Fixed off the edge of the screen bug
This commit is contained in:
parent
45052b42f8
commit
671d527a59
|
@ -58,7 +58,7 @@ function ea(a, b) {
|
|||
this.canvas = document.getElementById("ascii-canvas");
|
||||
this.context = this.canvas.getContext("2d");
|
||||
this.zoom = 1;
|
||||
this.offset = new l(7500, 7500);
|
||||
this.offset = new l(9E3, 5100);
|
||||
this.d = !0;
|
||||
this.s = !1;
|
||||
A(this);
|
||||
|
@ -84,6 +84,10 @@ function fa(a) {
|
|||
b.scale(a.zoom, a.zoom);
|
||||
b.translate(a.canvas.width / 2 / a.zoom, a.canvas.height / 2 / a.zoom);
|
||||
var c = n(B(a, new l(0, 0)), new l(3, 3)), d = B(a, new l(a.canvas.width, a.canvas.height)).add(new l(3, 3));
|
||||
c.x = Math.max(0, Math.min(c.x, 2E3));
|
||||
d.x = Math.max(0, Math.min(d.x, 2E3));
|
||||
c.y = Math.max(0, Math.min(c.y, 600));
|
||||
d.y = Math.max(0, Math.min(d.y, 600));
|
||||
b.lineWidth = "1";
|
||||
b.strokeStyle = "#EEEEEE";
|
||||
b.beginPath();
|
||||
|
|
|
@ -11,7 +11,10 @@ ascii.View = function(state) {
|
|||
/** @type {Object} */ this.context = this.canvas.getContext('2d');
|
||||
|
||||
/** @type {number} */ this.zoom = 1;
|
||||
/** @type {ascii.Vector} */ this.offset = new ascii.Vector(7500, 7500);
|
||||
/** @type {ascii.Vector} */ this.offset = new ascii.Vector(
|
||||
MAX_GRID_WIDTH * CHAR_PIXELS_H / 2,
|
||||
MAX_GRID_HEIGHT * CHAR_PIXELS_V / 2);
|
||||
|
||||
/** @type {boolean} */ this.dirty = true;
|
||||
// TODO: Should probably save this setting in a cookie or something.
|
||||
/** @type {boolean} */ this.useLines = false;
|
||||
|
@ -70,6 +73,11 @@ ascii.View.prototype.render = function() {
|
|||
.add(new ascii.Vector(
|
||||
RENDER_PADDING_CELLS, RENDER_PADDING_CELLS));
|
||||
|
||||
startOffset.x = Math.max(0, Math.min(startOffset.x, MAX_GRID_WIDTH));
|
||||
endOffset.x = Math.max(0, Math.min(endOffset.x, MAX_GRID_WIDTH));
|
||||
startOffset.y = Math.max(0, Math.min(startOffset.y, MAX_GRID_HEIGHT));
|
||||
endOffset.y = Math.max(0, Math.min(endOffset.y, MAX_GRID_HEIGHT));
|
||||
|
||||
// Render the grid.
|
||||
context.lineWidth = '1';
|
||||
context.strokeStyle = '#EEEEEE';
|
||||
|
|
Loading…
Reference in New Issue