Expand description
A simple 2D graphics library for turning simple 2D shapes and text into textured triangles.
Made for egui.
Create some Shape:s and pass them to Tessellator::tessellate_shapes to generate Mesh:es
that you can then paint using some graphics API of your choice (e.g. OpenGL).
§Coordinate system
The left-top corner of the screen is (0.0, 0.0),
with X increasing to the right and Y increasing downwards.
epaint uses logical points as its coordinate system.
Those related to physical pixels by the pixels_per_point scale factor.
For example, a high-dpi screen can have pixels_per_point = 2.0,
meaning there are two physical screen pixels for each logical point.
Angles are in radians, and are measured clockwise from the X-axis, which has angle=0.
§Feature flags
-
cint—cintenables interoperability with other color libraries. -
color-hex— Enable thehex_colormacro. -
color_fonts— Support bitmap (sbix,CBDT) andCOLRglyphs, i.e. color emoji fonts like Apple Color Emoji and Segoe UI Emoji.Adds a PNG decoder to the binary, so it is off by default.
eframeenables it on native viaegui_system_fonts. -
default_fonts— If set, epaint will useinclude_bytes!to bundle some fonts.This is off by default, because only the application should decide whether to pay for the bundled fonts.
eframeenables it by default; an integration that is noteframemust either enable it, or install atext::FontProviderof its own. -
mint—mintenables interoperability with other math libraries such asglamandnalgebra. -
monochrome_emoji_fonts— Bundle the monochrome emoji fontsNotoEmoji-Regularandemoji-icon-font, and put them in the defaulttext::FontDefinitions.They add about 1 MB to the binary, and are only needed if you want the same (monochrome) emoji on every platform, instead of the platform’s own color emoji (see
text::GlyphRasterizerandtext::FontProvider). -
rayon— Enable parallel tessellation usingrayon.This can help performance for graphics-intense applications.
-
serde— Allow serialization usingserde. -
unity— Change Vertex layout to be compatible with unity -
_override_unity— Override and disable the unity feature This exists, so that when testing with –all-features, snapshots render correctly.
§Optional dependencies
document-features— Enable this when generating docs.serde— Allow serialization usingserde.
Re-exports§
pub use self::brush::Brush;pub use self::color::ColorMode;pub use self::corner_radius::CornerRadius;pub use self::corner_radius_f32::CornerRadiusF32;pub use self::direction::Direction;pub use self::image::ColorImage;pub use self::image::FontColorTransferFunction;pub use self::image::ImageData;pub use self::image::ImageDelta;pub use self::margin::Margin;pub use self::mesh::Mesh;pub use self::mesh::Mesh16;pub use self::mesh::Vertex;pub use self::rounded_rect::RoundedRect;pub use self::shadow::Shadow;pub use self::shapes::BandPoint;pub use self::shapes::BandShape;pub use self::shapes::CircleShape;pub use self::shapes::CubicBezierShape;pub use self::shapes::EllipseShape;pub use self::shapes::PaintCallback;pub use self::shapes::PaintCallbackInfo;pub use self::shapes::PathShape;pub use self::shapes::QuadraticBezierShape;pub use self::shapes::RectShape;pub use self::shapes::Shape;pub use self::shapes::TextShape;pub use self::stats::PaintStats;pub use self::stroke::PathStroke;pub use self::stroke::Stroke;pub use self::stroke::StrokeKind;pub use self::tessellator::TessellationOptions;pub use self::tessellator::Tessellator;pub use self::text::FontFamily;pub use self::text::FontId;pub use self::text::Fonts;pub use self::text::FontsView;pub use self::text::Galley;pub use self::text::TextOptions;pub use self::texture_atlas::TextureAtlas;pub use self::texture_handle::TextureHandle;pub use self::textures::TextureManager;pub use self::viewport::ViewportInPixels;pub use ecolor;pub use emath;pub use self::margin_f32::*;
Modules§
- color
- image
- mutex
- Wrappers around
parking_lotlocks, with a simple deadlock detection mechanism. - shape_
transform - special_
emojis - A few special emojis that are not part of the unicode standard.
- stats
- Collect statistics about what is being painted.
- tessellator
- Converts graphics primitives into textured triangles.
- text
- Everything related to text, fonts, text layout, cursors etc.
- textures
- util
Macros§
- hex_
color - Construct a
crate::Color32from a hex RGB or RGBA string literal.
Structs§
- Band
Point - A sample in a
BandShape. - Band
Shape - A varying-width band along a line segment.
- Brush
- Controls texturing of a
crate::RectShape. - Circle
Shape - How to paint a circle.
- Clipped
Primitive - A
MeshorPaintCallbackwithin a clip rectangle. - Clipped
Shape - A
Shapewithin a clip rectangle. - Color32
- This format is used for space-efficient color representation (32 bits).
- Corner
Radius - How rounded the corners of things should be.
- Corner
Radius F32 - How rounded the corners of things should be, in
f32. - Cubic
Bezier Shape - A cubic Bézier Curve.
- Ellipse
Shape - How to paint an ellipse.
- Hsva
- Hue, saturation, value, alpha. All in the range [0, 1]. No premultiplied alpha.
- Hsva
Gamma - Like Hsva but with the
vvalue (brightness) being gamma corrected so that it is somewhat perceptually even. - Margin
- A value for all four sides of a rectangle, often used to express padding or spacing.
- Margin
F32 - A value for all four sides of a rectangle, often used to express padding or spacing.
- Mesh
- Textured triangles in two dimensions.
- Mesh16
- A version of
Meshthat uses 16-bit indices. - Paint
Callback - If you want to paint some 3D shapes inside an egui region, you can use this.
- Paint
Callback Info - Information passed along with
PaintCallback(Shape::Callback). - Path
Shape - A path which can be stroked and/or filled (if closed).
- Path
Stroke - Describes the width and color of paths. The color can either be solid or provided by a callback. For more information, see
ColorMode - Pos2
- A position on screen.
- Quadratic
Bezier Shape - A quadratic Bézier Curve.
- Rect
- A rectangular region of space.
- Rect
Shape - How to paint a rectangle.
- Rgba
- 0-1 linear space
RGBAcolor with premultiplied alpha. - Rounded
Rect - A rectangle geometry with rounded corners.
- Shadow
- The color and fuzziness of a fuzzy shape.
- Stroke
- Describes the width and color of a line.
- Text
Shape - How to paint some text on screen.
- Texture
Atlas - Contains font data in an atlas, where each character occupied a small rectangle.
- Texture
Handle - Used to paint images.
- Vec2
- A vector has a direction and length.
A
Vec2is often used to represent a size. - Vertex
- The 2D vertex type.
- Viewport
InPixels - Size of the viewport in whole, physical pixels.
Enums§
- Direction
- A cardinal direction, one of
LeftToRight,RightToLeft,TopDown,BottomUp. - Primitive
- A rendering primitive - either a
Meshor aPaintCallback. - Shape
- A paint primitive such as a circle or a piece of text. Coordinates are all screen space points (not physical pixels).
- Stroke
Kind - Describes how the stroke of a shape should be painted.
- Texture
Id - What texture to use in a
Meshmesh.
Constants§
- HAS_
RAYON - Was epaint compiled with the
rayonfeature? - WHITE_
UV - The UV coordinate of a white region of the texture mesh.