Class ShapeExtensions
java.lang.Object
com.technicjelle.BMUtils.ShapeExtensions
-
Method Summary
Modifier and TypeMethodDescriptionstatic ShapeexpandShapeAccurate(@NotNull Shape shape, double amount) Expands aShapeby 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 ShapeexpandShapeRect(@NotNull Shape shape, double amount) Expands aShapeby 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 ShapescaleShapeAround(@NotNull Shape shape, double scale, Vector2d origin) Scales a shape by a given factor, around a given originstatic @NotNull ShapescaleShapeMiddle(@NotNull Shape shape, double scale) Scales a shape by a given factor, around the middle of the shapestatic ShapescaleShapeOrigin(@NotNull Shape shape, double scale) Scales a shape by a given factor, around the origin (0, 0)static ShapeshrinkShapeAccurate(@NotNull Shape shape, double amount) Shrinks aShapeby 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 ShapeshrinkShapeRect(@NotNull Shape shape, double amount) Shrinks aShapeby 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 aShapeby 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 aShapeby 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 aShapeby 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 aShapeby 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
-
scaleShapeMiddle
-
scaleShapeAround
-