Sketch --Transform

Does anyone have an example using transform? I am not sure what function it is referring to in the documentation. Is this for taking a sketch object and translating/rotating it?


Apply an arbitrary transformation to a sketch, by specifying functions

transform will take a sketch layer and perform transformations on each x and y coordinate of the sketchLayer assigned.

You’ll need to create two functions to transform both the x and y coordinates of the sketch layer.

fnx = simpleFunction("x+5","x","y") moves the entire sketch 5 to the right
fny = simpleFunction("y","x","y") preserves all of the y coordinates in the sketch

They work just like transformations in coordinate geometry work. In this case sketch.transform(fnx,fny)

Or you can do it all in one line without the fnx, fny functions. Its just easier to share it that way!


One caveat to be aware of with this is that they currently only transform the key points, not all of the pixels in between, so non-linear transformations may not be quite right (e.g. they will transform the end-points of a straight line, not transform that straight line into a curve).

1 Like

Very cool. I could see how this could come in handy.

Thanks again Jay.