CanvasContext.setLineCap

解释:设置线条的端点样式。

# 方法参数

StringlineCap

lineCap参数说明 :有效值:'butt'、'round'、'square', 线条的结束端点样式。

# 示例

在开发者工具中预览效果

# 扫码体验

请使用百度APP扫码

# 图片示例

图片

# 代码示例

    const canvasContext = swan.createCanvasContext('myCanvas');
    canvasContext.beginPath();
    canvasContext.moveTo(30, 10);
    canvasContext.lineTo(200, 10);
    canvasContext.stroke();
    
    canvasContext.beginPath();
    canvasContext.setLineCap('butt');
    canvasContext.setLineWidth(10);
    canvasContext.moveTo(50, 30);
    canvasContext.lineTo(200, 30);
    canvasContext.stroke();
    
    canvasContext.beginPath();
    canvasContext.setLineCap('round');
    canvasContext.setLineWidth(10);
    canvasContext.moveTo(70, 50);
    canvasContext.lineTo(200, 50);
    canvasContext.stroke();
    
    canvasContext.beginPath();
    canvasContext.setLineCap('square');
    canvasContext.setLineWidth(10);
    canvasContext.moveTo(90, 70);
    canvasContext.lineTo(200, 70);
    canvasContext.stroke();
    
    canvasContext.draw();