回复
HarmonyOS/OpenHarmony应用开发-ArkTS画布组件(十五)
鸿蒙时代
发布于 2023-4-28 11:05
浏览
0收藏
quadraticCurveTo
quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void
创建二次贝赛尔曲线的路径。
示例:
.// xxx.ets
.@Entry
.@Component
.struct QuadraticCurveTo {
. private settings: RenderingContextSettings = new RenderingContextSettings(true)
. private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
.
. build() {
. Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
. Canvas(this.context)
. .width('100%')
. .height('100%')
. .backgroundColor('#ffff00')
. .onReady(() =>{
. this.context.beginPath()
. this.context.moveTo(20, 20)
. this.context.quadraticCurveTo(100, 100, 200, 20)
. this.context.stroke()
. })
. }
. .width('100%')
. .height('100%')
. }
.}
arc
arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void
示例:
.// xxx.ets
.@Entry
.@Component
.struct Arc {
. private settings: RenderingContextSettings = new RenderingContextSettings(true)
. private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
.
. build() {
. Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
. Canvas(this.context)
. .width('100%')
. .height('100%')
. .backgroundColor('#ffff00')
. .onReady(() =>{
. this.context.beginPath()
. this.context.arc(100, 75, 50, 0, 6.28)
. this.context.stroke()
. })
. }
. .width('100%')
. .height('100%')
. }
.}
标签
HarmonyOSOpenHarmony应用开发-ArkTS画布组.docx 30.79K 14次下载
已于2023-4-28 11:05:37修改
赞
收藏
回复
相关推荐