Crate graphics [−] [src]
A library for 2D graphics that works with multiple back-ends.
Piston-Graphics was started in 2014 by Sven Nilsen to test back-end agnostic design for 2D in Rust. This means generic code can be reused across projects and platforms.
A graphics back-end implements the
This library uses immediate design for flexibility. By default, triangles are generated from 2D shapes and passed in chunks to the back-end. This behavior can be overridden by a back-end library.
The structures used for drawing 2D shapes contains settings for rendering.
The separation of shapes and settings allows more reuse and flexibility.
For example, to render an image, you use an
math module contains useful methods for 2D geometry.
Context stores settings that are commonly shared when rendering.
It can be copied and changed without affecting any global state.
At top level, there are some shortcut methods for common operations.
ellipse is a simplified version of
pub use rectangle::Rectangle;
pub use line::Line;
pub use ellipse::Ellipse;
pub use circle_arc::CircleArc;
pub use image::Image;
pub use polygon::Polygon;
pub use text::Text;
pub use context::Context;
pub use draw_state::DrawState;
A text character
Draw an arc
Helper methods for colors
Least square deforming of a 2D grid.
Graphics draw state.
A flat grid with square cells.
Draw an image
Various methods for computing with vectors.
Helper functions for computing modular index safely.
Reexport radians helper trait from vecmath
Methods for converting shapes into triangles.
Contains type aliases used in this library
Stores viewport information.
Any triangulation method called on the back-end never exceeds this number of vertices. This can be used to initialize buffers that fit the chunk size.
Implemented by contexts that contains color.
Implemented by all graphics back-ends.
Implemented by all images to be used with generic algorithms.
Should be implemented by contexts that have rectangle information.
Should be implemented by contexts that have source rectangle information.
Implemented by contexts that can transform.
Clears the screen.