RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
Loading...
Searching...
No Matches
path.h File Reference

Caller-owned Q16 paths and deterministic sample-coverage painting. More...

#include "draw_target.h"

Data Structures

struct  rmgui_path_command_t
 One verb, indexing the path's caller-owned Q16 point array. More...
struct  rmgui_path_t
 Initialize counts to zero. More...
struct  rmgui_path_scratch_t
 Scratch storage must not overlap its other arrays, the path or pixels. More...
struct  rmgui_path_stroke_t
 Positive Q16 width and miter limit (ratio >= 1). More...

Enumerations

enum  rmgui_path_verb_t {
  RMGUI_PATH_MOVE , RMGUI_PATH_LINE , RMGUI_PATH_QUAD , RMGUI_PATH_CUBIC ,
  RMGUI_PATH_ARC , RMGUI_PATH_CLOSE
}
 Stored verbs. More...
enum  rmgui_path_cap_t { RMGUI_PATH_CAP_BUTT , RMGUI_PATH_CAP_ROUND , RMGUI_PATH_CAP_SQUARE }
 Caps and joins for the geometry of a stroked path. More...
enum  rmgui_path_join_t { RMGUI_PATH_JOIN_MITER , RMGUI_PATH_JOIN_ROUND , RMGUI_PATH_JOIN_BEVEL }

Functions

int rmgui_path_move_to (rmgui_path_t *, rmgui_draw_point_t)
int rmgui_path_line_to (rmgui_path_t *, rmgui_draw_point_t)
int rmgui_path_quad_to (rmgui_path_t *, rmgui_draw_point_t, rmgui_draw_point_t)
int rmgui_path_cubic_to (rmgui_path_t *, rmgui_draw_point_t, rmgui_draw_point_t, rmgui_draw_point_t)
int rmgui_path_arc_to (rmgui_path_t *, rmgui_draw_point_t, int32_t, int32_t, int32_t, unsigned)
 SVG endpoint arc: nonnegative radii, flags 0..3; zero radius is a line, equal endpoints paint no arc.
int rmgui_path_close (rmgui_path_t *)
int rmgui_path_rect (rmgui_path_t *, rmgui_draw_point_t, int32_t, int32_t)
 Append closed shapes atomically.
int rmgui_path_rounded_rect (rmgui_path_t *, rmgui_draw_point_t, int32_t, int32_t, int32_t)
int rmgui_path_ellipse (rmgui_path_t *, rmgui_draw_point_t, int32_t, int32_t)
int rmgui_path_fill (rmgui_fb_t *, rmgui_rect_t, const rmgui_path_t *, rmgui_draw_fill_rule_t, rmgui_color_t, rmgui_draw_mode_t, rmgui_path_scratch_t *)
 Nonzero/even-odd AA fill; open subpaths close implicitly.
int rmgui_path_stroke (rmgui_fb_t *, rmgui_rect_t, const rmgui_path_t *, const rmgui_path_stroke_t *, rmgui_color_t, rmgui_draw_mode_t, rmgui_path_scratch_t *)
 Stroke produces consistently wound component contours then fills their union once with nonzero winding, avoiding overdraw at joins/intersections.
int rmgui_path_fill_to (rmgui_target_t *, rmgui_rect_t, const rmgui_path_t *, rmgui_draw_fill_rule_t, rmgui_color_t, rmgui_draw_mode_t, rmgui_path_scratch_t *)
 Target variants snapshot flattened geometry before returning.
int rmgui_path_stroke_to (rmgui_target_t *, rmgui_rect_t, const rmgui_path_t *, const rmgui_path_stroke_t *, rmgui_color_t, rmgui_draw_mode_t, rmgui_path_scratch_t *)

Detailed Description

Caller-owned Q16 paths and deterministic sample-coverage painting.

Enumeration Type Documentation

◆ rmgui_path_verb_t

Stored verbs.

ARC flags are bit 0 large arc, bit 1 clockwise.

Enumerator
RMGUI_PATH_MOVE 
RMGUI_PATH_LINE 
RMGUI_PATH_QUAD 
RMGUI_PATH_CUBIC 
RMGUI_PATH_ARC 
RMGUI_PATH_CLOSE 

◆ rmgui_path_cap_t

Caps and joins for the geometry of a stroked path.

Enumerator
RMGUI_PATH_CAP_BUTT 
RMGUI_PATH_CAP_ROUND 
RMGUI_PATH_CAP_SQUARE 

◆ rmgui_path_join_t

Enumerator
RMGUI_PATH_JOIN_MITER 
RMGUI_PATH_JOIN_ROUND 
RMGUI_PATH_JOIN_BEVEL 

Function Documentation

◆ rmgui_path_move_to()

int rmgui_path_move_to ( rmgui_path_t * ,
rmgui_draw_point_t  )

◆ rmgui_path_line_to()

int rmgui_path_line_to ( rmgui_path_t * ,
rmgui_draw_point_t  )

◆ rmgui_path_quad_to()

int rmgui_path_quad_to ( rmgui_path_t * ,
rmgui_draw_point_t ,
rmgui_draw_point_t  )

◆ rmgui_path_cubic_to()

◆ rmgui_path_arc_to()

int rmgui_path_arc_to ( rmgui_path_t * ,
rmgui_draw_point_t ,
int32_t ,
int32_t ,
int32_t ,
unsigned  )

SVG endpoint arc: nonnegative radii, flags 0..3; zero radius is a line, equal endpoints paint no arc.

Radii enlarge as needed to reach the endpoint. Refuses if enlarged radii or resulting vertices exceed signed Q16 range.

◆ rmgui_path_close()

int rmgui_path_close ( rmgui_path_t * )

◆ rmgui_path_rect()

int rmgui_path_rect ( rmgui_path_t * ,
rmgui_draw_point_t ,
int32_t ,
int32_t  )

Append closed shapes atomically.

Nonpositive extents or ellipse radii refuse. Rects use Q16 origin and extents. A rounded radius must be nonnegative and clamps to half the smaller extent; zero gives square corners.

Caller-owned temporary vertices and intersections. Flattening uses a fixed 32-level subdivision stack, stopping when every control coordinate differs from its chord's parameter-linear control by <= 1/1024 pixel. Including subdivision rounding, curve error is <= 1/512 pixel before raster rounding. Arc chord error is <= 1/512 pixel, plus integer endpoint conversion error. Vertices round to 1/256 pixel, halves up, exactly as draw_aa.

◆ rmgui_path_rounded_rect()

int rmgui_path_rounded_rect ( rmgui_path_t * ,
rmgui_draw_point_t ,
int32_t ,
int32_t ,
int32_t  )

◆ rmgui_path_ellipse()

int rmgui_path_ellipse ( rmgui_path_t * ,
rmgui_draw_point_t ,
int32_t ,
int32_t  )

◆ rmgui_path_fill()

Nonzero/even-odd AA fill; open subpaths close implicitly.

Each contour's boundary contributes no winding; other containing contours still fill. Nonconvex and self-intersecting contours are valid. Clip never rebases samples. Returns 0, or -1 without destination changes for NULL, malformed paths, invalid mode/rule, or insufficient scratch. Work is bounded by visible pixels, flattened geometry and its sorting.

◆ rmgui_path_stroke()

Stroke produces consistently wound component contours then fills their union once with nonzero winding, avoiding overdraw at joins/intersections.

Fill's refusal rules apply; invalid styles or geometry outside signed Q16 range also return -1 before destination writes. Each intermediate miter offset must fit UINT32_MAX Q16 units (the full coordinate span), including before the miter-limit comparison.

◆ rmgui_path_fill_to()

Target variants snapshot flattened geometry before returning.

Scratch is needed only during this call; replay intersections use submit scratch.

◆ rmgui_path_stroke_to()