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
MoveTo in paths doesn't seem to be working as expected for me - here is a quick example from sbt console to show you what I mean:
val c = implicitly[doodle.backend.Canvas].asInstanceOf[doodle.jvm.Java2DCanvas]
val i = implicitly[doodle.backend.Interpreter].asInstanceOf[doodle.backend.StandardInterpreter]
def axes(xLen: Int, yLen: Int) = Path(List(
MoveTo(Vec(-xLen/2,0)),
LineTo(Vec(xLen/2,0)),
MoveTo(Vec(0,-yLen/2)),
LineTo(Vec(0,yLen/2))))
axes(100,100).draw(i,c)
val linePath = Path(List(
MoveTo(Vec(0,0)),
LineTo(Vec(10,10))
))
linePath.draw(i,c)
And the output:
I'm trying to add support for rotating images and drawing circular arcs in paths, and ran into this while testing. If you can give me a pointer to what might be wrong, id be happy to take a crack at fixing it!
The text was updated successfully, but these errors were encountered:
ankitson
changed the title
Paths are off center
Path MoveTo doesnt move to the right place
Oct 22, 2015
Thanks for the report! Rotations would be awesome. Circular arcs you should be able to build on top of BezierCurveTo, as in Canvas#circle
The issue you're seeing is caused by the call to Canvas#setOriginhere. The underlying issue is that draw attempts to render the image centered in the canvas. This requires translating from the local coordinate system that an Image uses to the global coordinate system in the Canvas.
The axes image is already centered on its local coordinate system, so there is no transformation from local to global coordinate system.
The linePath image is centered at (5,5) in its local coordinate system (the line goes from (0,0) to (10, 10)), so when we call draw it add a transform from local to global coordinates. It's this transform, along with the attempt to resize the canvas, that causes the image to not be centered relative to the previous image.
I'm not sure of the best way to fix this. There are other draw methods that allow the origin to be specified, but they aren't very convenient to use.
MoveTo in paths doesn't seem to be working as expected for me - here is a quick example from
sbt console
to show you what I mean:And the output:
![screenshot 2015-10-22 02 51 16](https://cloud.githubusercontent.com/assets/855649/10662225/ec2ee5ba-7867-11e5-855c-b35ae937360e.png)
I'm trying to add support for rotating images and drawing circular arcs in paths, and ran into this while testing. If you can give me a pointer to what might be wrong, id be happy to take a crack at fixing it!
The text was updated successfully, but these errors were encountered: