Shapes for Graphics
Contains code to make and alter various shapes.
Primarily designed to be used with Buffer Graphics and Pixels graphics lib
Usage
Add this line to Cargo.toml
= "0.4.0"
# or with both features (serde is enabled by default)
= { = "0.4.0", = ["mint"] }
Examples
let rect = new;
assert!;
let triangle = new;
let rotated = triangle.rotate;
let start = coord!;
let dist = start.distance;
Shapes
Line
Rect
Triangle
Circle
Ellipse
Polygon
Shared methods
contains
(Coord
|Shape
) - Returns true if param is entirely insideintersects
(Shape
) - Returns true if param is partially inside/touchingoutline_pixels
- Returns a list of points that can be used to draw a stroke versionfilled_pixels
- Returns a list of points that can be used to draw a filled versionrotate
,scale
,transform
- Copy and change the shape
Per shape methods
All the shapes have methods to create similar sized shapes of different types, e.g. Circle::to_outer_rect()
, Rect::to_triangles()
Working with multiple shapes
Each Shape
is a separate struct so to store them without putting them in a Box
you can use ShapeBox
which implements Shape
and so is fully compatible with other Shape
s and their methods.
Assertions
This library uses debug assertions for some methods.
Features
Default features: "serde"
Serde
serde
adds serde::{Serialize, Deserialize}
to Coord
, Line
, Rect
, Circle
, Triangle
, Ellipse
, Polygon
Mint
mint
adds a From
impl for Point2<isize>
to Coord
Known issues
Ellipse
s don't render correctly when rotated