Progress on zoom

This commit is contained in:
Devine Lu Linvega
2017-12-27 21:27:02 +13:00
parent e3815cb8da
commit 041e5ec873
10 changed files with 133 additions and 54 deletions

View File

@@ -5,7 +5,9 @@ function Brush()
this.speed = 0;
this.pointers = [
new Pointer({offset:{x:0,y:0}})
new Pointer({offset:{x:0,y:0}}),
new Pointer({offset:{x:2,y:2}}),
new Pointer({offset:{x:4,y:4}})
];
this.methods.add = new Method("add","x,y&mirror_x,mirror_y","Add a new pointer to the brush",function(q){

View File

@@ -4,6 +4,7 @@ function Frame()
this.width = 400;
this.height = 400;
this.zoom = {scale:1,offset:{x:0,y:0}};
this.methods.resize = new Method("resize","WxH","Resize canvas to size.",function(q){
var data = ronin.render.select(0,0,ronin.frame.width,ronin.frame.height);
@@ -38,6 +39,25 @@ function Frame()
ronin.guide.draw();
});
this.methods.zoom = new Method("zoom","","Zoom canvas",function(q){
if(ronin.frame.zoom.scale == parseInt(q)){ return; }
ronin.frame.zoom.scale = parseInt(q);
ronin.layers.render.el.style.width = (ronin.frame.width * ronin.frame.zoom.scale)+"px";
ronin.layers.render.el.style.height = (ronin.frame.height * ronin.frame.zoom.scale)+"px";
if(ronin.frame.zoom.scale == 1){
ronin.frame.zoom.offset.x = 0;
ronin.frame.zoom.offset.y = 0;
}
else{
ronin.frame.zoom.offset.x = ((-ronin.cursor.pos.x * ronin.frame.zoom.scale) + (ronin.frame.width/2));
ronin.frame.zoom.offset.y = ((-ronin.cursor.pos.y * ronin.frame.zoom.scale) + (ronin.frame.height/2));
}
ronin.layers.render.el.style.left = ronin.frame.zoom.offset.x+"px";
ronin.layers.render.el.style.top = ronin.frame.zoom.offset.y+"px";
});
this.resize_to = function(size)
{
ronin.frame.width = size.width;