Skip to main content

Crate yog_graphics

Crate yog_graphics 

Source
Expand description

yog-graphics — the graphics primitives every Yog crate shares, so a color, a rectangle or a picture is one type everywhere: Color, Vec2/Vec3/Mat4, Rect, vector Seg paths, RGBA Images, drawings (Op: paths filled and stroked, images) and a Canvas that paints them to pixels.

Modules§

color
Colors: 0xAARRGGBB, straight alpha — what every Yog format and API passes.
draw
Drawings: what to paint, in order — paths filled or stroked, images — in a drawing’s own units (y up). Glyphs, icons and shapes are drawings; a Canvas paints them.
image
RGBA images.
mask
One-color pictures, a bit a pixel: a pixel font’s glyph is one — a thirty-second of the same picture as RGBA.
math
Vectors and 4×4 matrices (column-major, as JOML and the hosts’ PoseStack keep them).
path
Vector paths: contours of lines and curves, as fonts, SVG and drawn shapes describe them.
raster
A canvas to draw on in pixels (y down): shapes filled with signed-area coverage (anti-aliased, non-zero winding), strokes as the union of their segments with round joins and caps, images sampled into place.
rect
Axis-aligned rectangles.

Structs§

Canvas
Pixels being drawn, premultiplied, in floats.
Color
A color, 0xAARRGGBB.
Fill
Image
Pixels, RGBA8 row by row from the top, straight alpha.
ImageOp
image in box rect (rect.x, rect.y its bottom-left corner).
Mask
width × height pixels, a bit each: rows top to bottom, a row’s pixels from its first byte’s highest bit on, each row whole bytes.
MaskOp
mask in box rect (rect.x, rect.y its bottom-left corner), its set pixels color (none: the current color — a text’s).
Mat4
A 4×4 matrix, column-major: m[col * 4 + row].
PlacedImage
An image and where it goes: its top-left corner x, y pixels (y down) from the origin it was drawn for — a glyph’s from its pen position on the baseline, say.
Rect
A rectangle: its corner x, y (the one with the smallest coordinates) and its size.
Stroke
Vec2
A point or a direction in a plane.
Vec3

Enums§

Op
One step of a drawing.
Seg
A path segment.

Constants§

BYTES_PER_PIXEL
Bytes per pixel: red, green, blue, alpha.

Functions§

rad
Degrees to radians, for the formats (which are in degrees).

Type Aliases§

Rgba8
One RGBA8 pixel.