99热99这里只有精品6国产,亚洲中文字幕在线天天更新,在线观看亚洲精品国产福利片 ,久久久久综合网

歡迎加入QQ討論群258996829
麥子學院 頭像
蘋果6袋
6
麥子學院

HTML5之CANVAS學習

發(fā)布時間:2016-07-12 20:55  回復:0  查看:2476   最后回復:2016-07-12 20:55  

canvashtml5出現(xiàn)的新標簽,主要用來畫圖,看見網(wǎng)上能用來實現(xiàn)各種圖形,所以感覺很好玩,就學習了一下。希望對正在入門HTML5 的童鞋有用。
canvas繪制圖形有兩種方法:

 

context.fill() //填充

 

 

context.stroke() //繪制邊框

 

在繪制圖形前要設置好圖形樣式,也有兩種方法:

 

context.fillStyle() //填充的樣式

 

 

context.strokeStyle() //邊框樣式

 

 

下面就開始繪制各種圖形

 

繪制矩形
context.fillRect(x,y,width,height)
context.fillRect(x,y,width,height)
x : 矩形的起點橫坐標
y : 矩形的起點縱坐標
width : 矩形的寬度

 

function draw(){

        var canvas = document.getElementById('chen'),

            context = canvas.getContext('2d');

            canvas.width = 100;

            canvas.height = 100;

            context.fillStyle = 'red';        //發(fā)現(xiàn)要先設置填充顏色

            context.fillRect(0, 0, 100 ,100);

            context.strokeRect(0, 100, 100 ,100);

            

    }

 draw();

 


context.arc(x,y,radius,starAngle,endAngle, anticlockwose)
radius : 半徑

 

 

 

原文來自:JSER

 

您還未登錄,請先登錄

熱門帖子

最新帖子

?