@@ -55,6 +55,11 @@ String matrix4ToCssTransform(Matrix4 matrix) {
5555 return float64ListToCssTransform (matrix.storage);
5656}
5757
58+ /// Converts [matrix] to CSS top/left values.
59+ Position2D matrix4ToCssTransformForSemantics (Matrix4 matrix) {
60+ return float64ListToCss2dPositionSemantics (matrix.storage);
61+ }
62+
5863/// Applies a transform to the [element] .
5964///
6065/// See [float64ListToCssTransform] for details on how the CSS value is chosen.
@@ -86,6 +91,19 @@ String float64ListToCssTransform(Float32List matrix) {
8691 }
8792}
8893
94+ /// Converts [matrix] to coordinates on 2 dimensional space.
95+ ///
96+ /// Only used by semantics node styling calculations, since semantics
97+ /// node does not receive 3D transforms, only tx and ty values of the matrix
98+ /// is used.
99+ Position2D float64ListToCss2dPositionSemantics (Float32List matrix) {
100+ assert (transformKindOf (matrix) != TransformKind .transform2d);
101+ assert (matrix.length == 16 );
102+ final Float32List m = matrix;
103+ print ('top left: ${matrix [13 ]} ${matrix [12 ]} semantics' );
104+ return Position2D ('${matrix [13 ]}px' , '${matrix [12 ]}px' );
105+ }
106+
89107/// The kind of effect a transform matrix performs.
90108enum TransformKind {
91109 /// No effect.
@@ -573,3 +591,15 @@ int clampInt(int value, int min, int max) {
573591 return value;
574592 }
575593}
594+
595+ /// Position of a node in 2 dimensional space.
596+ class Position2D {
597+ /// The position on y-axis.
598+ final String top;
599+
600+ /// The position on x-axis.
601+ final String left;
602+
603+ /// Position2D default constructor.
604+ Position2D (this .top, this .left);
605+ }
0 commit comments