溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

小程序怎么創(chuàng)建二次方貝塞爾曲線

發(fā)布時(shí)間:2022-03-09 10:25:20 來(lái)源:億速云 閱讀:123 作者:iii 欄目:開(kāi)發(fā)技術(shù)

這篇文章主要講解了“小程序怎么創(chuàng)建二次方貝塞爾曲線”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來(lái)研究和學(xué)習(xí)“小程序怎么創(chuàng)建二次方貝塞爾曲線”吧!

canvasContext.quadraticCurveTo


定義

創(chuàng)建二次貝塞爾曲線路徑。

Tip: 曲線的起始點(diǎn)為路徑中前一個(gè)點(diǎn)。

參數(shù)

參數(shù) 類型 說(shuō)明
cpx Number 貝塞爾控制點(diǎn)的x坐標(biāo)
cpy Number 貝塞爾控制點(diǎn)的y坐標(biāo)
x Number 結(jié)束點(diǎn)的x坐標(biāo)
y Number 結(jié)束點(diǎn)的y坐標(biāo)

例子

const ctx = wx.createCanvasContext('myCanvas')// Draw pointsctx.beginPath()
ctx.arc(20, 20, 2, 0, 2 * Math.PI)
ctx.setFillStyle('red')
ctx.fill()

ctx.beginPath()
ctx.arc(200, 20, 2, 0, 2 * Math.PI)
ctx.setFillStyle('lightgreen')
ctx.fill()

ctx.beginPath()
ctx.arc(20, 100, 2, 0, 2 * Math.PI)
ctx.setFillStyle('blue')
ctx.fill()

ctx.setFillStyle('black')
ctx.setFontSize(12)// Draw guidesctx.beginPath()
ctx.moveTo(20, 20)
ctx.lineTo(20, 100)
ctx.lineTo(200, 20)
ctx.setStrokeStyle('#AAAAAA')
ctx.stroke()// Draw quadratic curvectx.beginPath()
ctx.moveTo(20, 20)
ctx.quadraticCurveTo(20, 100, 200, 20)
ctx.setStrokeStyle('black')
ctx.stroke()

ctx.draw()

針對(duì) moveTo(20, 20) quadraticCurveTo(20, 100, 200, 20)的三個(gè)關(guān)鍵坐標(biāo)如下:

  • 紅色:起始點(diǎn)(20, 20)

  • 藍(lán)色:控制點(diǎn)(20, 100)

  • 綠色:終止點(diǎn)(200, 20)

感謝各位的閱讀,以上就是“小程序怎么創(chuàng)建二次方貝塞爾曲線”的內(nèi)容了,經(jīng)過(guò)本文的學(xué)習(xí)后,相信大家對(duì)小程序怎么創(chuàng)建二次方貝塞爾曲線這一問(wèn)題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是億速云,小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI