Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat small program API drawing setLineCap (set line endpoint style)


May 19, 2021 WeChat Mini Program Development Document


Table of contents


WeChat small program API drawing setLineCap (set line endpoint style) Drawing interfaces and methods


canvasContext.setLineCap


Defined

Set the end style of the line.

Parameters

Parameters Type Range Description
lineCap String 'butt'、'round'、'square' The end endpoint style of the line

Example code:

const ctx = wx.createCanvasContext('myCanvas')
ctx.beginPath()
ctx.moveTo(10, 10)
ctx.lineTo(150, 10)
ctx.stroke()

ctx.beginPath()
ctx.setLineCap('butt')
ctx.setLineWidth(10)
ctx.moveTo(10, 30)
ctx.lineTo(150, 30)
ctx.stroke()

ctx.beginPath()
ctx.setLineCap('round')
ctx.setLineWidth(10)
ctx.moveTo(10, 50)
ctx.lineTo(150, 50)
ctx.stroke()

ctx.beginPath()
ctx.setLineCap('square')
ctx.setLineWidth(10)
ctx.moveTo(10, 70)
ctx.lineTo(150, 70)
ctx.stroke()

ctx.draw()

WeChat small program API drawing setLineCap (set line endpoint style)

WeChat small program API drawing setLineCap (set line endpoint style) Drawing interfaces and methods