API
- 應用程序接口
- 一個程序提供給另個一程序可以對本程序進行操作
- 外部接口:如查看天氣腕扶、汽車違章、菜譜等,URL著瓶,對URL進行請求,接口通常返回json數(shù)據(jù)/xml數(shù)據(jù)
- dom啼县、bom是API材原,nodeJS的模塊也是API
canvas
- 屬性
width height
用css和<canvas width='400' height='300'></canvas>
設(shè)置的寬高的區(qū)別:當下載畫布時,顯示的寬高是canvas設(shè)置的季眷,所以不要用css設(shè)置寬高
- 方法
getContext
繪制直線
-
獲取畫圖環(huán)境
var c=document.getElementById('id');
var cxt=c.getContext('2d') 設(shè)置繪圖路徑
cxt.moveTo()
cxt.lineTo()
描邊
cxt.strokeStyle='red'
cxt.lineWidth='100px'
cxt.stroke()
-
填充
cxt.fill()
cxt.fillStyle='red'
設(shè)置填充顏色填充到邊框?qū)挾鹊囊话?/em>
路徑的開始和關(guān)閉:beiginPath()华糖、closePath()
rect(x,y瘟裸,寬客叉,高),繪制矩形
快速矩形工具
- rect(x, y, width, height) 繪制矩形路徑
- strokeRect(x, y, width, height) 描邊矩形
- fillRect(x,y,width,height) 填充矩形
- clearRect(x,y,w,h) 清除矩形 (矩形范圍內(nèi)的內(nèi)容會被擦除)
圓形(圓弧)
- arc(x,y,r,start, end, wise) 繪制圓弧
- start/end是起始位置 單位是 弧度 , 360角度 = 2PI兼搏, 180角度 = PI
- 最后一個參數(shù) 順時針(false)/逆時針(true) 默認false