Package com.technicjelle.BMUtils
Class ShapeExtensions
java.lang.Object
com.technicjelle.BMUtils.ShapeExtensions
Utility functions for
Shape
s-
Method Summary
Modifier and TypeMethodDescriptionstatic Shape
expandShapeAccurate
(@NotNull Shape shape, double amount) Expands aShape
by a given amount, in all directions.
More accurate for free-form shapes, like ellipses and circles, but less intuitive for rectangular shapes
UseexpandShapeRect(Shape, double)
for more rectangular shapes.
Example: expanding a square by 1 in each direction will only offset each edge by (√2)/2static Shape
expandShapeRect
(@NotNull Shape shape, double amount) Expands aShape
by a given amount, in all directions.
This function is more intuitive for rectangular shapes, but technically not exactly mathematically accurate.
UseexpandShapeAccurate(Shape, double)
for more free-form shapes, like ellipses and circles.
Example: expanding a 16x16 square by 1 in each direction results in an 18x18 squarestatic Shape
scaleShapeAround
(@NotNull Shape shape, double scale, Vector2d origin) Scales a shape by a given factor, around a given originstatic @NotNull Shape
scaleShapeMiddle
(@NotNull Shape shape, double scale) Scales a shape by a given factor, around the middle of the shapestatic Shape
scaleShapeOrigin
(@NotNull Shape shape, double scale) Scales a shape by a given factor, around the origin (0, 0)static Shape
shrinkShapeAccurate
(@NotNull Shape shape, double amount) Shrinks aShape
by a given amount, in all directions.
More accurate for free-form shapes, like ellipses and circles, but less intuitive for rectangular shapes
UseshrinkShapeRect(Shape, double)
for more rectangular shapes.
Example: shrinking a square by 1 in each direction will only offset each edge by (√2)/2static Shape
shrinkShapeRect
(@NotNull Shape shape, double amount) Shrinks aShape
by a given amount, in all directions.
This function is more intuitive for rectangular shapes, but technically not exactly mathematically accurate.
UseshrinkShapeAccurate(Shape, double)
for more free-form shapes, like ellipses and circles.
Example: shrinking a 16x16 square by 1 in each direction results in a 14x14 square
-
Method Details
-
expandShapeRect
Expands aShape
by a given amount, in all directions.
This function is more intuitive for rectangular shapes, but technically not exactly mathematically accurate.
UseexpandShapeAccurate(Shape, double)
for more free-form shapes, like ellipses and circles.
Example: expanding a 16x16 square by 1 in each direction results in an 18x18 square- Parameters:
shape
- The shape to expandamount
- The amount (in blocks) to expand the shape by. May be negative to shrink the shape.- Returns:
- A new shape, expanded by the given amount
- See Also:
-
shrinkShapeRect
Shrinks aShape
by a given amount, in all directions.
This function is more intuitive for rectangular shapes, but technically not exactly mathematically accurate.
UseshrinkShapeAccurate(Shape, double)
for more free-form shapes, like ellipses and circles.
Example: shrinking a 16x16 square by 1 in each direction results in a 14x14 square- Parameters:
shape
- The shape to shrinkamount
- The amount (in blocks) to expand the shape by. May be negative to expand the shape.- Returns:
- A new shape, shrunk by the given amount
- See Also:
-
expandShapeAccurate
Expands aShape
by a given amount, in all directions.
More accurate for free-form shapes, like ellipses and circles, but less intuitive for rectangular shapes
UseexpandShapeRect(Shape, double)
for more rectangular shapes.
Example: expanding a square by 1 in each direction will only offset each edge by (√2)/2- Parameters:
shape
- The shape to expandamount
- The amount to expand the shape by. May be negative to shrink the shape.- Returns:
- A new shape, expanded by the given amount
- See Also:
-
shrinkShapeAccurate
Shrinks aShape
by a given amount, in all directions.
More accurate for free-form shapes, like ellipses and circles, but less intuitive for rectangular shapes
UseshrinkShapeRect(Shape, double)
for more rectangular shapes.
Example: shrinking a square by 1 in each direction will only offset each edge by (√2)/2- Parameters:
shape
- The shape to shrinkamount
- The amount to expand the shape by. May be negative to shrink the shape.- Returns:
- A new shape, shrunk by the given amount
- See Also:
-
scaleShapeOrigin
Scales a shape by a given factor, around the origin (0, 0)- Parameters:
shape
- The shape to scalescale
- The factor to scale by- Returns:
- A new scaled shape
-
scaleShapeMiddle
Scales a shape by a given factor, around the middle of the shape- Parameters:
shape
- The shape to scalescale
- The factor to scale by- Returns:
- A new scaled shape
-
scaleShapeAround
Scales a shape by a given factor, around a given origin- Parameters:
shape
- The shape to scalescale
- The factor to scale byorigin
- The origin to scale around- Returns:
- A new scaled shape
-