CanvasContext.beginPath
2020-08-26 16:37 更新
解释:开始创建一个路径,需要调用 fill 或者 stroke 才会使用路径进行填充或描边。
方法参数
无
示例
图片示例
代码示例
<canvas canvas-id="myCanvas" class="myCanvas" />
Page({
onLoad() {
const canvasContext = swan.createCanvasContext('myCanvas');
canvasContext.beginPath();
canvasContext.setLineWidth(5);
canvasContext.setStrokeStyle('blue');
canvasContext.moveTo(0, 75);
canvasContext.lineTo(250, 75);
canvasContext.stroke();
canvasContext.beginPath();
canvasContext.setStrokeStyle('red');
canvasContext.moveTo(50, 0);
canvasContext.lineTo(150, 130);
canvasContext.stroke();
canvasContext.draw();
}
});
以上内容是否对您有帮助:
更多建议: