اذهب إلى المحتوى
  • 0

كيف اكتب كود يرسم مسجد

Huda Abdulrahman

السؤال

Recommended Posts

  • 0

ممكن بالjavascript في صفحه ويب

<!doctype>
<html>
<head>
<title>Drawing a mosque</title>
<style>
</style>
</head>
<body dir="">
<canvas id="cnvs" style="width:100%;height:100%;background:green;">
</canvas> 
<script>
function drawcol(ctx, x, y, w, h){
    ctx.strokeRect(x, y, w, h);
    ctx.beginPath();
    ctx.moveTo(x+w/2, h-w+y);
    ctx.lineTo(x, h+y);
    ctx.moveTo(x+w/2, h-w+y);
    ctx.lineTo(x+w, h+y);
    ctx.stroke();
    ctx.fillStyle="#fff";
    ctx.beginPath();
    ctx.arc(x+w-w/4, h-w+y-w/2, w/2, 0, 2* Math.PI);
    ctx.fill();
    ctx.fillStyle="black";
    ctx.beginPath();
    ctx.arc(x+w-w/4+w/10, h-w+y-w/2-w/10, w/2, 0, 2 * Math.PI);
    ctx.fill();
}

function draw(){
    var c = document.getElementById('cnvs');
    var w=c.width, h=c.height;
    var ctx=c.getContext('2d');
    var mw=w/10, mh=h/10;
    
    ctx.fillStyle="black";
    ctx.strokeStyle="#fff";
    ctx.fillRect(0, 0, w, h);
    ctx.translate(w/2, h/2+mh*4);
    ctx.strokeRect(-mw*3, 0, mw*6, -mh*3);
    ctx.strokeRect(-mw, 0, mw*2, -mh*1.5);
    drawcol(ctx, -mw/2, -mh*3, mw, -mh*1.6);
    drawcol(ctx, -mw*4, 0, mw, -mh*5);
    drawcol(ctx,mw*3, 0, mw, -mh*5);
}
draw();
</script>
</body>
</html>

Screenshot_٢٠١٩٠٦٢٢-١٩٣٦١٤.png

رابط هذا التعليق
شارك على الشبكات الإجتماعية

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...