HTML5表白愛心代碼 真是太浪漫啦!
<!doctype html> <html> <head> <meta charset="UTF-8"> <title>表白愛心代碼</title> </head> <body> <canvas id="heart" width="200" height="200"></canvas> <script> var canvas = document.getElementById('heart'); var ctx = canvas.getContext('2d'); var x = canvas.width / 2; var y = canvas.height / 2; var rad = Math.PI / 12; ctx.rotate(rad); ctx.translate(100, 0); ctx.scale(0.8, 0.8); ctx.beginPath(); ctx.fillStyle = "#fd0053"; var c = Math.cos(rad), s = Math.sin(rad); ctx.moveTo(100 * c, 100 * s); for (var i = 0; i< 13; i++) { var x1 = 100 * Math.cos(rad * i); var y1 = 100 * Math.sin(rad * i); var x2 = 50 * Math.cos(rad * (i + 0.5)); var y2 = 50 * Math.sin(rad * (i + 0.5)); ctx.quadraticCurveTo(x1, y1, x2, y2); } ctx.closePath(); ctx.fill(); </script> </body> </html>
使用該愛心代碼,你可以在網頁上添加一個浪漫的、閃閃發亮的愛心形狀!能夠讓你甜蜜地向ta表白哦!快去試試吧!
上一篇html5表白動畫代碼
下一篇html5表格表單代碼