欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

HTML5 canvas rect() 方法

實(shí)例

繪制 150*100 像素的矩形:

Your browser does not support the HTML5 canvas tag.

JavaScript:

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

親自試一試

瀏覽器支持

Internet Explorer 9、Firefox、Opera、Chrome 以及 Safari 支持 rect() 方法。

注釋:Internet Explorer 8 或更早的瀏覽器不支持 <canvas> 元素。

定義和用法

rect() 方法創(chuàng)建矩形。

提示:請(qǐng)使用 stroke()fill() 方法在畫布上實(shí)際地繪制矩形。

JavaScript 語(yǔ)法:

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

參數(shù)值

參數(shù) 描述
x 矩形左上角的 x 坐標(biāo)
y 矩形左上角的 y 坐標(biāo)
width 矩形的寬度,以像素計(jì)
height 矩形的高度,以像素計(jì)

更多實(shí)例

通過(guò) rect() 方法來(lái)創(chuàng)建三個(gè)矩形:

Your browser does not support the HTML5 canvas tag.

JavaScript:

JavaScript:
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");

// 紅色矩形
ctx.beginPath();
ctx.lineWidth="6";
ctx.strokeStyle="red";
ctx.rect(5,5,290,140);
ctx.stroke();

// 綠色矩形
ctx.beginPath();
ctx.lineWidth="4";
ctx.strokeStyle="green";
ctx.rect(30,30,50,50);
ctx.stroke();

// 藍(lán)色矩形
ctx.beginPath();
ctx.lineWidth="10";
ctx.strokeStyle="blue";
ctx.rect(50,50,150,80);
ctx.stroke();

親自試一試