117 *cx = rel ? (*cx + args[0]) : args[0];
121 *cy = rel ? (*cy + args[0]) : args[0];
125 const int32_t ey = args[na - 1];
126 *cx = rel ? (*cx + ex) : ex;
127 *cy = rel ? (*cy + ey) : ey;
162 static const float k_cubic = 3.0F;
163 const float mt = 1.0F - tt;
164 return ((mt * mt * mt) * c0) + (k_cubic * (mt * mt) * tt * c1) + (k_cubic * mt * (tt * tt) * c2) +
165 ((tt * tt * tt) * c3);
250 const svg_pt_t p = {.x = rel ? (cx + ax) : ax, .y = rel ? (cy + ay) : ay};
298 static const float k_quadratic = 2.0F;
299 const float mt = 1.0F - tt;
300 return ((mt * mt) * c0) + (k_quadratic * mt * tt * c1) + ((tt * tt) * c2);
378 const svg_pt_t r = {.x = (2 * cur.
x) - ctrl.
x, .y = (2 * cur.
y) - ctrl.
y};
562 if ((u ==
'q') || (u ==
't')) {
563 const bool sm = (u ==
't');
566 const int32_t e = sm ? INT32_C(0) : INT32_C(2);
570 if ((u ==
'c') || (u ==
's')) {
571 const bool sm = (u ==
's');
574 const int32_t b = sm ? INT32_C(0) : INT32_C(2);
624 while ((*i < dlen) && (
priv_ra8_svgp_ws((
char)d[*i]) || (d[*i] == (uint8_t)
','))) {
630 const char c = (char)d[*i];
631 if (((c >=
'A') && (c <=
'Z')) || ((c >=
'a') && (c <=
'z'))) {
675 path_state_t st = {.cx = 0, .cy = 0, .ctrl = {.x = 0, .y = 0}, .kind = 0};
683 const size_t i_before = i;
694 const bool rel = (c >=
'a') && (c <=
'z');
710 for (int32_t a = 0; a < na; ++a) {
723 last = rel ?
'l' :
'L';
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
int32_t priv_ra8_svgp_num(const uint8_t *s, size_t len, size_t *i)
Parse the integer part of one SVG number at s[*i], skipping leading separators (whitespace / commas);...
bool priv_ra8_svgp_ws(char c)
Test whether a character is XML whitespace.
bool priv_ra8_svgp_attr(const uint8_t *s, size_t len, const char *name, size_t *voff, size_t *vlen)
Find attribute name in tag span s[0..len); return its value slice.
uint32_t priv_ra8_svgp_resolve_fill(const uint8_t *s, size_t len, const svg_xform_t *t, uint32_t def, int32_t *gi)
Resolve a shape's 'fill': a solid colour, or a gradient index via gi.
char priv_ra8_svgp_lc(char c)
ASCII-fold a character to lower case.
Cross-TU surface for the split minimal-SVG subset (#112).
void priv_ra8_svgp_fill_poly_grad(const int32_t *xs, const int32_t *ys, int32_t n, const svg_grad_t *g)
Per-pixel gradient scanline fill of polygon (xs,ys)[0..n).
void priv_ra8_svgp_fill_poly(const int32_t *xs, const int32_t *ys, int32_t n, uint32_t color)
Even-odd scanline fill of polygon (xs,ys)[0..n) with a solid colour.
void priv_ra8_svgp_map_point(const svg_xform_t *t, int32_t ux, int32_t uy, int32_t *fx, int32_t *fy)
Map a user-space point through the FULL affine, then viewBox->box.
void priv_ra8_svgp_flatten_arc(const svg_xform_t *t, svg_pt_t p0, const int32_t *args, svg_pt_t p_end, int32_t *xs, int32_t *ys, int32_t *n)
Flatten an SVG elliptical arc into the polygon vertex array.
@ k_svg_arc_ey
A arg index: endpoint Y.
@ k_svg_path_args
Max args of a path command (A).
@ k_svg_arc_ex
A arg index: endpoint X.
@ k_svg_def_fill
SVG default fill is black.
@ k_svg_no_paint
none / absent paint sentinel.
@ k_svg_poly_max
Max points / scanline crossings.
@ k_svg_path_ep
Endpoint pair size (x, y); M/L/T.
@ k_svg_argc_cube
Arg count of C.
@ k_svg_curve_seg
Segments per cubic-Bezier flatten.
@ k_svg_argc_quad
Arg count of S / Q.
static int32_t internal_parse_path(const uint8_t *d, size_t dlen, const svg_xform_t *t, int32_t *xs, int32_t *ys)
Parse a path 'd' value into framebuffer-space vertices; return count.
static void internal_flatten_cubic(const svg_xform_t *t, svg_pt_t p0, svg_pt_t p1, svg_pt_t p2, svg_pt_t p3, int32_t *xs, int32_t *ys, int32_t *n)
Flatten a cubic Bezier curve (P0..P3, user space) into the vertex array.
static int32_t internal_emit_cubic(const svg_xform_t *t, svg_pt_t p0, svg_pt_t p1, svg_pt_t p2, svg_pt_t p3, path_state_t *st, int32_t *xs, int32_t *ys, int32_t n)
Flatten a cubic Bezier (P0..P3) into the vertex list and advance path state.
static float internal_bezier1(float tt, float c0, float c1, float c2, float c3)
Evaluate one axis of a cubic Bernstein-Bezier polynomial at parameter tt.
static void internal_flatten_quad(const svg_xform_t *t, svg_pt_t p0, svg_pt_t p1, svg_pt_t p2, int32_t *xs, int32_t *ys, int32_t *n)
Flatten a quadratic Bezier curve (P0..P2, user space) into the vertex array.
static int32_t internal_emit_quad(const svg_xform_t *t, svg_pt_t p0, svg_pt_t p1, svg_pt_t p2, path_state_t *st, int32_t *xs, int32_t *ys, int32_t n)
Flatten a quadratic Bezier (P0..P2) into the vertex list and advance path state.
static svg_pt_t internal_arg_pt(bool rel, int32_t cx, int32_t cy, int32_t ax, int32_t ay)
Resolve an absolute or relative SVG point from an argument pair.
static svg_pt_t internal_reflect(svg_pt_t cur, svg_pt_t ctrl)
Reflect control point ctrl through current point cur.
static svg_pt_t internal_smooth_ctrl(svg_pt_t p0, const path_state_t *st, char want)
Derive the first control point for a smooth curve command.
static void internal_path_step(char u, bool rel, const int32_t *args, int32_t na, int32_t *cx, int32_t *cy)
Advance the current path point to the endpoint of a line-type command.
static int32_t internal_cmd_argc(char u)
Return the argument count for a lower-cased SVG path command letter.
static char internal_next_cmd(const uint8_t *d, size_t dlen, size_t *i, char *last)
Resolve the next path command at d[*i].
static float internal_bezier_q1(float tt, float c0, float c1, float c2)
Evaluate one axis of a quadratic Bernstein-Bezier polynomial at parameter tt.
void priv_ra8_svgp_draw_path(const uint8_t *s, size_t len, const svg_xform_t *t)
Draw one SVG 'path' element as a filled polygon.
static int32_t internal_path_curve(const svg_xform_t *t, char u, bool rel, const int32_t *args, path_state_t *st, int32_t *xs, int32_t *ys, int32_t n)
Flatten a cubic/quadratic path curve command into the vertex list.
Running cursor state while parsing a <path> d string.
int32_t cx
Current point X (user space).
svg_pt_t ctrl
Last control (abs): quad ctrl (Q/T) or cubic ctrl2 (C/S).
char kind
'q' if the last command was Q/T, 'c' if C/S, else 0.
int32_t cy
Current point Y (user space).
svg_grad_t g[k_svg_grad_max]
The gradient table.
A 2-D point in SVG user space (an x/y pair).