HTML5使ç¨drawImage()æ¹æ³ç»å¶å¾å_html5æç¨æå·§
程序员文章站
2022-03-08 16:51:27
...
ä¸ãç»å¶å¾å
使ç¨drawImage()æ¹æ³ç»å¶å¾åãç»å¾ç¯å¢æä¾äºè¯¥æ¹æ³çä¸ä¸ªä¸åçæ¬ã
drawImage(image,x,y) ï¼ å¨canvasä¸(x,y)å¤ç»å¶å¾çã
drawImage(image,x,y,width,height) ï¼ å¨canvasä¸(x,y)å¤ç»å¶å¾çï¼å¹¶å°å ¶ç¼©æ¾å°æå®ç宽度åé«åº¦ã
drawImage(image,sourceX,sourceY,sourceWidth,sourceHeight,x,y,width,height) ï¼ ä»å¾çä¸åå²åºä¸ä¸ªç©å½¢åºå(sourceX,sourceY,sourceWidth,sourceHeight)ï¼ç¼©æ¾å°æå®ç宽度åé«åº¦ï¼å¹¶å¨canvasä¸(x,y)ç»å¶åºæ¥ã
äºãæ ç¾
ç»å¶å¾çåï¼è¿éè¦å°å¾çå è½½å°æµè§å¨ä¸ãè¿éæä»¬ä» ä» å¨canvasæ ç¾åé¢æ·»å ä¸ä¸ªæ ç¾ã
ä¸ãç»å¶å¾ç
HTML5
åãç»å¶ææ
äºãéä¸åå¦å ç´ æ
使ç¨drawImage()æ¹æ³ç»å¶å¾åãç»å¾ç¯å¢æä¾äºè¯¥æ¹æ³çä¸ä¸ªä¸åçæ¬ã
drawImage(image,x,y) ï¼ å¨canvasä¸(x,y)å¤ç»å¶å¾çã
drawImage(image,x,y,width,height) ï¼ å¨canvasä¸(x,y)å¤ç»å¶å¾çï¼å¹¶å°å ¶ç¼©æ¾å°æå®ç宽度åé«åº¦ã
drawImage(image,sourceX,sourceY,sourceWidth,sourceHeight,x,y,width,height) ï¼ ä»å¾çä¸åå²åºä¸ä¸ªç©å½¢åºå(sourceX,sourceY,sourceWidth,sourceHeight)ï¼ç¼©æ¾å°æå®ç宽度åé«åº¦ï¼å¹¶å¨canvasä¸(x,y)ç»å¶åºæ¥ã
äºãæ ç¾
ç»å¶å¾çåï¼è¿éè¦å°å¾çå è½½å°æµè§å¨ä¸ãè¿éæä»¬ä» ä» å¨canvasæ ç¾åé¢æ·»å ä¸ä¸ªæ ç¾ã
ä¸ãç»å¶å¾ç
å¤å¶ä»£ç
代ç å¦ä¸:åãç»å¶ææ
äºãéä¸åå¦å ç´ æ
上一篇: 上传图片时本地先预览如何实现