Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
f1d2d2224This file is pinned to the selected release. Download the original to open it in your design tool.
package com.marginallyclever.makelangelo.makeart.turtletool;
import com.marginallyclever.makelangelo.turtle.Turtle;
import java.awt.geom.Rectangle2D;
/**
* Center the input {@link Turtle} to the origin.
* @author Dan Royer
*/
public class CenterTurtleToPaperAction extends TurtleTool {
public CenterTurtleToPaperAction(String name) {
super(name);
}
@Override
public Turtle run(Turtle turtle) {
Rectangle2D.Double turtleBounds = turtle.getBounds(); // image bounds
double ix = turtleBounds.getCenterX();
double iy = turtleBounds.getCenterY();
// apply
Turtle result = new Turtle(turtle);
result.translate(-ix,-iy);
return result;
}
}