Add min/max x/y accessors, and offset to cursors.
catseye
12 years ago
231 | 231 | /* |
232 | 232 | * Draws the Playfield in a drawing context. |
233 | 233 | * cellWidth and cellHeight are canvas units of measure for each cell. |
234 | * offsetX and offsetY are canvas units of measure for the playfield. | |
234 | 235 | */ |
235 | 236 | this.drawContext = function(ctx, offsetX, offsetY, cellWidth, cellHeight) { |
236 | 237 | var me = this; |
240 | 241 | }); |
241 | 242 | }; |
242 | 243 | |
244 | this.getMinX = function() { return this.minX; } | |
245 | this.getMaxX = function() { return this.maxX; } | |
246 | this.getMinY = function() { return this.minY; } | |
247 | this.getMaxY = function() { return this.maxY; } | |
248 | ||
243 | 249 | this.getExtentX = function() { |
244 | 250 | if (this.maxX === undefined || this.minX === undefined) { |
245 | 251 | return 0; |
287 | 293 | for (var i = 0; i < cursors.length; i++) { |
288 | 294 | cursors[i].drawContext( |
289 | 295 | ctx, |
290 | cursors[i].x * cellWidth, cursors[i].y * cellHeight, | |
296 | offsetX + cursors[i].x * cellWidth, | |
297 | offsetY + cursors[i].y * cellHeight, | |
291 | 298 | cellWidth, cellHeight |
292 | 299 | ); |
293 | 300 | } |