Fix canvas size for reruns. Again.
This commit is contained in:
@ -3,13 +3,14 @@ var editor;
|
|||||||
var pipeurl;
|
var pipeurl;
|
||||||
var filename;
|
var filename;
|
||||||
var pendingChanges = -1;
|
var pendingChanges = -1;
|
||||||
|
var height;
|
||||||
|
var width;
|
||||||
var devicePixelRatio = window.devicePixelRatio || 1;
|
var devicePixelRatio = window.devicePixelRatio || 1;
|
||||||
|
|
||||||
function Turtle(pipe, canvas) {
|
function Turtle(pipe, canvas) {
|
||||||
var dx, dy, xpos, ypos;
|
var dx, dy, xpos, ypos;
|
||||||
this.canvas = canvas; // jQuery object
|
this.canvas = canvas; // jQuery object
|
||||||
this.height;
|
|
||||||
this.width;
|
|
||||||
this.items = [];
|
this.items = [];
|
||||||
this.canvas.off('click');
|
this.canvas.off('click');
|
||||||
|
|
||||||
@ -76,7 +77,7 @@ Turtle.prototype.update = function () {
|
|||||||
canvas.style.width = `${this.get_width()}px`;
|
canvas.style.width = `${this.get_width()}px`;
|
||||||
canvas.style.height = `${this.get_height()}px`;
|
canvas.style.height = `${this.get_height()}px`;
|
||||||
ctx = canvas.getContext('2d');
|
ctx = canvas.getContext('2d');
|
||||||
ctx.clearRect(0, 0, this.width, this.width);
|
ctx.clearRect(0, 0, this.get_width(), this.get_height());
|
||||||
ctx.scale(devicePixelRatio, devicePixelRatio);
|
ctx.scale(devicePixelRatio, devicePixelRatio);
|
||||||
length = this.items.length;
|
length = this.items.length;
|
||||||
dx = canvas.width / (2 * devicePixelRatio);
|
dx = canvas.width / (2 * devicePixelRatio);
|
||||||
@ -118,17 +119,17 @@ Turtle.prototype.update = function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Turtle.prototype.get_width = function () {
|
Turtle.prototype.get_width = function () {
|
||||||
if (this.width === undefined) {
|
if (width === undefined) {
|
||||||
this.width = this.canvas[0].width;
|
width = this.canvas[0].width;
|
||||||
}
|
}
|
||||||
return this.width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
Turtle.prototype.get_height = function () {
|
Turtle.prototype.get_height = function () {
|
||||||
if (this.height === undefined) {
|
if (height === undefined) {
|
||||||
this.height = this.canvas[0].height;
|
height = this.canvas[0].height;
|
||||||
}
|
}
|
||||||
return this.height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
Turtle.prototype.delete = function (item) {
|
Turtle.prototype.delete = function (item) {
|
||||||
|
Reference in New Issue
Block a user