git @ Cat's Eye Technologies Etcha / 4930f96
Fix some bugs in PlayfieldCanvasView. Cat's Eye Technologies 11 years ago
1 changed file(s) with 16 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
3939 * Return the requested bounds of the occupied portion of the playfield.
4040 * "Occupation" in this sense includes all cursors.
4141 *
42 * These may return 'undefined' if there is nothing in the playfield.
43 *
4244 * Override these if you want to draw some portion of the
4345 * playfield which is not the whole playfield.
4446 * (Not yet implemented)
4648 this.getLowerX = function() {
4749 var minX = this.pf.getMinX();
4850 for (var i = 0; i < this.cursors.length; i++) {
49 if (this.cursors[i].x < minX) minX = this.cursors[i].x;
51 if (minX === undefined || this.cursors[i].x < minX) {
52 minX = this.cursors[i].x;
53 }
5054 }
5155 return minX;
5256 };
5357 this.getUpperX = function() {
5458 var maxX = this.pf.getMaxX();
5559 for (var i = 0; i < this.cursors.length; i++) {
56 if (this.cursors[i].x > maxX) maxX = this.cursors[i].x;
60 if (maxX === undefined || this.cursors[i].x > maxX) {
61 maxX = this.cursors[i].x;
62 }
5763 }
5864 return maxX;
5965 };
6066 this.getLowerY = function() {
6167 var minY = this.pf.getMinY();
6268 for (var i = 0; i < this.cursors.length; i++) {
63 if (this.cursors[i].y < minY) minY = this.cursors[i].y;
69 if (minY === undefined || this.cursors[i].y < minY) {
70 minY = this.cursors[i].y;
71 }
6472 }
6573 return minY;
6674 };
6775 this.getUpperY = function() {
6876 var maxY = this.pf.getMaxY();
6977 for (var i = 0; i < this.cursors.length; i++) {
70 if (this.cursors[i].y > maxY) maxY = this.cursors[i].y;
78 if (maxY === undefined || this.cursors[i].y > maxY) {
79 maxY = this.cursors[i].y;
80 }
7181 }
7282 return maxY;
7383 };
158168 ctx.textBaseline = "top";
159169 ctx.font = cellHeight + "px monospace";
160170
161 var offsetX = this.pf.getMinX() * cellWidth * -1;
162 var offsetY = this.pf.getMinY() * cellHeight * -1;
171 var offsetX = (this.getLowerX() || 0) * cellWidth * -1;
172 var offsetY = (this.getLowerY() || 0) * cellHeight * -1;
163173
164174 if (this.fixedPosition) {
165175 offsetX = 0;