瀏覽代碼

inlcuding image file

DESKTOP-QJU4N0L\mityh 7 年之前
父節點
當前提交
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);