SOLVED Mojo drawing tools: rotate, origin point argument



  • Hi there, I'm trying to specify an origin point for rotation with mojo drawing tools. Is this possible? I can get around this by rotating on (0,0) and then translating, but of course accustomed to DrawBot.

    RF docs:
    rotate(angle)
    Rotate the canvas around the origin point with a given angle in degrees.

    DB docs:
    rotate(angle, center=(0, 0))
    Rotate the canvas around the center point (which is the origin by default) with a given angle in degrees.

    Thanks!
    Ryan



  • Understood. Thanks @frederik !


  • admin

    savedState() will be added :)


  • admin

    Some DrawBot api callback are indeed super handy to have while drawing in RF. But supporting all DrawBot apis will be overkill... mojo.drawingTools is a simplified set of DrawBot as not every method is usefull in a view based canvas.



  • Thanks @gferreira and @frederik! While we're on the subject, it'd be great to have the two libraries pretty much synonymous, if there isn't any reason not to. For instance, savedState() in DrawBot vs deprecated save() & restore().


  • admin

    added! will be there in the next beta and release!

    thanks



  • hello @ryan,

    the rotate() command in mojo.drawingTools does not support the center argument. (I wasn’t aware of it in DrawBot until now :)

    you can achieve the same result by translating to the desired rotation center, applying the rotation, and then translating back to the previous position:

    translate(x, y)
    rotate(angle)
    translate(-x, -y)
    

    I think it would make sense to add center to mojo.drawingTools too, so that both APIs are the same. I’ve created an issue for it.

    thanks!