Переглянути джерело

Merge pull request #1852 from aWeirdo/patch-9

Allows y === null in drawText.
David Catuhe 8 роки тому
батько
коміт
d0c6914c24
1 змінених файлів з 7 додано та 3 видалено
  1. 7 3
      src/Materials/Textures/babylon.dynamicTexture.ts

+ 7 - 3
src/Materials/Textures/babylon.dynamicTexture.ts

@@ -75,11 +75,15 @@ module BABYLON {
             }
 
             this._context.font = font;
-            if (x === null) {
+            if (x === null  || x === undefined) {
                 var textSize = this._context.measureText(text);
                 x = (size.width - textSize.width) / 2;
             }
-
+            if (y === null || y === undefined) {
+                var fontSize = parseInt((font.replace(/\D/g,'')));;
+                y = (size.height /2) + (fontSize/3.65);
+            }
+            
             this._context.fillStyle = color;
             this._context.fillText(text, x, y);
 
@@ -103,4 +107,4 @@ module BABYLON {
             return newTexture;
         }
     }
-} 
+}