canvas卡通形象笑臉效果
分享一段程式碼例項,它利用canvas實現了卡通形象的笑臉效果。
程式碼例項如下:
[HTML] 純文字檢視 複製程式碼執行程式碼<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="author" content="http://www.softwhy.com/" /> <title>螞蟻部落</title> <style> * { padding: 0px; margin: 0px; } canvas { background: #fce501; } </style> </head> <body> <canvas id="myCanvas"></canvas> <script type="text/javascript"> var canvas = document.getElementById("myCanvas"); canvas.width = 500; canvas.height = 400; var ctx = canvas.getContext("2d"); ctx.beginPath(); ctx.fillStyle = '#000000'; ctx.arc(175, 160, 27, 0, 2 * Math.PI); ctx.closePath(); ctx.fill(); ctx.stroke(); ctx.beginPath(); ctx.fillStyle = '#ffffff'; ctx.arc(165, 149, 8, 0, 2 * Math.PI); ctx.closePath(); ctx.fill(); ctx.stroke(); ctx.beginPath(); ctx.fillStyle = '#000000'; ctx.arc(325, 160, 27, 0, 2 * Math.PI); ctx.closePath(); ctx.fill(); ctx.stroke(); ctx.beginPath(); ctx.fillStyle = '#ffffff'; ctx.arc(315, 149, 8, 0, 2 * Math.PI); ctx.closePath(); ctx.fill(); ctx.stroke(); ctx.beginPath(); ctx.fillStyle = '#ed6b49'; ctx.arc(135, 215, 23, 0, 2 * Math.PI); ctx.closePath(); ctx.fill(); // ctx.stroke(); ctx.beginPath(); ctx.fillStyle = '#ed6b49'; ctx.arc(365, 215, 23, 0, 2 * Math.PI); ctx.closePath(); ctx.fill(); ctx.beginPath(); ctx.fillStyle = '#000000'; ctx.arc(251, 221, 10, 180 * Math.PI / 180, 360 * Math.PI / 180, true); ctx.closePath(); ctx.fill(); ctx.stroke(); ctx.beginPath(); ctx.strokeStyle = '#000000'; ctx.lineWidth = 6; ctx.lineCap = 'round'; ctx.moveTo(182, 248); ctx.quadraticCurveTo(198, 275, 251, 252); ctx.stroke(); ctx.beginPath(); ctx.strokeStyle = '#000000'; ctx.lineWidth = 6; ctx.lineCap = 'round'; ctx.moveTo(310, 248); ctx.quadraticCurveTo(297, 275, 251, 252); ctx.stroke(); </script> </body> </html>
相關文章
- canvas繪製卡通人臉形象效果Canvas
- canvas繪製笑臉表情Canvas
- canvas繪製笑臉程式碼例項Canvas
- canvas實現的卡通人物形象程式碼例項Canvas
- CSS3卡通形象程式碼例項CSSS3
- 笑臉漏洞復現
- CSS3大熊貓卡通效果CSSS3
- Python指令碼檢測笑臉漏洞Python指令碼
- 笑臉符號 :-) 迎來30週歲生日符號
- Abstract Pack Mac(彩色卡通元素效果fcpx外掛)Mac
- canvas小球碰壁效果Canvas
- canvas矩形拖拽效果Canvas
- canvas簽名效果Canvas
- jQuery和CSS3繪製動態笑臉jQueryCSSS3
- canvas繪製憤怒小鳥形象程式碼例項Canvas
- canvas繪製流星效果Canvas
- canvas實現波浪效果Canvas
- canvas小球擺動效果Canvas
- canvas蔚藍星空效果Canvas
- CSS3哭臉效果CSSS3
- canvas設定陰影效果Canvas
- canvas圓形時鐘效果Canvas
- canvas繪製風車效果Canvas
- canvas小球落地彈動效果Canvas
- canvas環形資料效果Canvas
- canvas簡單畫板效果Canvas
- canvas畫布效果程式碼Canvas
- canvas動態時鐘效果Canvas
- canvas立體效果的圓環Canvas
- Anime Elements And Transitions Mac(卡通動漫元素轉場效果Pr預設)Mac
- Canvas系列之一——濾鏡效果Canvas
- canvas旋轉太極圖效果Canvas
- canvas透明度的矩形效果Canvas
- canvas水平勻速運動效果Canvas
- canvas環形進度條效果Canvas
- canvas具有漸變效果的矩形Canvas
- canvas實現 漂亮的下雨效果Canvas
- canvas漫天飛雪效果程式碼Canvas