|
|
|
|
|
|
|
|
this.__brushColor = 0; |
|
|
this.__brushColor = 0; |
|
|
this.__brushPalette = 0; |
|
|
this.__brushPalette = 0; |
|
|
|
|
|
|
|
|
this.__gridEnabled = true; //false; |
|
|
|
|
|
|
|
|
this.__gridEnabled = false; |
|
|
this.__gridSize = 1; |
|
|
this.__gridSize = 1; |
|
|
|
|
|
|
|
|
this.__surface = null; |
|
|
this.__surface = null; |
|
|
|
|
|
this.__palette = null; |
|
|
|
|
|
|
|
|
// var self = this; |
|
|
// var self = this; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}).bind(this); |
|
|
}).bind(this); |
|
|
GlobalEvents.listen("resize", handle_resize); |
|
|
GlobalEvents.listen("resize", handle_resize); |
|
|
|
|
|
|
|
|
|
|
|
var handle_setapppalette = (function(pal){ |
|
|
|
|
|
this.__palette = pal; |
|
|
|
|
|
if (this.__surface !== null){ |
|
|
|
|
|
this.__surface.palette = pal; |
|
|
|
|
|
if (this.__onePaletteMode === false) |
|
|
|
|
|
RenderD(); |
|
|
|
|
|
} |
|
|
|
|
|
}).bind(this); |
|
|
|
|
|
GlobalEvents.listen("set_app_palette", handle_setapppalette); |
|
|
|
|
|
|
|
|
var handle_change_surface = (function(surf){ |
|
|
var handle_change_surface = (function(surf){ |
|
|
if (!(surf instanceof ISurface)){ |
|
|
if (!(surf instanceof ISurface)){ |
|
|
console.log("WARNING: Attempted to set painter to non-surface instance."); |
|
|
console.log("WARNING: Attempted to set painter to non-surface instance."); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
this.__surface = surf; |
|
|
this.__surface = surf; |
|
|
|
|
|
if (this.__palette === null && this.__surface.palette !== null){ |
|
|
|
|
|
this.__palette = this.__surface.palette; |
|
|
|
|
|
} else if (this.__palette !== null && this.__surface.palette !== this.__palette){ |
|
|
|
|
|
this.__surface.palette = this.__palette; |
|
|
|
|
|
} |
|
|
this.center_surface(); |
|
|
this.center_surface(); |
|
|
RenderD(); |
|
|
RenderD(); |
|
|
}).bind(this); |
|
|
}).bind(this); |
|
|
|
|
|
|
|
|
RenderD(); |
|
|
RenderD(); |
|
|
}).bind(this); |
|
|
}).bind(this); |
|
|
input.listen("wheel", handle_scale); |
|
|
input.listen("wheel", handle_scale); |
|
|
|
|
|
|
|
|
|
|
|
var handle_togglegrid = (function(target, args){ |
|
|
|
|
|
if (args.show){ |
|
|
|
|
|
target.classList.add("pure-button-active"); |
|
|
|
|
|
target.setAttribute("emit-args", JSON.stringify({show:false})); |
|
|
|
|
|
this.__gridEnabled = true; |
|
|
|
|
|
} else { |
|
|
|
|
|
target.classList.remove("pure-button-active"); |
|
|
|
|
|
target.setAttribute("emit-args", JSON.stringify({show:true})); |
|
|
|
|
|
this.__gridEnabled = false; |
|
|
|
|
|
} |
|
|
|
|
|
RenderD(); |
|
|
|
|
|
}).bind(this); |
|
|
|
|
|
GlobalEvents.listen("painter-togglegrid", handle_togglegrid); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var handle_colormode = (function(target, args){ |
|
|
|
|
|
if (args.onePaletteMode){ |
|
|
|
|
|
target.classList.remove("pure-button-active"); |
|
|
|
|
|
target.setAttribute("emit-args", JSON.stringify({onePaletteMode:false})); |
|
|
|
|
|
this.__onePaletteMode = true; |
|
|
|
|
|
} else { |
|
|
|
|
|
target.classList.add("pure-button-active"); |
|
|
|
|
|
target.setAttribute("emit-args", JSON.stringify({onePaletteMode:true})); |
|
|
|
|
|
this.__onePaletteMode = false; |
|
|
|
|
|
} |
|
|
|
|
|
RenderD(); |
|
|
|
|
|
}).bind(this); |
|
|
|
|
|
GlobalEvents.listen("painter-colormode", handle_colormode); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|