canvas繪製熊貓頭像程式碼例項
分享一段程式碼例項,它利用canvas繪製了熊貓頭像的效果。
程式碼例項如下:
[HTML] 純文字檢視 複製程式碼<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="author" content="http://www.softwhy.com/" /> <title>螞蟻部落</title> </head> <body> <canvas id='canvas' width='700' height='500'></canvas> <script> var cvs = document.getElementById('canvas'); var context = cvs.getContext("2d"); function circle(x, y, r, color, flag) { var flag = flag; context.beginPath(); context.fillStyle = color; context.arc(x, y, r, 0, 2 * Math.PI, false); context.closePath(); context.fill(); if (flag) { context.stroke(); } } //左耳 circle(217, 158, 70, '#000', false); //右耳 circle(567, 158, 70, '#000', false); //左眼 circle(397, 283, 200, '#fff', true); circle(298, 283, 50, 'black', false); circle(312, 283, 15, '#fff', false); circle(318, 286, 10, '#000', false); circle(320, 286, 4, '#fff', false); circle(318, 281, 2, '#fff', false); //右眼 circle(487, 283, 50, 'black', false); circle(482, 283, 15, '#fff', false); circle(476, 286, 10, '#000', false); circle(474, 286, 4, '#fff', false); circle(476, 280, 2, '#fff', false); //鼻子 circle(397, 330, 15, '#1f1a17', false); //嘴巴 context.beginPath(); context.strokeStyle = 'black'; context.arc(397, 390, 35, -Math.PI / 6, 7 * Math.PI / 6, false); context.stroke(); </script> </body> </html>
相關文章
- canvas繪製機器貓程式碼例項Canvas
- canvas繪製箭頭效果程式碼例項Canvas
- canvas繪製扇形程式碼例項Canvas
- canvas繪製網格程式碼例項Canvas
- canvas繪製拋物線程式碼例項Canvas線程
- canvas繪製圓形鐘錶程式碼例項Canvas
- css繪製圓形程式碼例項CSS
- SVG拖動繪製矩形程式碼例項SVG
- canvas刮刮樂程式碼例項Canvas
- canvas載入效果程式碼例項Canvas
- canvas原型鐘錶效果程式碼例項Canvas原型
- canvas氣泡上浮效果程式碼例項Canvas
- CSS3繪製太極圖程式碼例項詳解CSSS3
- canvas translate()、scale()和rotate()方法程式碼例項Canvas
- CSS空心箭頭程式碼例項CSS
- UML類圖繪製例項
- 例項QT程式 —— Qt自繪製小時鐘QT
- 純div+css3程式碼繪製kitty貓CSSS3
- table表頭分組程式碼例項
- E-R圖繪製例項
- 資料流圖繪製例項
- Python例項:僅繪製圖例而不繪製實際的圖形Python
- canvas 繪製扇形Canvas
- canvas 繪製文字Canvas
- canvas 繪製矩形Canvas
- canvas 奇巧淫技(二)繪製箭頭路徑效果Canvas
- 小程式canvas居中剪裁繪製圖片Canvas
- canvas 繪製圓形Canvas
- canvas繪製流星效果Canvas
- canvas繪製直線Canvas
- canvas lineWidth 繪製原理Canvas
- canvas lineWidth繪製原理Canvas
- canvas 繪製線條Canvas
- 原生Canvas繪製餅圖,我是不是被騙程式碼了Canvas
- QT OPENGL 與 shader 繪製展示視訊程式碼例項 OPenGL直接顯示YUV資料QT
- canvas 繪製圓角矩形Canvas
- canvas 繪製雙線技巧Canvas
- canvas繪製矩形框Canvas
- canvas繪製風車效果Canvas