You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ah yes - most people would probably not need it, but you can use it to improve performance for special situations. For example if you have a complex rendering on a layer, but just need to move it around, you could use setPosition() to physically move the canvas element as opposed to constantly re rendering. Alternatively, you could copy the canvas, and then re render the canvas pixels at different locations.
I think the situation you mentioned is sort of related to what I want.
I need to 'move around' the canvas. From the source code, setPosition looks like 'not implemented'. It do nothing but set this.xthis.y, and both of the two variables are not used afterward.
Could you provide more sample code to show how to use setPosition?
Currently, I use clip to simulate 'move around' the whole canvas. It will be very nice if you can point out how to use setPosition
you are absolutely correct, setPosition() isn't actually moving the dom element. Must have been something I was thinking about but missed. setPosition() should also do:
Currently, I can not come up with a way to make setPosition meaningful.
Because setPosition is a method of Layer, even if it can be inherited by Scene or Hit somehow. They both live in memory (except the scene instance belonging to the viewport). For most in-memory canvas, how to implement setPosition
Correct me If I understand things more wrong, my knowledge of canvas is limited
Activity
[-]What is the point of `setPosition`[/-][+]What is the point of setPosition[/+]ericdrowell commentedon Jan 10, 2018
ah yes - most people would probably not need it, but you can use it to improve performance for special situations. For example if you have a complex rendering on a layer, but just need to move it around, you could use setPosition() to physically move the canvas element as opposed to constantly re rendering. Alternatively, you could copy the canvas, and then re render the canvas pixels at different locations.
ericdrowell commentedon Jan 10, 2018
you do have a point however, as most folks would probably never use it
GuichiZhao commentedon Jan 10, 2018
I think the situation you mentioned is sort of related to what I want.
I need to 'move around' the canvas. From the source code,
setPositionlooks like 'not implemented'. It do nothing but setthis.xthis.y, and both of the two variables are not used afterward.Could you provide more sample code to show how to use
setPosition?Currently, I use
clipto simulate 'move around' the whole canvas. It will be very nice if you can point out how to usesetPositionMany thanks
ericdrowell commentedon Jan 10, 2018
you are absolutely correct, setPosition() isn't actually moving the dom element. Must have been something I was thinking about but missed. setPosition() should also do:
this.viewport.container.style.marginLeft = x;
this.viewport.container.style.marginTop = y;
or something similar
GuichiZhao commentedon Jan 10, 2018
Currently, I can not come up with a way to make
setPositionmeaningful.Because
setPositionis a method ofLayer, even if it can be inherited bySceneorHitsomehow. They both live in memory (except the scene instance belonging to the viewport). For most in-memory canvas, how to implementsetPositionCorrect me If I understand things more wrong, my knowledge of canvas is limited
marstave commentedon Jan 25, 2018
Just alter the render function and put layer.x and layer.y for the two 0,0 in drawImage :)
GuichiZhao commentedon Jan 28, 2018
@marstave
This is also what I thought where
positioncan fit in :)