CanvasContext.setLineWidth

解释:设置线条的宽度。

方法参数

Number lineWidth

lineWidth参数说明 :线条的宽度(单位是 px)

示例

在开发者工具中预览效果

扫码体验

CanvasContext.setLineWidth - 图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.setLineWidth(5);
  8. canvasContext.moveTo(50, 30);
  9. canvasContext.lineTo(200, 30);
  10. canvasContext.stroke();
  11. canvasContext.beginPath();
  12. canvasContext.setLineWidth(10);
  13. canvasContext.moveTo(70, 50);
  14. canvasContext.lineTo(200, 50);
  15. canvasContext.stroke();
  16. canvasContext.beginPath();
  17. canvasContext.setLineWidth(15);
  18. canvasContext.moveTo(90, 70);
  19. canvasContext.lineTo(200, 70);
  20. canvasContext.stroke();
  21. canvasContext.draw();