Commits

Cat's Eye Technologies committed 942e7ca

Extents of PlayfieldCanvasView now include all cursors.

Comments (0)

Files changed (1)

src/yoob/playfield-canvas-view.js

 /*
- * This file is part of yoob.js version 0.5
+ * This file is part of yoob.js version 0.6-PRE
  * Available from https://github.com/catseye/yoob.js/
  * This file is in the public domain.  See http://unlicense.org/ for details.
  */
     };
 
     /*
+     * Return the requested bounds of the occupied portion of the playfield.
+     * "Occupation" in this sense includes all cursors.
+     *
      * Override these if you want to draw some portion of the
      * playfield which is not the whole playfield.
      * (Not yet implemented)
      */
     this.getLowerX = function() {
-        return this.pf.getMinX();
+        var minX = this.pf.getMinX();
+        for (var i = 0; i < this.cursors.length; i++) {
+            if (this.cursors[i].x < minX) minX = this.cursors[i].x;
+        }
+        return minX;
     };
     this.getUpperX = function() {
-        return this.pf.getMaxX();
+        var maxX = this.pf.getMaxX();
+        for (var i = 0; i < this.cursors.length; i++) {
+            if (this.cursors[i].x > maxX) maxX = this.cursors[i].x;
+        }
+        return maxX;
     };
     this.getLowerY = function() {
-        return this.pf.getMinY();
+        var minY = this.pf.getMinY();
+        for (var i = 0; i < this.cursors.length; i++) {
+            if (this.cursors[i].y < minY) minY = this.cursors[i].y;
+        }
+        return minY;
     };
     this.getUpperY = function() {
-        return this.pf.getMaxY();
+        var maxY = this.pf.getMaxY();
+        for (var i = 0; i < this.cursors.length; i++) {
+            if (this.cursors[i].y > maxY) maxY = this.cursors[i].y;
+        }
+        return maxY;
     };
 
     /*
      * Returns the number of occupied cells in the x direction.
+     * "Occupation" in this sense includes all cursors.
      */
     this.getExtentX = function() {
         if (this.getLowerX() === undefined || this.getUpperX() === undefined) {
 
     /*
      * Returns the number of occupied cells in the y direction.
+     * "Occupation" in this sense includes all cursors.
      */
     this.getExtentY = function() {
         if (this.getLowerY() === undefined || this.getUpperY() === undefined) {