Package com.takenoko.shape
Class Shape
java.lang.Object
com.takenoko.shape.Shape
- Direct Known Subclasses:
Pattern
Class representing a Shape.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final PositionVector
private final Map<PositionVector,
Tile> static final IllegalArgumentException
-
Constructor Summary
ConstructorsConstructorDescriptionShape
(PositionVector... vectors) Constructor of the Shape class.Shape
(Map<PositionVector, Tile> shape) Constructor for the Shape class.Shape
(Map<PositionVector, Tile> shape, PositionVector defaultRotationOrigin) Constructor for the Shape class.Shape
(org.apache.commons.lang3.tuple.Pair<PositionVector, Tile>... vectors) Constructor of the Shape class. -
Method Summary
Modifier and TypeMethodDescriptioncopy()
boolean
private static PositionVector
findOrigin
(Map<PositionVector, Tile> shape) Find the rotation origin of the shape.getMissingShape
(Shape other) getRotatedShape
(int i) int
hashCode()
rotate60()
Returns a new shape with the same pattern but rotated 60 degrees around the rotation origin of the shape.rotate60
(PositionVector rotationOrigin) Returns a new shape with the same pattern but rotated 60 degrees around the given rotation rotationOrigin.toString()
translate
(PositionVector vector) Returns a new shape with the same pattern but translated by the given vector.
-
Field Details
-
THE_SHAPE_CANNOT_BE_EMPTY_EXCEPTION
-
elements
-
defaultRotationOrigin
-
-
Constructor Details
-
Shape
Constructor for the Shape class.- Parameters:
shape
- the pattern of the shapedefaultRotationOrigin
- the default rotation origin of the shape
-
Shape
Constructor for the Shape class. The rotation origin is the element the closest to the origin of the coordinate system.- Parameters:
shape
- the pattern of the shape
-
Shape
Constructor of the Shape class. To facilitate the creation of the shape, the shape is defined by a list of vectors. The rotation origin is the element the closest to the origin of the coordinate- Parameters:
vectors
- the vectors of the shape
-
Shape
-
Shape
Constructor of the Shape class. To facilitate the creation of the shape, the shape is defined by a list of Pair of vectors and tiles. The rotation origin is the element the closest to the origin of the coordinate system.
-
-
Method Details
-
findOrigin
Find the rotation origin of the shape.- Parameters:
shape
- the pattern of the shape- Returns:
- the rotation origin of the shape
-
getElements
-
rotate60
Returns a new shape with the same pattern but rotated 60 degrees around the given rotation rotationOrigin. see https://www.redblobgames.com/grids/hexagons/#rotation- Parameters:
rotationOrigin
- pivot point of the rotation- Returns:
- the rotated shape
-
rotate60
Returns a new shape with the same pattern but rotated 60 degrees around the rotation origin of the shape.- Returns:
- the shape rotated 60 degrees around the first element of the pattern
-
getRotatedShapes
-
getRotatedShape
-
translate
Returns a new shape with the same pattern but translated by the given vector.- Parameters:
vector
- the vector to translate the shape by- Returns:
- a new shape with the same pattern but translated by the given vector
-
equals
-
hashCode
public int hashCode() -
copy
-
toString
-
getMissingShape
-