|
1 | 1 | /* eslint-disable no-redeclare */ |
2 | | -import { Color, Font, ImageSource, View } from '@nativescript/core'; |
| 2 | +import { Color, Font, ImageSource, Screen, View } from '@nativescript/core'; |
3 | 3 | import { FontStyleType, FontWeightType } from '@nativescript/core/ui/styling/font'; |
4 | 4 | import { |
5 | 5 | Canvas as ICanvas, |
@@ -1450,9 +1450,17 @@ export class Canvas implements ICanvas { |
1450 | 1450 | console.error('Method not implemented:', 'skew'); |
1451 | 1451 | } |
1452 | 1452 |
|
1453 | | - // setMatrix(matrix: Matrix) { |
1454 | | - // CGContextConcatCTM(this.ctx, matrix.mTransform); |
1455 | | - // } |
| 1453 | + setMatrix(matrix: Matrix): void { |
| 1454 | + // TODO: Find a better way to implement matrix set |
| 1455 | + const density = Screen.mainScreen.scale; |
| 1456 | + const currentMatrix = this.getMatrix(); |
| 1457 | + const invertedTransform = CGAffineTransformInvert(currentMatrix.mTransform); |
| 1458 | + const scaleTransform = CGAffineTransformMake(density, 0, 0, -density, 0, density * this.getHeight()); |
| 1459 | + |
| 1460 | + CGContextConcatCTM(this.ctx, invertedTransform); |
| 1461 | + CGContextConcatCTM(this.ctx, scaleTransform); |
| 1462 | + CGContextConcatCTM(this.ctx, matrix.mTransform); |
| 1463 | + } |
1456 | 1464 | getMatrix(): Matrix { |
1457 | 1465 | return new Matrix(CGContextGetCTM(this.ctx)); |
1458 | 1466 | } |
|
0 commit comments