Crate epaint

Source
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

Re-exportsΒ§

pub use self::color::ColorMode;
pub use self::image::AlphaFromCoverage;
pub use self::image::ColorImage;
pub use self::image::ImageData;
pub use self::image::ImageDelta;
pub use self::stats::PaintStats;
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::Galley;
pub use self::textures::TextureManager;
pub use ahash;
pub use ecolor;
pub use emath;

ModulesΒ§

brush πŸ”’
color
corner_radius πŸ”’
corner_radius_f32 πŸ”’
image
margin πŸ”’
margin_f32 πŸ”’
mesh πŸ”’
mutex
Helper module that adds extra checks when the deadlock_detection feature is turned on.
shadow πŸ”’
shape_transform
shapes πŸ”’
stats
Collect statistics about what is being painted.
stroke πŸ”’
tessellator
Converts graphics primitives into textured triangles.
text
Everything related to text, fonts, text layout, cursors etc.
texture_atlas πŸ”’
texture_handle πŸ”’
textures
util
viewport πŸ”’

StructsΒ§

Brush
Controls texturing of a crate::RectShape.
CircleShape
How to paint a circle.
ClippedPrimitive
A Mesh or PaintCallback within a clip rectangle.
ClippedShape
A Shape within a clip rectangle.
Color32
This format is used for space-efficient color representation (32 bits).
CornerRadius
How rounded the corners of things should be.
CornerRadiusF32
How rounded the corners of things should be, in f32.
CubicBezierShape
A cubic BΓ©zier Curve.
EllipseShape
How to paint an ellipse.
Hsva
Hue, saturation, value, alpha. All in the range [0, 1]. No premultiplied alpha.
HsvaGamma
Like Hsva but with the v value (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.
MarginF32
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 Mesh that uses 16-bit indices.
PaintCallback
If you want to paint some 3D shapes inside an egui region, you can use this.
PaintCallbackInfo
Information passed along with PaintCallback (Shape::Callback).
PathShape
A path which can be stroked and/or filled (if closed).
PathStroke
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.
QuadraticBezierShape
A quadratic BΓ©zier Curve.
Rect
A rectangular region of space.
RectShape
How to paint a rectangle.
Rgba
0-1 linear space RGBA color with premultiplied alpha.
Shadow
The color and fuzziness of a fuzzy shape.
Stroke
Describes the width and color of a line.
TextShape
How to paint some text on screen.
TextureAtlas
Contains font data in an atlas, where each character occupied a small rectangle.
TextureHandle
Used to paint images.
Vec2
A vector has a direction and length. A Vec2 is often used to represent a size.
Vertex
The 2D vertex type.
ViewportInPixels
Size of the viewport in whole, physical pixels.

EnumsΒ§

Primitive
A rendering primitive - either a Mesh or a PaintCallback.
Shape
A paint primitive such as a circle or a piece of text. Coordinates are all screen space points (not physical pixels).
StrokeKind
Describes how the stroke of a shape should be painted.
TextureId
What texture to use in a Mesh mesh.

ConstantsΒ§

HAS_RAYON
Was epaint compiled with the rayon feature?
WHITE_UV
The UV coordinate of a white region of the texture mesh.

FunctionsΒ§

pos2
pos2(x, y) == Pos2::new(x, y)
vec2
vec2(x, y) == Vec2::new(x, y)

Type AliasesΒ§

MarginfDeprecated
RoundingDeprecated