CanvasContext.beginPath

解释:开始创建一个路径,需要调用 fill 或者 stroke 才会使用路径进行填充或描边。

# 方法参数

# 示例

扫码体验
重新加载
请使用百度APP扫码

# 图片示例

# 代码示例

    <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();
        }
    });