HTML5 canvas fillRect() ·½·¨

ʵÀý

»æÖÆ 150*100 ÏñËØµÄÒÑÌî³ä¾ØÐΣº

Your browser does not support the HTML5 canvas tag.

JavaScript:

var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.fillRect(20,20,150,100);

Ç××ÔÊÔÒ»ÊÔ

ä¯ÀÀÆ÷Ö§³Ö

Internet Explorer 9¡¢Firefox¡¢Opera¡¢Chrome ÒÔ¼° Safari Ö§³Ö fillRect() ·½·¨¡£

×¢ÊÍ£ºInternet Explorer 8 »ò¸üÔçµÄä¯ÀÀÆ÷²»Ö§³Ö <canvas> ÔªËØ¡£

¶¨ÒåºÍÓ÷¨

fillRect() ·½·¨»æÖÆ¡°ÒÑÌîÉ«¡±µÄ¾ØÐΡ£Ä¬ÈϵÄÌî³äÑÕÉ«ÊǺÚÉ«¡£

Ìáʾ£ºÇëʹÓà fillStyle ÊôÐÔÀ´ÉèÖÃÓÃÓÚÌî³ä»æÍ¼µÄÑÕÉ«¡¢½¥±ä»òģʽ¡£

JavaScript Óï·¨£º

context.fillRect(x,y,width,height);

²ÎÊýÖµ

²ÎÊý ÃèÊö
x ¾ØÐÎ×óÉÏ½ÇµÄ x ×ø±ê
y ¾ØÐÎ×óÉÏ½ÇµÄ y ×ø±ê
width ¾ØÐεĿí¶È£¬ÒÔÏñËØ¼Æ
height ¾ØÐεĸ߶ȣ¬ÒÔÏñËØ¼Æ
VUE