獲取Image對象,new出來
定義Image對象的src屬性,參數(shù):圖片路徑
定義Image對象的onload方法,調(diào)用context對象的drawImage()方法,參數(shù):Image對象,x坐標(biāo),y坐標(biāo)
重載方法,調(diào)用context對象的drawImage()方法,參數(shù):Image對象,x坐標(biāo),y坐標(biāo),圖像寬度,高度
重載方法,調(diào)用context對象的drawImage()方法,
參數(shù):
Image對象,圖像上x坐標(biāo),圖像上y坐標(biāo),矩形寬度,矩形高度,畫在畫布上的x坐標(biāo),畫在畫布上的y坐標(biāo),圖像寬度,圖像高度
調(diào)用context對象的getImageData()方法,得到像素顏色數(shù)組,參數(shù):x坐標(biāo),y坐標(biāo),x寬度,y寬度
調(diào)用context對象的putImageData ()方法,設(shè)置圖片顏色,參數(shù):ImageData對象,x坐標(biāo),y坐標(biāo)
新聞熱點(diǎn)
疑難解答