Package nl.saxion.app.canvas.pens
Class Pen
java.lang.Object
nl.saxion.app.canvas.pens.Pen
- Direct Known Subclasses:
FilledPen
Pen object is used to draw on the canvas. This will draw lines between points.
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
protected int
protected int
protected boolean
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
debug()
int
getAngle()
Get the current angle of the pen (in degrees)void
headTo
(int degrees) Set rotation.boolean
isOn()
Indicates if the pen is on or off.void
move
(int distance) Move the pen a certain distance.void
moveTo
(int newX, int newY) Move the current pen position to the new x and new y provided.void
Reset the angle of the pen (reset to 0 degrees)void
rotate
(int degrees) Rotate, relatively to the current rotationvoid
turnOff()
Turn the pen off.void
turnOn()
Turn the pen on.
-
Field Details
-
penOn
protected boolean penOn -
currentX
protected int currentX -
currentY
protected int currentY -
currentAngle
protected int currentAngle
-
-
Constructor Details
-
Pen
public Pen()
-
-
Method Details
-
turnOn
public void turnOn()Turn the pen on. -
turnOff
public void turnOff()Turn the pen off. -
move
public void move(int distance) Move the pen a certain distance. The angle can be set using `headTo` or `rotate`.- Parameters:
distance
- Distance in pixel
-
moveTo
public void moveTo(int newX, int newY) Move the current pen position to the new x and new y provided. In case the pen is on, a line will be drawn between the previous point and the new point.- Parameters:
newX
- New x-coordinatenewY
- New y-coordinate
-
isOn
public boolean isOn()Indicates if the pen is on or off.- Returns:
- True, if the pen is on.
-
rotate
public void rotate(int degrees) Rotate, relatively to the current rotation- Parameters:
degrees
- Number of degrees
-
headTo
public void headTo(int degrees) Set rotation. 0 degrees is to right, 90 down, 180 left, 270 up.- Parameters:
degrees
- Number of degrees
-
getAngle
public int getAngle()Get the current angle of the pen (in degrees)- Returns:
- Number of degrees
-
resetAngle
public void resetAngle()Reset the angle of the pen (reset to 0 degrees) -
debug
public void debug()
-