save canvas width/height in localStorage

main
Isaiah Odhner 2014-05-17 19:02:04 -07:00
parent f4d423bf6e
commit 3e71dfd7dd
2 changed files with 18 additions and 4 deletions

18
app.js
View File

@ -2,8 +2,17 @@
var aliasing = true;
var transparency = false;
var default_width = 683;
var default_height = 384;
var default_canvas_width = 683;
var default_canvas_height = 384;
var my_canvas_width = default_canvas_width;
var my_canvas_height = default_canvas_height;
try{
if(localStorage){
my_canvas_width = Number(localStorage.width);
my_canvas_height = Number(localStorage.height);
}
}catch(e){}
var palette = [
"#000000","#787878","#790300","#757A01","#007902","#007778","#0A0078","#7B0077","#767A38","#003637","#286FFE","#083178","#4C00FE","#783B00",
@ -84,6 +93,11 @@ $canvas.on("user-resized", function(e, width, height){
if(previous_canvas){
ctx.drawImage(previous_canvas, 0, 0);
}
try{
localStorage.width = width;
localStorage.height = height;
}catch(e){}
}
});

View File

@ -12,8 +12,8 @@ function reset(){
file_name = "untitled";
update_title();
canvas.width = default_width;
canvas.height = default_height;
canvas.width = my_canvas_width;
canvas.height = my_canvas_height;
ctx.fillStyle = colors[1];
ctx.fillRect(0, 0, canvas.width, canvas.height);