CanvasContext.setLineCap

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

方法参数

StringlineCap

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

示例

在开发者工具中预览效果

扫码体验

CanvasContext.setLineCap - 图1请使用百度APP扫码

图片示例

图片

代码示例

  1. const canvasContext = swan.createCanvasContext('myCanvas');
  2. canvasContext.beginPath();
  3. canvasContext.moveTo(30, 10);
  4. canvasContext.lineTo(200, 10);
  5. canvasContext.stroke();
  6. canvasContext.beginPath();
  7. canvasContext.setLineCap('butt');
  8. canvasContext.setLineWidth(10);
  9. canvasContext.moveTo(50, 30);
  10. canvasContext.lineTo(200, 30);
  11. canvasContext.stroke();
  12. canvasContext.beginPath();
  13. canvasContext.setLineCap('round');
  14. canvasContext.setLineWidth(10);
  15. canvasContext.moveTo(70, 50);
  16. canvasContext.lineTo(200, 50);
  17. canvasContext.stroke();
  18. canvasContext.beginPath();
  19. canvasContext.setLineCap('square');
  20. canvasContext.setLineWidth(10);
  21. canvasContext.moveTo(90, 70);
  22. canvasContext.lineTo(200, 70);
  23. canvasContext.stroke();
  24. canvasContext.draw();