Replies: 4 comments 20 replies
-
Did you try forcing a viewportTransform or change it just at export time? |
Beta Was this translation helpful? Give feedback.
-
Just made the change and the left ruler now works exactly the same as the code I've written. I've done I don;t know how many lines and you have done one character :) However just realised that this affects every canvas. So now the left ruler seems to work OK, but not really pushed it yet, but the right top ruler no longer works as the small change affects every canvas. Just looking at the code again, isn't this the same as what you originally suggested though? thanks Rob |
Beta Was this translation helpful? Give feedback.
-
Just found out that when you select an object and move it, the object moves in the Y axis in the opposite direction. Rats! I'll try and work out if I can invert the Y delta. |
Beta Was this translation helpful? Give feedback.
-
I'm now wondering if this is too complicated as we're getting into the bowels of fabric.js. Changing the behaviour of the object dragging code strikes me as a step too far. I'm looking at the code now and I wouldn't know where to start. Having a function that 'simply' translates the points over for each object as its created and cutlines are drawn, but leaving it as-is might be signficantly easier. The ruler code was already written for setting the origin to bottom left. Your solution is massively easier for that part, but managing the drawing of the object as it's being moved requires me to get deep into the code. Tricky? Thoughts? Rob |
Beta Was this translation helpful? Give feedback.
-
I'm writing code for a CNC machine, most CNC machines have their (0,0) bottom left on the screen, though some have them at different corners just to make life interesting :) Fabric.js puts (0,0) on the top left of the canvas so there's a discrepancy.
I'm looking at two different options to handle putting (0,0) at all four corners of the canvas. However there may be more so would welcome inputs and thoughts....
Since I do a lot of points manipulations anyway, adding in more code to modify each point on creation of an object and when I work out the cutting actions is not that major an issue, just a lot of it to do.
I extend or modify something (not exactly sure what) in the master Fabric.js object to handle the maths necessary to change the origin to be either bottom left, bottom right or wherever. So I would capture the coordinates coming in (no idea how yet), modify the coordinates to reflect the new origin. Whenever I check coordinates, I return them based on the origin rather than their actual position on the canvas. Doing this at the main and root object level seems the most consistent way but I have to work out actually how to do it (and in Typescript) as I'm uisng electron.js :)
Interested in other views OR how to implement point 2.
Thanks
Rob
Beta Was this translation helpful? Give feedback.
All reactions