DESKTOP-QJU4N0L\mityh 8 лет назад
Родитель
Сommit
22757b3cd5
1 измененных файлов с 16 добавлено и 0 удалено
  1. 16 0
      gui/src/controls/image.ts

+ 16 - 0
gui/src/controls/image.ts

@@ -199,6 +199,22 @@ module BABYLON.GUI {
             context.save();
 
             let x, y, width, height;
+            if (this.cellId == -1) {
+                x = this._sourceLeft;
+                y = this._sourceTop;
+
+                width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
+                height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
+            }
+            else {
+                let rowCount = this._domImage.naturalWidth / this.cellWidth;
+                let column = (this.cellId / rowCount) >> 0;
+                let row = this.cellId % rowCount;
+
+                x = this.cellWidth * row;
+                y = this.cellHeight * column;
+                width = this.cellWidth;
+                height = this.cellHeight;
             }
 
             this._applyStates(context);