canvas 绘制二次贝塞尔曲线

      2020-03-26 08:37      HTML5

<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>canvas</title><script>function init() {var canvas=document.getElementById(‘canvas‘);var ctx=canvas.getContext(‘2d‘);ctx.strokeStyle="dark";ctx.beginPath();ctx.moveTo(0,200);ctx.quadraticCurveTo(75,50,300,200);ctx.stroke();ctx.globalCompositeOperation="source-over";ctx.strokeStyle="blue";ctx.beginPath();ctx.moveTo(75,50);ctx.lineTo(0,200);ctx.moveTo(75,50);ctx.lineTo(300,200);ctx.stroke();}</script></head><body><canvas></canvas></body></html>