提交 ed8a9201 编写于 作者: Y yaoyuchi

edit canvas doc

Signed-off-by: Nyaoyuchi <yaoyuchi@huawei.com>
上级 758b703f
...@@ -78,7 +78,7 @@ Canvas\(context: CanvasRenderingContext2D\) ...@@ -78,7 +78,7 @@ Canvas\(context: CanvasRenderingContext2D\)
@Entry @Entry
@Component @Component
struct CanvasExample { struct CanvasExample {
private settings: RenderingContextSettings = new RenderingContextSettings(true,true) private settings: RenderingContextSettings = new RenderingContextSettings(true)
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
build() { build() {
......
...@@ -56,9 +56,8 @@ addColorStop\(offset: number, color: string\): void ...@@ -56,9 +56,8 @@ addColorStop\(offset: number, color: string\): void
@Entry @Entry
@Component @Component
struct Page45 { struct Page45 {
private settings: RenderingContextSettings = new RenderingContextSettings(true,true) private settings: RenderingContextSettings = new RenderingContextSettings(true)
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
private gra:CanvasGradient = new CanvasGradient()
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
...@@ -68,9 +67,9 @@ addColorStop\(offset: number, color: string\): void ...@@ -68,9 +67,9 @@ addColorStop\(offset: number, color: string\): void
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
var grad = this.context.createLinearGradient(50,0, 300,100) var grad = this.context.createLinearGradient(50,0, 300,100)
this.gra.addColorStop(0.0, 'red') grad.addColorStop(0.0, 'red')
this.gra.addColorStop(0.5, 'white') grad.addColorStop(0.5, 'white')
this.gra.addColorStop(1.0, 'green') grad.addColorStop(1.0, 'green')
this.context.fillStyle = grad this.context.fillStyle = grad
this.context.fillRect(0, 0, 500, 500) this.context.fillRect(0, 0, 500, 500)
}) })
......
...@@ -83,7 +83,7 @@ ImageBitmap\(src: string\) ...@@ -83,7 +83,7 @@ ImageBitmap\(src: string\)
@Entry @Entry
@Component @Component
struct DrawImageExample { struct DrawImageExample {
private settings:RenderingContextSettings = new RenderingContextSettings(true,true) private settings:RenderingContextSettings = new RenderingContextSettings(true)
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
private img:ImageBitmap = new ImageBitmap("common/images/example.jpg") private img:ImageBitmap = new ImageBitmap("common/images/example.jpg")
......
...@@ -45,7 +45,7 @@ addPath\(path: Object\): void ...@@ -45,7 +45,7 @@ addPath\(path: Object\): void
@Entry @Entry
@Component @Component
struct AddPath { struct AddPath {
private settings: RenderingContextSettings = new RenderingContextSettings(true,true) private settings: RenderingContextSettings = new RenderingContextSettings(true)
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
private path2Da: Path2D = new Path2D("M250 150 L150 350 L350 350 Z") private path2Da: Path2D = new Path2D("M250 150 L150 350 L350 350 Z")
...@@ -83,7 +83,7 @@ closePath\(\): void ...@@ -83,7 +83,7 @@ closePath\(\): void
@Entry @Entry
@Component @Component
struct ClosePath { struct ClosePath {
private settings: RenderingContextSettings = new RenderingContextSettings(true,true) private settings: RenderingContextSettings = new RenderingContextSettings(true)
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
private path2Db: Path2D = new Path2D() private path2Db: Path2D = new Path2D()
...@@ -161,7 +161,7 @@ moveTo\(x: number, y: number\): void ...@@ -161,7 +161,7 @@ moveTo\(x: number, y: number\): void
@Entry @Entry
@Component @Component
struct MoveTo { struct MoveTo {
private settings: RenderingContextSettings = new RenderingContextSettings(true,true) private settings: RenderingContextSettings = new RenderingContextSettings(true)
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
private path2Db: Path2D = new Path2D() private path2Db: Path2D = new Path2D()
...@@ -239,7 +239,7 @@ lineTo\(x: number, y: number\): void ...@@ -239,7 +239,7 @@ lineTo\(x: number, y: number\): void
@Entry @Entry
@Component @Component
struct LineTo { struct LineTo {
private settings: RenderingContextSettings = new RenderingContextSettings(true,true) private settings: RenderingContextSettings = new RenderingContextSettings(true)
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
private path2Db: Path2D = new Path2D() private path2Db: Path2D = new Path2D()
...@@ -363,7 +363,7 @@ bezierCurveTo\(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number ...@@ -363,7 +363,7 @@ bezierCurveTo\(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number
@Entry @Entry
@Component @Component
struct BezierCurveTo { struct BezierCurveTo {
private settings: RenderingContextSettings = new RenderingContextSettings(true,true) private settings: RenderingContextSettings = new RenderingContextSettings(true)
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
private path2Db: Path2D = new Path2D() private path2Db: Path2D = new Path2D()
...@@ -460,7 +460,7 @@ quadraticCurveTo\(cpx: number, cpy: number, x: number ,y: number\): void ...@@ -460,7 +460,7 @@ quadraticCurveTo\(cpx: number, cpy: number, x: number ,y: number\): void
@Entry @Entry
@Component @Component
struct QuadraticCurveTo { struct QuadraticCurveTo {
private settings: RenderingContextSettings = new RenderingContextSettings(true,true) private settings: RenderingContextSettings = new RenderingContextSettings(true)
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
private path2Db: Path2D = new Path2D() private path2Db: Path2D = new Path2D()
...@@ -580,7 +580,7 @@ arc\(x: number, y: number, radius: number, startAngle: number, endAngle: number, ...@@ -580,7 +580,7 @@ arc\(x: number, y: number, radius: number, startAngle: number, endAngle: number,
@Entry @Entry
@Component @Component
struct Arc { struct Arc {
private settings: RenderingContextSettings = new RenderingContextSettings(true,true) private settings: RenderingContextSettings = new RenderingContextSettings(true)
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
private path2Db: Path2D = new Path2D() private path2Db: Path2D = new Path2D()
...@@ -687,7 +687,7 @@ arcTo\(x1: number, y1: number, x2: number, y2: number, radius: number\): void ...@@ -687,7 +687,7 @@ arcTo\(x1: number, y1: number, x2: number, y2: number, radius: number\): void
@Entry @Entry
@Component @Component
struct ArcTo { struct ArcTo {
private settings: RenderingContextSettings = new RenderingContextSettings(true,true) private settings: RenderingContextSettings = new RenderingContextSettings(true)
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
private path2Db: Path2D = new Path2D() private path2Db: Path2D = new Path2D()
...@@ -827,8 +827,8 @@ ellipse\(x: number, y: number, radiusX: number, radiusY: number, rotation: numbe ...@@ -827,8 +827,8 @@ ellipse\(x: number, y: number, radiusX: number, radiusY: number, rotation: numbe
``` ```
@Entry @Entry
@Component @Component
struct Ellipse { struct CanvasExample {
private settings: RenderingContextSettings = new RenderingContextSettings(true,true) private settings: RenderingContextSettings = new RenderingContextSettings(true)
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
private path2Db: Path2D = new Path2D() private path2Db: Path2D = new Path2D()
...@@ -924,8 +924,8 @@ rect\(x: number, y: number, width: number, height: number\): void ...@@ -924,8 +924,8 @@ rect\(x: number, y: number, width: number, height: number\): void
``` ```
@Entry @Entry
@Component @Component
struct Rect { struct CanvasExample {
private settings: RenderingContextSettings = new RenderingContextSettings(true,true) private settings: RenderingContextSettings = new RenderingContextSettings(true)
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
private path2Db: Path2D = new Path2D() private path2Db: Path2D = new Path2D()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册