Browse Source

Canvas2D small API added to access global position of prim (#1200)

* Change text drawing starting location to the right place in case of multi-line

* Fix textSize null case

* Canvas2D: enhance text rendering quality

* Canvas2D: small api to access global position of prim
Loïc Baumann 9 years ago
parent
commit
34f8e78d57
1 changed files with 18 additions and 0 deletions
  1. 18 0
      src/Canvas2d/babylon.prim2dBase.ts

+ 18 - 0
src/Canvas2d/babylon.prim2dBase.ts

@@ -1873,6 +1873,24 @@
         }
 
         /**
+         * return the global position of the primitive, relative to its canvas
+         */
+        public getGlobalPosition(): Vector2 {
+            let v = new Vector2(0, 0);
+            this.getGlobalPositionByRef(v);
+            return v;
+        }
+
+        /**
+         * return the global position of the primitive, relative to its canvas
+         * @param v the valid Vector2 object where the global position will be stored
+         */
+        public getGlobalPositionByRef(v: Vector2) {
+            v.x = this.globalTransform.m[12];
+            v.y = this.globalTransform.m[13];
+        }
+
+        /**
          * Get invert of the global transformation matrix of the primitive
          */
         public get invGlobalTransform(): Matrix {