微信小程序API 繪圖setLineCap(設(shè)置線條端點(diǎn)樣式)

2022-05-09 16:37 更新

微信小程序 canvas接口和方法繪圖接口和方法


canvasContext.setLineCap


定義

設(shè)置線條的端點(diǎn)樣式。

參數(shù)

參數(shù)類型范圍說(shuō)明
lineCapString'butt'、'round'、'square'線條的結(jié)束端點(diǎn)樣式

示例代碼:

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


微信小程序 canvas接口和方法繪圖接口和方法

以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)