未验证 提交 db36d175 编写于 作者: O openharmony_ci 提交者: Gitee

!23930 reference/arkui-ts部分文件arkts整改

Merge pull request !23930 from liuliu/arkui0904
...@@ -45,8 +45,8 @@ struct LongPressGestureExample { ...@@ -45,8 +45,8 @@ struct LongPressGestureExample {
.gesture( .gesture(
LongPressGesture({ repeat: true }) LongPressGesture({ repeat: true })
// 由于repeat设置为true,长按动作存在时会连续触发,触发间隔为duration(默认值500ms) // 由于repeat设置为true,长按动作存在时会连续触发,触发间隔为duration(默认值500ms)
.onAction((event: GestureEvent) => { .onAction((event?: GestureEvent) => {
if (event.repeat) { if (event && event.repeat) {
this.count++ this.count++
} }
}) })
......
...@@ -95,12 +95,14 @@ struct PanGestureExample { ...@@ -95,12 +95,14 @@ struct PanGestureExample {
// 左右拖动触发该手势事件 // 左右拖动触发该手势事件
.gesture( .gesture(
PanGesture(this.panOption) PanGesture(this.panOption)
.onActionStart((event: GestureEvent) => { .onActionStart((event?: GestureEvent) => {
console.info('Pan start') console.info('Pan start')
}) })
.onActionUpdate((event: GestureEvent) => { .onActionUpdate((event?: GestureEvent) => {
this.offsetX = this.positionX + event.offsetX if (event) {
this.offsetY = this.positionY + event.offsetY this.offsetX = this.positionX + event.offsetX
this.offsetY = this.positionY + event.offsetY
}
}) })
.onActionEnd(() => { .onActionEnd(() => {
this.positionX = this.offsetX this.positionX = this.offsetX
......
...@@ -56,13 +56,15 @@ struct PinchGestureExample { ...@@ -56,13 +56,15 @@ struct PinchGestureExample {
// 三指捏合触发该手势事件 // 三指捏合触发该手势事件
.gesture( .gesture(
PinchGesture({ fingers: 3 }) PinchGesture({ fingers: 3 })
.onActionStart((event: GestureEvent) => { .onActionStart((event?: GestureEvent) => {
console.info('Pinch start') console.info('Pinch start')
}) })
.onActionUpdate((event: GestureEvent) => { .onActionUpdate((event?: GestureEvent) => {
this.scaleValue = this.pinchValue * event.scale if (event) {
this.pinchX = event.pinchCenterX this.scaleValue = this.pinchValue * event.scale
this.pinchY = event.pinchCenterY this.pinchX = event.pinchCenterX
this.pinchY = event.pinchCenterY
}
}) })
.onActionEnd(() => { .onActionEnd(() => {
this.pinchValue = this.scaleValue this.pinchValue = this.scaleValue
......
...@@ -53,11 +53,13 @@ struct RotationGestureExample { ...@@ -53,11 +53,13 @@ struct RotationGestureExample {
// 双指旋转触发该手势事件 // 双指旋转触发该手势事件
.gesture( .gesture(
RotationGesture() RotationGesture()
.onActionStart((event: GestureEvent) => { .onActionStart((event?: GestureEvent) => {
console.info('Rotation start') console.info('Rotation start')
}) })
.onActionUpdate((event: GestureEvent) => { .onActionUpdate((event?: GestureEvent) => {
this.angle = this.rotateValue + event.angle if (event) {
this.angle = this.rotateValue + event.angle
}
}) })
.onActionEnd(() => { .onActionEnd(() => {
this.rotateValue = this.angle this.rotateValue = this.angle
......
...@@ -59,9 +59,11 @@ struct SwipeGestureExample { ...@@ -59,9 +59,11 @@ struct SwipeGestureExample {
// 单指竖直方向滑动时触发该事件 // 单指竖直方向滑动时触发该事件
.gesture( .gesture(
SwipeGesture({ direction: SwipeDirection.Vertical }) SwipeGesture({ direction: SwipeDirection.Vertical })
.onAction((event: GestureEvent) => { .onAction((event?: GestureEvent) => {
this.speed = event.speed if (event) {
this.rotateAngle = event.angle this.speed = event.speed
this.rotateAngle = event.angle
}
}) })
) )
}.width('100%') }.width('100%')
......
...@@ -41,8 +41,10 @@ struct TapGestureExample { ...@@ -41,8 +41,10 @@ struct TapGestureExample {
Text('Click twice').fontSize(28) Text('Click twice').fontSize(28)
.gesture( .gesture(
TapGesture({ count: 2 }) TapGesture({ count: 2 })
.onAction((event: GestureEvent) => { .onAction((event?: GestureEvent) => {
this.value = JSON.stringify(event.fingerList[0]) if (event) {
this.value = JSON.stringify(event.fingerList[0])
}
}) })
) )
Text(this.value) Text(this.value)
......
...@@ -1425,8 +1425,10 @@ createPattern(image: ImageBitmap, repetition: string | null): CanvasPattern | nu ...@@ -1425,8 +1425,10 @@ createPattern(image: ImageBitmap, repetition: string | null): CanvasPattern | nu
.height('100%') .height('100%')
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
var pattern = this.context.createPattern(this.img, 'repeat') let pattern = this.context.createPattern(this.img, 'repeat')
this.context.fillStyle = pattern if (pattern) {
this.context.fillStyle = pattern
}
this.context.fillRect(0, 0, 200, 200) this.context.fillRect(0, 0, 200, 200)
}) })
} }
...@@ -2423,7 +2425,7 @@ getImageData(sx: number, sy: number, sw: number, sh: number): ImageData ...@@ -2423,7 +2425,7 @@ getImageData(sx: number, sy: number, sw: number, sh: number): ImageData
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
this.context.drawImage(this.img,0,0,130,130) this.context.drawImage(this.img,0,0,130,130)
var imagedata = this.context.getImageData(50,50,130,130) let imagedata = this.context.getImageData(50,50,130,130)
this.context.putImageData(imagedata,150,150) this.context.putImageData(imagedata,150,150)
}) })
} }
...@@ -2475,8 +2477,8 @@ putImageData(imageData: ImageData, dx: number | string, dy: number | string, dir ...@@ -2475,8 +2477,8 @@ putImageData(imageData: ImageData, dx: number | string, dy: number | string, dir
.height('100%') .height('100%')
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
var imageData = this.context.createImageData(100, 100) let imageData = this.context.createImageData(100, 100)
for (var i = 0; i < imageData.data.length; i += 4) { for (let i = 0; i < imageData.data.length; i += 4) {
imageData.data[i + 0] = 255 imageData.data[i + 0] = 255
imageData.data[i + 1] = 0 imageData.data[i + 1] = 0
imageData.data[i + 2] = 255 imageData.data[i + 2] = 255
...@@ -2628,15 +2630,15 @@ transferFromImageBitmap(bitmap: ImageBitmap): void ...@@ -2628,15 +2630,15 @@ transferFromImageBitmap(bitmap: ImageBitmap): void
.height('100%') .height('100%')
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
var imageData = this.offContext.createImageData(100, 100) let imageData = this.offContext.createImageData(100, 100)
for (var i = 0; i < imageData.data.length; i += 4) { for (let i = 0; i < imageData.data.length; i += 4) {
imageData.data[i + 0] = 255 imageData.data[i + 0] = 255
imageData.data[i + 1] = 0 imageData.data[i + 1] = 0
imageData.data[i + 2] = 255 imageData.data[i + 2] = 255
imageData.data[i + 3] = 255 imageData.data[i + 3] = 255
} }
this.offContext.putImageData(imageData, 10, 10) this.offContext.putImageData(imageData, 10, 10)
var image = this.offContext.transferToImageBitmap() let image = this.offContext.transferToImageBitmap()
this.context.transferFromImageBitmap(image) this.context.transferFromImageBitmap(image)
}) })
} }
...@@ -2686,7 +2688,7 @@ toDataURL(type?: string, quality?: number): string ...@@ -2686,7 +2688,7 @@ toDataURL(type?: string, quality?: number): string
.height('100%') .height('100%')
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
var dataURL = this.context.toDataURL() let dataURL = this.context.toDataURL()
}) })
} }
.width('100%') .width('100%')
...@@ -2810,7 +2812,7 @@ createLinearGradient(x0: number, y0: number, x1: number, y1: number): void ...@@ -2810,7 +2812,7 @@ createLinearGradient(x0: number, y0: number, x1: number, y1: number): void
.height('100%') .height('100%')
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
var grad = this.context.createLinearGradient(50,0, 300,100) let grad = this.context.createLinearGradient(50,0, 300,100)
grad.addColorStop(0.0, '#ff0000') grad.addColorStop(0.0, '#ff0000')
grad.addColorStop(0.5, '#ffffff') grad.addColorStop(0.5, '#ffffff')
grad.addColorStop(1.0, '#00ff00') grad.addColorStop(1.0, '#00ff00')
...@@ -2863,7 +2865,7 @@ createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, ...@@ -2863,7 +2865,7 @@ createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number,
.height('100%') .height('100%')
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
var grad = this.context.createRadialGradient(200,200,50, 200,200,200) let grad = this.context.createRadialGradient(200,200,50, 200,200,200)
grad.addColorStop(0.0, '#ff0000') grad.addColorStop(0.0, '#ff0000')
grad.addColorStop(0.5, '#ffffff') grad.addColorStop(0.5, '#ffffff')
grad.addColorStop(1.0, '#00ff00') grad.addColorStop(1.0, '#00ff00')
...@@ -2910,7 +2912,7 @@ struct CanvasExample { ...@@ -2910,7 +2912,7 @@ struct CanvasExample {
.height('100%') .height('100%')
.backgroundColor('#ffffff') .backgroundColor('#ffffff')
.onReady(() => { .onReady(() => {
var grad = this.context.createConicGradient(0, 50, 80) let grad = this.context.createConicGradient(0, 50, 80)
grad.addColorStop(0.0, '#ff0000') grad.addColorStop(0.0, '#ff0000')
grad.addColorStop(0.5, '#ffffff') grad.addColorStop(0.5, '#ffffff')
grad.addColorStop(1.0, '#00ff00') grad.addColorStop(1.0, '#00ff00')
......
...@@ -62,8 +62,8 @@ struct GestureGroupExample { ...@@ -62,8 +62,8 @@ struct GestureGroupExample {
// 以下组合手势为顺序识别,当长按手势事件未正常触发时则不会触发拖动手势事件 // 以下组合手势为顺序识别,当长按手势事件未正常触发时则不会触发拖动手势事件
GestureGroup(GestureMode.Sequence, GestureGroup(GestureMode.Sequence,
LongPressGesture({ repeat: true }) LongPressGesture({ repeat: true })
.onAction((event: GestureEvent) => { .onAction((event?: GestureEvent) => {
if (event.repeat) { if (event && event.repeat) {
this.count++ this.count++
} }
console.info('LongPress onAction') console.info('LongPress onAction')
...@@ -76,9 +76,11 @@ struct GestureGroupExample { ...@@ -76,9 +76,11 @@ struct GestureGroupExample {
this.borderStyles = BorderStyle.Dashed this.borderStyles = BorderStyle.Dashed
console.info('pan start') console.info('pan start')
}) })
.onActionUpdate((event: GestureEvent) => { .onActionUpdate((event?: GestureEvent) => {
this.offsetX = this.positionX + event.offsetX if (event) {
this.offsetY = this.positionY + event.offsetY this.offsetX = this.positionX + event.offsetX
this.offsetY = this.positionY + event.offsetY
}
console.info('pan update') console.info('pan update')
}) })
.onActionEnd(() => { .onActionEnd(() => {
......
...@@ -42,7 +42,7 @@ struct Page45 { ...@@ -42,7 +42,7 @@ struct Page45 {
.height('100%') .height('100%')
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() => { .onReady(() => {
var grad = this.context.createLinearGradient(50, 0, 300, 100) let grad = this.context.createLinearGradient(50, 0, 300, 100)
grad.addColorStop(0.0, '#ff0000') grad.addColorStop(0.0, '#ff0000')
grad.addColorStop(0.5, '#ffffff') grad.addColorStop(0.5, '#ffffff')
grad.addColorStop(1.0, '#00ff00') grad.addColorStop(1.0, '#00ff00')
......
...@@ -33,7 +33,7 @@ struct CanvasPatternPage { ...@@ -33,7 +33,7 @@ struct CanvasPatternPage {
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
private matrix: Matrix2D = new Matrix2D() private matrix: Matrix2D = new Matrix2D()
private img: ImageBitmap = new ImageBitmap("common/pattern.jpg") private img: ImageBitmap = new ImageBitmap("common/pattern.jpg")
private pattern : CanvasPattern private pattern : CanvasPattern | null = null
build() { build() {
Column() { Column() {
...@@ -43,7 +43,9 @@ struct CanvasPatternPage { ...@@ -43,7 +43,9 @@ struct CanvasPatternPage {
this.matrix.scaleX = 1 this.matrix.scaleX = 1
this.matrix.translateX = 50 this.matrix.translateX = 50
this.matrix.translateY = 200 this.matrix.translateY = 200
this.pattern.setTransform(this.matrix) if (this.pattern) {
this.pattern.setTransform(this.matrix)
}
this.context.fillRect(0, 0, 480, 720) this.context.fillRect(0, 0, 480, 720)
}) })
.width("45%") .width("45%")
...@@ -54,12 +56,14 @@ struct CanvasPatternPage { ...@@ -54,12 +56,14 @@ struct CanvasPatternPage {
.backgroundColor('#FFFFFF') .backgroundColor('#FFFFFF')
.onReady(() => { .onReady(() => {
this.pattern = this.context.createPattern(this.img, 'no-repeat') this.pattern = this.context.createPattern(this.img, 'no-repeat')
this.context.fillStyle = this.pattern
this.matrix.scaleY = 0.5 this.matrix.scaleY = 0.5
this.matrix.scaleX = 0.5 this.matrix.scaleX = 0.5
this.matrix.translateX = 50 this.matrix.translateX = 50
this.matrix.translateY = 50 this.matrix.translateY = 50
this.pattern.setTransform(this.matrix) if (this.pattern) {
this.context.fillStyle = this.pattern
this.pattern.setTransform(this.matrix)
}
this.context.fillRect(0, 0, 480, 720) this.context.fillRect(0, 0, 480, 720)
}) })
} }
......
...@@ -39,7 +39,7 @@ ImageData对象可以存储canvas渲染的像素数据。 ...@@ -39,7 +39,7 @@ ImageData对象可以存储canvas渲染的像素数据。
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
this.context.drawImage(this.img,0,0,130,130) this.context.drawImage(this.img,0,0,130,130)
var imagedata = this.context.getImageData(50,50,130,130) let imagedata = this.context.getImageData(50,50,130,130)
this.context.putImageData(imagedata,150,150) this.context.putImageData(imagedata,150,150)
}) })
} }
......
...@@ -36,7 +36,7 @@ Matrix2D() ...@@ -36,7 +36,7 @@ Matrix2D()
struct Matrix2DScaleX { struct Matrix2DScaleX {
@State message: string = 'Matrix2D ScaleX' @State message: string = 'Matrix2D ScaleX'
printMatrix(title, matrix) { printMatrix(title: string, matrix: Matrix2D) {
console.log(title) console.log(title)
console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY + console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY +
", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY + ", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY +
...@@ -50,7 +50,7 @@ struct Matrix2DScaleX { ...@@ -50,7 +50,7 @@ struct Matrix2DScaleX {
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
Button("Set scaleX") Button("Set scaleX")
.onClick(() => { .onClick(() => {
var matrix : Matrix2D = new Matrix2D() let matrix : Matrix2D = new Matrix2D()
matrix.scaleX = 1 matrix.scaleX = 1
this.printMatrix(this.message, matrix) this.printMatrix(this.message, matrix)
}) })
...@@ -71,7 +71,7 @@ struct Matrix2DScaleX { ...@@ -71,7 +71,7 @@ struct Matrix2DScaleX {
struct Matrix2DScaleY { struct Matrix2DScaleY {
@State message: string = 'Matrix2D ScaleY' @State message: string = 'Matrix2D ScaleY'
printMatrix(title, matrix) { printMatrix(title: string, matrix: Matrix2D) {
console.log(title) console.log(title)
console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY + console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY +
", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY + ", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY +
...@@ -85,7 +85,7 @@ struct Matrix2DScaleY { ...@@ -85,7 +85,7 @@ struct Matrix2DScaleY {
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
Button("Set scaleY") Button("Set scaleY")
.onClick(() => { .onClick(() => {
var matrix : Matrix2D = new Matrix2D() let matrix : Matrix2D = new Matrix2D()
matrix.scaleY = 1 matrix.scaleY = 1
this.printMatrix(this.message, matrix) this.printMatrix(this.message, matrix)
}) })
...@@ -106,7 +106,7 @@ struct Matrix2DScaleY { ...@@ -106,7 +106,7 @@ struct Matrix2DScaleY {
struct Matrix2DRotateX { struct Matrix2DRotateX {
@State message: string = 'Matrix2D RotateX' @State message: string = 'Matrix2D RotateX'
printMatrix(title, matrix) { printMatrix(title: string, matrix: Matrix2D) {
console.log(title) console.log(title)
console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY + console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY +
", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY + ", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY +
...@@ -120,7 +120,7 @@ struct Matrix2DRotateX { ...@@ -120,7 +120,7 @@ struct Matrix2DRotateX {
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
Button("Set rotateX") Button("Set rotateX")
.onClick(() => { .onClick(() => {
var matrix : Matrix2D = new Matrix2D() let matrix : Matrix2D = new Matrix2D()
matrix.rotateX = Math.sin(45 / Math.PI) matrix.rotateX = Math.sin(45 / Math.PI)
this.printMatrix(this.message, matrix) this.printMatrix(this.message, matrix)
}) })
...@@ -141,7 +141,7 @@ struct Matrix2DRotateX { ...@@ -141,7 +141,7 @@ struct Matrix2DRotateX {
struct Matrix2DRotateY { struct Matrix2DRotateY {
@State message: string = 'Matrix2D RotateY' @State message: string = 'Matrix2D RotateY'
printMatrix(title, matrix) { printMatrix(title: string, matrix: Matrix2D) {
console.log(title) console.log(title)
console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY + console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY +
", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY + ", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY +
...@@ -155,7 +155,7 @@ struct Matrix2DRotateY { ...@@ -155,7 +155,7 @@ struct Matrix2DRotateY {
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
Button("Set rotateY") Button("Set rotateY")
.onClick(() => { .onClick(() => {
var matrix : Matrix2D = new Matrix2D() let matrix : Matrix2D = new Matrix2D()
matrix.rotateY = Math.cos(45 / Math.PI) matrix.rotateY = Math.cos(45 / Math.PI)
this.printMatrix(this.message, matrix) this.printMatrix(this.message, matrix)
}) })
...@@ -176,7 +176,7 @@ struct Matrix2DRotateY { ...@@ -176,7 +176,7 @@ struct Matrix2DRotateY {
struct Matrix2DTranslateX { struct Matrix2DTranslateX {
@State message: string = 'Matrix2D TranslateX' @State message: string = 'Matrix2D TranslateX'
printMatrix(title, matrix) { printMatrix(title: string, matrix: Matrix2D) {
console.log(title) console.log(title)
console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY + console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY +
", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY + ", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY +
...@@ -190,7 +190,7 @@ struct Matrix2DTranslateX { ...@@ -190,7 +190,7 @@ struct Matrix2DTranslateX {
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
Button("Set translateX") Button("Set translateX")
.onClick(() => { .onClick(() => {
var matrix : Matrix2D = new Matrix2D() let matrix : Matrix2D = new Matrix2D()
matrix.translateX = 10 matrix.translateX = 10
this.printMatrix(this.message, matrix) this.printMatrix(this.message, matrix)
}) })
...@@ -211,7 +211,7 @@ struct Matrix2DTranslateX { ...@@ -211,7 +211,7 @@ struct Matrix2DTranslateX {
struct Matrix2DTranslateY { struct Matrix2DTranslateY {
@State message: string = 'Matrix2D TranslateY' @State message: string = 'Matrix2D TranslateY'
printMatrix(title, matrix) { printMatrix(title: string, matrix: Matrix2D) {
console.log(title) console.log(title)
console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY + console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY +
", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY + ", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY +
...@@ -225,7 +225,7 @@ struct Matrix2DTranslateY { ...@@ -225,7 +225,7 @@ struct Matrix2DTranslateY {
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
Button("Set translateY") Button("Set translateY")
.onClick(() => { .onClick(() => {
var matrix : Matrix2D = new Matrix2D() let matrix : Matrix2D = new Matrix2D()
matrix.translateY = 10 matrix.translateY = 10
this.printMatrix(this.message, matrix) this.printMatrix(this.message, matrix)
}) })
...@@ -262,7 +262,7 @@ identity(): Matrix2D ...@@ -262,7 +262,7 @@ identity(): Matrix2D
struct Matrix2DIdentity { struct Matrix2DIdentity {
@State message: string = 'Matrix2D Identity' @State message: string = 'Matrix2D Identity'
printMatrix(title, matrix) { printMatrix(title: string, matrix: Matrix2D) {
console.log(title) console.log(title)
console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY + console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY +
", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY + ", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY +
...@@ -276,7 +276,7 @@ struct Matrix2DIdentity { ...@@ -276,7 +276,7 @@ struct Matrix2DIdentity {
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
Button("matrix identity") Button("matrix identity")
.onClick(() => { .onClick(() => {
var matrix : Matrix2D = new Matrix2D() let matrix : Matrix2D = new Matrix2D()
matrix = matrix.identity() matrix = matrix.identity()
this.printMatrix(this.message, matrix) this.printMatrix(this.message, matrix)
}) })
...@@ -311,7 +311,7 @@ invert(): Matrix2D ...@@ -311,7 +311,7 @@ invert(): Matrix2D
struct Matrix2DInvert { struct Matrix2DInvert {
@State message: string = 'Matrix2D Invert' @State message: string = 'Matrix2D Invert'
printMatrix(title, matrix) { printMatrix(title: string, matrix: Matrix2D) {
console.log(title) console.log(title)
console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY + console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY +
", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY + ", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY +
...@@ -325,7 +325,7 @@ struct Matrix2DInvert { ...@@ -325,7 +325,7 @@ struct Matrix2DInvert {
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
Button("matrix invert") Button("matrix invert")
.onClick(() => { .onClick(() => {
var matrix : Matrix2D = new Matrix2D() let matrix : Matrix2D = new Matrix2D()
matrix.scaleX = 2 matrix.scaleX = 2
matrix.scaleY = 1 matrix.scaleY = 1
matrix.rotateX = 0 matrix.rotateX = 0
...@@ -374,7 +374,7 @@ multiply(other?: Matrix2D): Matrix2D ...@@ -374,7 +374,7 @@ multiply(other?: Matrix2D): Matrix2D
struct Matrix2DMultiply { struct Matrix2DMultiply {
@State message: string = 'Matrix2D Multiply' @State message: string = 'Matrix2D Multiply'
printMatrix(title, matrix) { printMatrix(title: string, matrix: Matrix2D) {
console.log(title) console.log(title)
console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY + console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY +
", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY + ", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY +
...@@ -388,14 +388,14 @@ struct Matrix2DMultiply { ...@@ -388,14 +388,14 @@ struct Matrix2DMultiply {
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
Button("matrix multiply") Button("matrix multiply")
.onClick(() => { .onClick(() => {
var matrix : Matrix2D = new Matrix2D() let matrix : Matrix2D = new Matrix2D()
matrix.scaleX = 1 matrix.scaleX = 1
matrix.scaleY = 1 matrix.scaleY = 1
matrix.rotateX = 0 matrix.rotateX = 0
matrix.rotateY = 0 matrix.rotateY = 0
matrix.translateX = 0 matrix.translateX = 0
matrix.translateY = 0 matrix.translateY = 0
var other: Matrix2D = new Matrix2D() let other: Matrix2D = new Matrix2D()
other.scaleX = 2 other.scaleX = 2
other.scaleY = 2 other.scaleY = 2
other.rotateX = 0 other.rotateX = 0
...@@ -445,7 +445,7 @@ rotate(rx?: number, ry?: number): Matrix2D ...@@ -445,7 +445,7 @@ rotate(rx?: number, ry?: number): Matrix2D
struct Matrix2DRotate { struct Matrix2DRotate {
@State message: string = 'Matrix2D Rotate' @State message: string = 'Matrix2D Rotate'
printMatrix(title, matrix) { printMatrix(title: string, matrix: Matrix2D) {
console.log(title) console.log(title)
console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY + console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY +
", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY + ", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY +
...@@ -459,7 +459,7 @@ struct Matrix2DRotate { ...@@ -459,7 +459,7 @@ struct Matrix2DRotate {
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
Button("matrix rotate") Button("matrix rotate")
.onClick(() => { .onClick(() => {
var matrix : Matrix2D = new Matrix2D() let matrix : Matrix2D = new Matrix2D()
matrix.scaleX = 1 matrix.scaleX = 1
matrix.scaleY = 1 matrix.scaleY = 1
matrix.rotateX = 0 matrix.rotateX = 0
...@@ -508,7 +508,7 @@ rotate(degree: number, rx?: number, ry?: number): Matrix2D ...@@ -508,7 +508,7 @@ rotate(degree: number, rx?: number, ry?: number): Matrix2D
struct Matrix2DRotate { struct Matrix2DRotate {
@State message: string = 'Matrix2D Rotate' @State message: string = 'Matrix2D Rotate'
printMatrix(title, matrix) { printMatrix(title: string, matrix: Matrix2D) {
console.log(title) console.log(title)
console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY + console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY +
", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY + ", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY +
...@@ -522,7 +522,7 @@ struct Matrix2DRotate { ...@@ -522,7 +522,7 @@ struct Matrix2DRotate {
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
Button("matrix rotate") Button("matrix rotate")
.onClick(() => { .onClick(() => {
var matrix : Matrix2D = new Matrix2D() let matrix : Matrix2D = new Matrix2D()
matrix.scaleX = 1 matrix.scaleX = 1
matrix.scaleY = 1 matrix.scaleY = 1
matrix.rotateX = 0 matrix.rotateX = 0
...@@ -570,7 +570,7 @@ translate(tx?: number, ty?: number): Matrix2D ...@@ -570,7 +570,7 @@ translate(tx?: number, ty?: number): Matrix2D
struct Matrix2DTranslate { struct Matrix2DTranslate {
@State message: string = 'Matrix2D Translate' @State message: string = 'Matrix2D Translate'
printMatrix(title, matrix) { printMatrix(title: string, matrix: Matrix2D) {
console.log(title) console.log(title)
console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY + console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY +
", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY + ", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY +
...@@ -584,7 +584,7 @@ struct Matrix2DTranslate { ...@@ -584,7 +584,7 @@ struct Matrix2DTranslate {
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
Button("matrix translate") Button("matrix translate")
.onClick(() => { .onClick(() => {
var matrix : Matrix2D = new Matrix2D() let matrix : Matrix2D = new Matrix2D()
matrix.scaleX = 1 matrix.scaleX = 1
matrix.scaleY = 1 matrix.scaleY = 1
matrix.rotateX = 0 matrix.rotateX = 0
...@@ -632,7 +632,7 @@ scale(sx?: number, sy?: number): Matrix2D ...@@ -632,7 +632,7 @@ scale(sx?: number, sy?: number): Matrix2D
struct Matrix2DScale { struct Matrix2DScale {
@State message: string = 'Matrix2D Scale' @State message: string = 'Matrix2D Scale'
printMatrix(title, matrix) { printMatrix(title: string, matrix: Matrix2D) {
console.log(title) console.log(title)
console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY + console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY +
", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY + ", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY +
...@@ -646,7 +646,7 @@ struct Matrix2DScale { ...@@ -646,7 +646,7 @@ struct Matrix2DScale {
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
Button("matrix scale") Button("matrix scale")
.onClick(() => { .onClick(() => {
var matrix : Matrix2D = new Matrix2D() let matrix : Matrix2D = new Matrix2D()
matrix.scaleX = 1 matrix.scaleX = 1
matrix.scaleY = 1 matrix.scaleY = 1
matrix.rotateX = 0 matrix.rotateX = 0
......
...@@ -55,10 +55,10 @@ struct OffscreenCanvasPage { ...@@ -55,10 +55,10 @@ struct OffscreenCanvasPage {
.borderColor('#00FF00') .borderColor('#00FF00')
.backgroundColor('#FFFFFF') .backgroundColor('#FFFFFF')
.onReady(() => { .onReady(() => {
var offContext = this.offCanvas.getContext("2d", this.settings) let offContext = this.offCanvas.getContext("2d", this.settings)
offContext.fillStyle = '#CDCDCD' offContext.fillStyle = '#CDCDCD'
offContext.fillRect(0, 0, this.offCanvas.width, 150) offContext.fillRect(0, 0, this.offCanvas.width, 150)
var image = this.offCanvas.transferToImageBitmap() let image = this.offCanvas.transferToImageBitmap()
this.context.setTransform(1, 0, 0, 1, 50, 200) this.context.setTransform(1, 0, 0, 1, 50, 200)
this.context.transferFromImageBitmap(image) this.context.transferFromImageBitmap(image)
}) })
...@@ -91,10 +91,10 @@ struct OffscreenCanvasPage { ...@@ -91,10 +91,10 @@ struct OffscreenCanvasPage {
.borderColor('#00FF00') .borderColor('#00FF00')
.backgroundColor('#FFFFFF') .backgroundColor('#FFFFFF')
.onReady(() => { .onReady(() => {
var offContext = this.offCanvas.getContext("2d", this.settings) let offContext = this.offCanvas.getContext("2d", this.settings)
offContext.fillStyle = '#CDCDCD' offContext.fillStyle = '#CDCDCD'
offContext.fillRect(0, 0, 100, this.offCanvas.height) offContext.fillRect(0, 0, 100, this.offCanvas.height)
var image = this.offCanvas.transferToImageBitmap() let image = this.offCanvas.transferToImageBitmap()
this.context.setTransform(1, 0, 0, 1, 50, 200) this.context.setTransform(1, 0, 0, 1, 50, 200)
this.context.transferFromImageBitmap(image) this.context.transferFromImageBitmap(image)
}) })
...@@ -142,13 +142,13 @@ struct OffscreenCanvasPage { ...@@ -142,13 +142,13 @@ struct OffscreenCanvasPage {
.borderColor('#00FF00') .borderColor('#00FF00')
.backgroundColor('#FFFFFF') .backgroundColor('#FFFFFF')
.onReady(() => { .onReady(() => {
var offContext = this.offCanvas.getContext("2d", this.settings) let offContext = this.offCanvas.getContext("2d", this.settings)
offContext.fillStyle = '#CDCDCD' offContext.fillStyle = '#CDCDCD'
offContext.fillRect(0, 0, 300, 500) offContext.fillRect(0, 0, 300, 500)
offContext.fillStyle = '#000000' offContext.fillStyle = '#000000'
offContext.font = '70px serif bold' offContext.font = '70px serif bold'
offContext.fillText("Offscreen : Hello World!", 20, 60) offContext.fillText("Offscreen : Hello World!", 20, 60)
var image = this.offCanvas.transferToImageBitmap() let image = this.offCanvas.transferToImageBitmap()
this.context.transferFromImageBitmap(image) this.context.transferFromImageBitmap(image)
}) })
} }
...@@ -197,7 +197,7 @@ struct OffscreenCanvasExamplePage { ...@@ -197,7 +197,7 @@ struct OffscreenCanvasExamplePage {
.height('100%') .height('100%')
.backgroundColor('#FFFFFF') .backgroundColor('#FFFFFF')
.onReady(() => { .onReady(() => {
var offContext = this.offscreenCanvas.getContext("2d", this.settings) let offContext = this.offscreenCanvas.getContext("2d", this.settings)
offContext.font = '70px sans-serif' offContext.font = '70px sans-serif'
offContext.fillText("Offscreen : Hello World!", 20, 60) offContext.fillText("Offscreen : Hello World!", 20, 60)
offContext.fillStyle = "#0000ff" offContext.fillStyle = "#0000ff"
...@@ -217,7 +217,7 @@ struct OffscreenCanvasExamplePage { ...@@ -217,7 +217,7 @@ struct OffscreenCanvasExamplePage {
offContext.stroke() offContext.stroke()
offContext.fillStyle = '#FF00FF' offContext.fillStyle = '#FF00FF'
offContext.fillRect(100, 100, 60, 60) offContext.fillRect(100, 100, 60, 60)
var imageData = this.offscreenCanvas.transferToImageBitmap() let imageData = this.offscreenCanvas.transferToImageBitmap()
this.context.transferFromImageBitmap(imageData) this.context.transferFromImageBitmap(imageData)
}) })
}.width('100%').height('100%') }.width('100%').height('100%')
......
...@@ -86,7 +86,7 @@ struct AlphabetIndexerSample { ...@@ -86,7 +86,7 @@ struct AlphabetIndexerSample {
Stack({ alignContent: Alignment.Start }) { Stack({ alignContent: Alignment.Start }) {
Row() { Row() {
List({ space: 20, initialIndex: 0 }) { List({ space: 20, initialIndex: 0 }) {
ForEach(this.arrayA, (item) => { ForEach(this.arrayA, (item: string) => {
ListItem() { ListItem() {
Text(item) Text(item)
.width('80%') .width('80%')
...@@ -94,9 +94,9 @@ struct AlphabetIndexerSample { ...@@ -94,9 +94,9 @@ struct AlphabetIndexerSample {
.fontSize(30) .fontSize(30)
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
}.editable(true) }.editable(true)
}, item => item) }, (item: string) => item)
ForEach(this.arrayB, (item) => { ForEach(this.arrayB, (item: string) => {
ListItem() { ListItem() {
Text(item) Text(item)
.width('80%') .width('80%')
...@@ -104,9 +104,9 @@ struct AlphabetIndexerSample { ...@@ -104,9 +104,9 @@ struct AlphabetIndexerSample {
.fontSize(30) .fontSize(30)
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
}.editable(true) }.editable(true)
}, item => item) }, (item: string) => item)
ForEach(this.arrayC, (item) => { ForEach(this.arrayC, (item: string) => {
ListItem() { ListItem() {
Text(item) Text(item)
.width('80%') .width('80%')
...@@ -114,9 +114,9 @@ struct AlphabetIndexerSample { ...@@ -114,9 +114,9 @@ struct AlphabetIndexerSample {
.fontSize(30) .fontSize(30)
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
}.editable(true) }.editable(true)
}, item => item) }, (item: string) => item)
ForEach(this.arrayL, (item) => { ForEach(this.arrayL, (item: string) => {
ListItem() { ListItem() {
Text(item) Text(item)
.width('80%') .width('80%')
...@@ -124,7 +124,7 @@ struct AlphabetIndexerSample { ...@@ -124,7 +124,7 @@ struct AlphabetIndexerSample {
.fontSize(30) .fontSize(30)
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
}.editable(true) }.editable(true)
}, item => item) }, (item: string) => item)
} }
.width('50%') .width('50%')
.height('100%') .height('100%')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册