53 float r = 0.0f,
g = 0.0f,
b = 0.0f,
a = 1.0f;
56 static constexpr Color rgba(
float r,
float g,
float b,
float a = 1.0f) {
61 static constexpr Color rgba8(uint8_t
r, uint8_t
g, uint8_t
b, uint8_t
a = 255) {
62 return {
r / 255.0f,
g / 255.0f,
b / 255.0f,
a / 255.0f};
67 return rgba8(
static_cast<uint8_t
>((rgb >> 16) & 0xFF),
68 static_cast<uint8_t
>((rgb >> 8) & 0xFF),
69 static_cast<uint8_t
>(rgb & 0xFF));
74 struct HSV {
float h = 0,
s = 0,
v = 0; };
75 struct HSL {
float h = 0,
s = 0,
l = 0; };
99 return {
r + (other.r -
r) * t,
100 g + (other.g -
g) * t,
101 b + (other.b -
b) * t,
102 a + (other.a -
a) * t};
107 return {
r * multiplier,
g * multiplier,
b * multiplier,
a};
112 return {
r,
g,
b, alpha};
116 uint8_t
r8()
const {
return static_cast<uint8_t
>(std::clamp(
r, 0.0f, 1.0f) * 255.0f + 0.5f); }
117 uint8_t
g8()
const {
return static_cast<uint8_t
>(std::clamp(
g, 0.0f, 1.0f) * 255.0f + 0.5f); }
118 uint8_t
b8()
const {
return static_cast<uint8_t
>(std::clamp(
b, 0.0f, 1.0f) * 255.0f + 0.5f); }
119 uint8_t
a8()
const {
return static_cast<uint8_t
>(std::clamp(
a, 0.0f, 1.0f) * 255.0f + 0.5f); }
123 return (
static_cast<uint32_t
>(
a8()) << 24) |
124 (
static_cast<uint32_t
>(
r8()) << 16) |
125 (
static_cast<uint32_t
>(
g8()) << 8) |
126 static_cast<uint32_t
>(
b8());
131 return rgba8(
static_cast<uint8_t
>((argb >> 16) & 0xFF),
132 static_cast<uint8_t
>((argb >> 8) & 0xFF),
133 static_cast<uint8_t
>(argb & 0xFF),
134 static_cast<uint8_t
>((argb >> 24) & 0xFF));
138 return r == other.r &&
g == other.g &&
b == other.b &&
a == other.a;
203using Paint = std::variant<Color, LinearGradient, RadialGradient, ConicGradient>;
278 virtual void scale(
float sx,
float sy) = 0;
290 float d,
float e,
float f) {
291 (void)a; (void)b; (void)c; (void)d; (void)e; (void)f;
312 float d,
float e,
float f) {
313 (void)a; (void)b; (void)c; (void)d; (void)e; (void)f;
323 float a = 1.0f,
b = 0.0f;
324 float c = 0.0f,
d = 1.0f;
325 float e = 0.0f,
f = 0.0f;
342 virtual void clip_rect(
float x,
float y,
float w,
float h) = 0;
395 (void)enabled; (void)quality;
401 const Color* colors,
const float* positions,
408 const Color* colors,
const float* positions,
420 float cx,
float cy,
float rx,
float ry,
421 const Color* colors,
const float* positions,
int count) {
433 float x0,
float y0,
float r0,
434 float x1,
float y1,
float r1,
435 const Color* colors,
const float* positions,
int count) {
436 (void)x0; (void)y0; (void)r0;
442 const Color* colors,
const float* positions,
461 const Color* colors,
const float* positions,
467 const Color* colors,
const float* positions,
474 float x0,
float y0,
float r0,
475 float x1,
float y1,
float r1,
476 const Color* colors,
const float* positions,
int count) {
477 (void)x0; (void)y0; (void)r0;
482 const Color* colors,
const float* positions,
508 (void)image_src; (void)tile_x; (void)tile_y;
517 (void)image_src; (void)tile_x; (void)tile_y;
553 virtual void move_to(
float x,
float y) { (void)x; (void)y; }
555 virtual void line_to(
float x,
float y) { (void)x; (void)y; }
557 virtual void quad_to(
float cpx,
float cpy,
float x,
float y) {
558 (void)cpx; (void)cpy;
line_to(x, y);
561 virtual void cubic_to(
float cp1x,
float cp1y,
float cp2x,
float cp2y,
563 (void)cp1x; (void)cp1y; (void)cp2x; (void)cp2y;
line_to(x, y);
572 virtual void arc(
float cx,
float cy,
float radius,
573 float start_angle,
float end_angle,
574 bool anticlockwise) {
575 (void)cx; (void)cy; (void)radius;
576 (void)start_angle; (void)end_angle; (void)anticlockwise;
582 virtual void arc_to(
float x1,
float y1,
float x2,
float y2,
float radius) {
583 (void)x1; (void)y1; (void)x2; (void)y2; (void)radius;
589 virtual void ellipse(
float cx,
float cy,
float rx,
float ry,
591 float start_angle,
float end_angle,
592 bool anticlockwise) {
593 (void)cx; (void)cy; (void)rx; (void)ry; (void)rotation;
594 (void)start_angle; (void)end_angle; (void)anticlockwise;
603 float tl_x,
float tl_y,
604 float tr_x,
float tr_y,
605 float br_x,
float br_y,
606 float bl_x,
float bl_y) {
607 (void)x; (void)y; (void)w; (void)h;
608 (void)tl_x; (void)tl_y; (void)tr_x; (void)tr_y;
609 (void)br_x; (void)br_y; (void)bl_x; (void)bl_y;
638 float intensity,
float threshold,
640 save_layer(x, y, w, h, 1.0f, radius * intensity);
644 virtual void fill_rect(
float x,
float y,
float w,
float h) = 0;
660 virtual void clear_rect(
float x,
float y,
float w,
float h) {
669 float start_angle,
float end_angle) = 0;
672 virtual void stroke_line(
float x0,
float y0,
float x1,
float y1) = 0;
687 if (points ==
nullptr ||
count < 2)
return;
688 for (
size_t i = 1; i <
count; ++i)
689 stroke_line(points[i-1].x, points[i-1].y, points[i].x, points[i].y);
714 if (points ==
nullptr ||
count < 3)
return;
716 move_to(points[0].x, points[0].y);
717 for (
size_t i = 1; i <
count; ++i)
718 line_to(points[i].x, points[i].y);
733 float x,
float y,
float w,
float h) {
734 (void)native_handle; (void)x; (void)y; (void)w; (void)h;
751 if (
path.is_empty())
return;
767 if (
path.is_empty())
return;
772 if (style.
dash.empty())
784 if (
path.is_empty())
return;
807 if (
path.is_empty())
return;
810 if (spread != 0.0f) {
812 if (b.width > 0.0f && b.height > 0.0f) {
813 const float sx = (b.width + 2.0f * spread) / b.width;
814 const float sy = (b.height + 2.0f * spread) / b.height;
816 sx, sy, b.x + b.width * 0.5f, b.y + b.height * 0.5f));
853 constexpr explicit operator bool()
const {
return id != 0; }
871 clip_rect(bounds.x, bounds.y, bounds.width, bounds.height);
885 (void)layer; (void)alpha; (void)mode;
890 (void)layer; (void)dest;
895 (void)layer; (void)angle_rad;
929 float w,
float h,
const std::function<
void(
Canvas&)>& paint) {
930 (void)w; (void)h; (void)paint;
948 float opacity = 1.0f,
float blur_radius = 0.0f) {
950 (void)x; (void)y; (void)w; (void)h;
951 (void)opacity; (void)blur_radius;
961 float opacity,
float blur_radius,
1001 for (
int i = 0; i <
count; ++i) {
1005 opacity *= chain[i].
amount;
1028 const std::string& effect_name,
1060 const std::string& mask_image,
1061 const std::string& mask_size) {
1062 (void)mask_image; (void)mask_size;
1067 virtual void set_font(
const std::string& family,
float size) = 0;
1085 std::size_t byte_index) {
1148 float x,
float y,
float max_width) {
1163 float max_width = 0.0f) {
1179 int weight,
int slant,
float letter_spacing) {
1180 (void)weight; (void)slant; (void)letter_spacing;
1211 return (
static_cast<uint32_t
>(
static_cast<uint8_t
>(s[0])) << 24) |
1212 (
static_cast<uint32_t
>(
static_cast<uint8_t
>(s[1])) << 16) |
1213 (
static_cast<uint32_t
>(
static_cast<uint8_t
>(s[2])) << 8) |
1214 static_cast<uint32_t
>(
static_cast<uint8_t
>(s[3]));
1282 float x,
float y,
float w,
float h) {
1283 (void)data; (void)size; (void)x; (void)y; (void)w; (void)h;
1289 float x,
float y,
float w,
float h) {
1290 (void)
path; (void)x; (void)y; (void)w; (void)h;
1301 float x,
float y,
float w,
float h) {
1302 (void)svg_document; (void)x; (void)y; (void)w; (void)h;
1311 float sx,
float sy,
float sw,
float sh,
1312 float dx,
float dy,
float dw,
float dh) {
1313 (void)sx; (void)sy; (void)sw; (void)sh;
1317 float sx,
float sy,
float sw,
float sh,
1318 float dx,
float dy,
float dw,
float dh) {
1319 (void)sx; (void)sy; (void)sw; (void)sh;
1330 float& out_width,
float& out_height) {
1332 out_width = 0.0f; out_height = 0.0f;
1345 m.actual_bounding_box_left = 0;
1346 m.actual_bounding_box_right = m.width;
1347 m.actual_bounding_box_ascent = m.ascent;
1348 m.actual_bounding_box_descent = m.descent;
1362 (void)intervals; (void)
count; (void)phase;
1371 virtual bool read_pixels(
int x,
int y,
int width,
int height, uint8_t* out) {
1372 (void)x; (void)y; (void)width; (void)height; (void)out;
1381 (void)data; (void)width; (void)height; (void)dx; (void)dy;
1467 const std::string& sksl,
1469 (void)sksl; (void)options;
1478 float blur_radius,
float corner_radius = 0,
1494 float blur_radius) {
1495 (void)x; (void)y; (void)w; (void)h; (void)blur_radius;
1514 for (
int i = 0; i <
count; ++i)
1532 float dx,
float dy,
float blur,
float spread,
1534 float corner_radius = 0.0f);
1584 virtual void set_filter(
const std::string& filter) { (void)filter; }
1598 float x,
float y,
float width,
float height,
1601 if (
count < 2)
return;
1605 float half_h = height * 0.5f;
1607 float prev_y = cy - samples[0] * half_h;
1608 for (
size_t i = 1; i <
count; ++i) {
1609 float sx = x + (
static_cast<float>(i) /
static_cast<float>(
count - 1)) * width;
1610 float sy = cy - samples[i] * half_h;
1655 float v[4] = {0, 0, 0, 0};
1724 const std::string& uniform_name);
1731 float x,
float y,
float w,
float h,
1740 float x,
float y,
float w,
float h,
1774 float x,
float y,
float w,
float h,
1776 float sample_radius = 0.0f,
1777 const std::vector<NamedUniform>& extra_uniforms = {},
1779 (void)sksl; (void)uniforms; (void)sample_radius;
1780 (void)extra_uniforms; (void)blend_mode;
1817 float dx,
float dy,
float dw,
float dh,
1819 float align_x = 0.5f,
1820 float align_y = 0.5f) {
1822 if (iw <= 0.0f || ih <= 0.0f || dw <= 0.0f || dh <= 0.0f)
return r;
1831 const float w = iw *
scale;
1832 const float h = ih *
scale;
1833 return {dx + (dw - w) * align_x, dy + (dh - h) * align_y, w, h};
1855 float dx,
float dy,
float dw,
float dh,
1857 float align_x = 0.5f,
1858 float align_y = 0.5f) {
1862 draw_image(native_handle, r.x, r.y, r.w, r.h);
1872 float dx,
float dy,
float dw,
float dh,
1874 float align_x = 0.5f,
1875 float align_y = 0.5f) {
1876 float iw = 0.0f, ih = 0.0f;
1897 float tile_w,
float tile_h,
1898 float dx,
float dy,
float dw,
float dh,
1899 float offset_x = 0.0f,
float offset_y = 0.0f) {
1900 if (tile_w <= 0.0f || tile_h <= 0.0f || dw <= 0.0f || dh <= 0.0f)
return;
1905 float start_x = dx - std::fmod(offset_x, tile_w);
1906 if (start_x > dx) start_x -= tile_w;
1907 float start_y = dy - std::fmod(offset_y, tile_h);
1908 if (start_y > dy) start_y -= tile_h;
1909 for (
float ty = start_y; ty < dy + dh; ty += tile_h) {
1910 for (
float tx = start_x; tx < dx + dw; tx += tile_w) {
1911 draw_image(native_handle, tx, ty, tile_w, tile_h);
1935 const Color* colors,
const float* positions,
1955 const Color* colors,
1956 const float* positions,
1967 float sy,
float sw,
float sh,
float dx,
float dy,
1968 float dw,
float dh) {
1980 size_t size,
float x,
float y,
float w,
float h) {
1988 const uint8_t* data,
size_t size,
float sx,
1989 float sy,
float sw,
float sh,
float dx,
float dy,
1990 float dw,
float dh) {
2002 float& out_height) {
2005 static constexpr uint8_t kPngSignature[] = {0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a};
2006 if (!data || size < 24)
2008 for (
size_t i = 0; i <
sizeof(kPngSignature); ++i)
2009 if (data[i] != kPngSignature[i])
2011 const auto read_be32 = [&](
size_t offset) {
2012 return (
static_cast<uint32_t
>(data[offset]) << 24) |
2013 (
static_cast<uint32_t
>(data[offset + 1]) << 16) |
2014 (
static_cast<uint32_t
>(data[offset + 2]) << 8) |
2015 static_cast<uint32_t
>(data[offset + 3]);
2018 if (data[12] !=
'I' || data[13] !=
'H' || data[14] !=
'D' || data[15] !=
'R')
2020 const uint32_t w = read_be32(16);
2021 const uint32_t h = read_be32(20);
2022 if (w == 0 || h == 0 || w > 0x7fffffffu || h > 0x7fffffffu)
2024 out_width =
static_cast<float>(w);
2025 out_height =
static_cast<float>(h);
2033 gradient_interpolation_ = m;
2036 return gradient_interpolation_;
Definition canvas.hpp:240
virtual bool save_layer_with_sksl_post_effect(float x, float y, float w, float h, const std::string &sksl, const ShaderUniforms &uniforms, float sample_radius=0.0f, const std::vector< NamedUniform > &extra_uniforms={}, BlendMode blend_mode=BlendMode::normal)
Save a compositing layer whose ALREADY-PAINTED content is post-processed by a custom SkSL shader.
Definition canvas.hpp:1773
virtual void translate(float x, float y)=0
virtual void stroke_text(const std::string &text, float x, float y, float max_width=0.0f)
Canvas2D strokeText(text, x, y, maxWidth) spec form.
Definition canvas.hpp:1162
virtual void clip(FillRule rule=FillRule::nonzero)
Intersect the current clip region with the current path.
Definition canvas.hpp:348
virtual void set_transform(float a, float b, float c, float d, float e, float f)
Replace the current transform with the affine matrix [ a c e ] [ b d f ] [ 0 0 1 ] Mirrors CanvasRend...
Definition canvas.hpp:289
virtual void set_font_full(const std::string &family, float size, int weight, int slant, float letter_spacing)
Richer font setter that propagates CSS font-weight (100..900), font-slant (0=upright,...
Definition canvas.hpp:1178
virtual bool draw_image_from_keyed_data(const std::string &content_key, const uint8_t *data, size_t size, float x, float y, float w, float h)
Draw encoded image bytes identified by content_key, the lowercase hex SHA-256 of exactly those bytes.
Definition canvas.hpp:1979
virtual void save_layer(float x, float y, float w, float h, float opacity=1.0f, float blur_radius=0.0f)
Save a compositing layer.
Definition canvas.hpp:947
virtual void clip_path_svg(const std::string &svg_path_d)
CSS clip-path: path("...") — intersect the current clip with an SVG-path-d string.
Definition canvas.hpp:358
virtual ~Canvas()=default
virtual void stroke_rect(float x, float y, float w, float h)=0
static std::string compile_sksl(const std::string &sksl)
Validate and compile an SkSL shader without drawing.
virtual void draw_image_tiled(void *native_handle, float tile_w, float tile_h, float dx, float dy, float dw, float dh, float offset_x=0.0f, float offset_y=0.0f)
Fill the destination box (dx, dy, dw, dh) by tiling an opaque image handle at cells of size (tile_w x...
Definition canvas.hpp:1896
virtual bool draw_with_sksl(const std::string &sksl, float x, float y, float w, float h, const ShaderDrawOptions &options)
Definition canvas.hpp:1739
virtual void draw_layer_rotated(LayerHandle layer, float angle_rad)
Composite a sealed layer rotated about its own center.
Definition canvas.hpp:894
virtual void set_stroke_gradient_radial_two_circles(float x0, float y0, float r0, float x1, float y1, float r1, const Color *colors, const float *positions, int count)
Two-circle radial gradient on stroke (mirrors fill counterpart).
Definition canvas.hpp:473
virtual bool draw_image_from_keyed_data_rect(const std::string &content_key, const uint8_t *data, size_t size, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh)
Source-rect form of draw_image_from_keyed_data, with the same key contract.
Definition canvas.hpp:1987
virtual void invalidate_layer(LayerHandle layer)
Drop layer's texture.
Definition canvas.hpp:909
TextAnchor
Explicit, typed vertical-anchor API.
Definition canvas.hpp:1119
@ EmBoxTop
Definition canvas.hpp:1123
@ GlyphTop
Definition canvas.hpp:1121
@ Baseline
Definition canvas.hpp:1120
@ GlyphCenter
Definition canvas.hpp:1122
virtual bool draw_image_from_file_rect(const std::string &path, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh)
Definition canvas.hpp:1310
virtual void clip_rect(float x, float y, float w, float h)=0
virtual bool draw_image_from_data_rect(const uint8_t *data, size_t size, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh)
Definition canvas.hpp:1316
virtual void draw_image_transformed(void *native_handle, float w, float h, const AffineTransform &t)
Draw an opaque image handle (see draw_image) under an arbitrary affine transform.
Definition canvas.hpp:1841
virtual void draw_image_fitted(void *native_handle, float iw, float ih, float dx, float dy, float dw, float dh, ImageFit fit, float align_x=0.5f, float align_y=0.5f)
Draw an opaque image handle fitted into a destination box with a preserve-aspect fit mode and alignme...
Definition canvas.hpp:1854
virtual bool draw_image_from_file(const std::string &path, float x, float y, float w, float h)
Draw an image from a file path at the given rect.
Definition canvas.hpp:1288
GradientInterpolation gradient_interpolation() const
Definition canvas.hpp:2035
virtual void set_shadow_color(Color color)
Sticky drop-shadow state that wraps subsequent draw operations, matching the CanvasRenderingContext2D...
Definition canvas.hpp:1552
virtual bool draw_image_file_fitted(const std::string &path, float dx, float dy, float dw, float dh, ImageFit fit, float align_x=0.5f, float align_y=0.5f)
Draw a file-path image fitted into a destination box.
Definition canvas.hpp:1871
virtual void clear_rect(float x, float y, float w, float h)
Clear a rectangular region to transparent black (rgba 0,0,0,0).
Definition canvas.hpp:660
virtual void capture_paint_baseline_transform()
Snapshot the current device matrix as the baseline for subsequent set_transform() calls.
Definition canvas.hpp:298
virtual void fill_text_sdf(const std::string &text, float x, float y, const class SdfAtlas &atlas)
Render text using an SDF glyph atlas for resolution-independent rendering.
Definition canvas.hpp:1254
virtual void set_shadow_blur(float blur)
Definition canvas.hpp:1553
virtual void fill_rounded_rect(float x, float y, float w, float h, float radius)=0
virtual void set_stroke_gradient_linear(float x0, float y0, float x1, float y1, const Color *colors, const float *positions, int count)
Definition canvas.hpp:460
static std::string compile_sdf_chart_sksl(SDFShape shape, const std::string &sksl)
Compile an author chart shader against the geometry prelude used by draw_sdf_shape_with_shader.
virtual void save_backdrop_filter_chain(float x, float y, float w, float h, const FilterChainEntry *chain, int count)
CSS backdrop-filter with its full function list — saturate(0.2), brightness(2), invert(1),...
Definition canvas.hpp:1510
virtual bool draw_image_from_data(const uint8_t *data, size_t size, float x, float y, float w, float h)
Draw an image from encoded data (PNG, JPEG, WebP) at the given rect.
Definition canvas.hpp:1281
bool supports_image_draw() const
Whether this backend can actually decode + draw a raster image (the draw_image_from_* verbs below).
Definition canvas.hpp:1277
virtual void set_fill_gradient_conic_repeating(float cx, float cy, float start_angle, float sweep_turns, const Color *colors, const float *positions, int count)
Set a REPEATING conic gradient (CSS repeating-conic-gradient).
Definition canvas.hpp:1933
virtual bool layer_valid(LayerHandle layer) const
Is layer still backed by a live texture that can be drawn WITHOUT re-recording it?
Definition canvas.hpp:901
virtual void set_filter(const std::string &filter)
Canvas2D ctx.filter.
Definition canvas.hpp:1584
virtual std::shared_ptr< SceneRecording > record_scene(float w, float h, const std::function< void(Canvas &)> &paint)
Record paint into a replayable SceneRecording, capturing its draw commands ONCE so later frames can d...
Definition canvas.hpp:928
virtual void set_fill_gradient_linear_repeating(float x0, float y0, float x1, float y1, const Color *colors, const float *positions, int count)
Set a REPEATING linear gradient (CSS repeating-linear-gradient).
Definition canvas.hpp:1953
virtual float measure_text(const std::string &text)=0
virtual bool draw_svg(const std::string &svg_document, float x, float y, float w, float h)
Render an SVG document (the literal <svg>…</svg> string) into the box [x,y,w,h], scaled to fit.
Definition canvas.hpp:1300
virtual AffineTransform2x3 current_transform() const
Snapshot the current device matrix (CTM) without mutating canvas state.
Definition canvas.hpp:337
virtual void ellipse(float cx, float cy, float rx, float ry, float rotation, float start_angle, float end_angle, bool anticlockwise)
Native ellipse subpath.
Definition canvas.hpp:589
virtual void set_text_align(TextAlign align)=0
virtual void set_font(const std::string &family, float size)=0
virtual void draw_waveform(const float *samples, size_t count, float x, float y, float width, float height, const WaveformStyle &style)
Definition canvas.hpp:1597
virtual void set_fill_gradient_conic(float cx, float cy, float start_angle, const Color *colors, const float *positions, int count)
Set a conic (sweep) gradient as the fill paint.
Definition canvas.hpp:441
virtual bool write_pixels(const uint8_t *data, int width, int height, int dx, int dy)
Write RGBA pixels (data size = width*height*4) to the current surface at destination (dx,...
Definition canvas.hpp:1379
virtual void stroke_line(float x0, float y0, float x1, float y1)=0
virtual void set_fill_pattern(const std::string &image_src, PatternTileMode tile_x, PatternTileMode tile_y)
Set an image pattern as the fill paint.
Definition canvas.hpp:505
virtual void save_layer_with_shader_effect(float x, float y, float w, float h, const std::string &effect_name, float intensity)
Curated, named GPU post-effect layer save.
Definition canvas.hpp:1026
pulp::canvas::Point2D Point2D
Stroke a continuous polyline through an array of points.
Definition canvas.hpp:682
virtual void set_fill_gradient_linear(float x0, float y0, float x1, float y1, const Color *colors, const float *positions, int count)
Set a linear gradient as the fill paint.
Definition canvas.hpp:400
virtual void save_layer_with_bloom(float x, float y, float w, float h, float intensity, float threshold, float radius)
Save a compositing layer that applies a real bloom/glow post-effect to the subtree painted into it.
Definition canvas.hpp:637
virtual void set_opacity(float alpha)
Set global alpha for subsequent drawing operations (0.0-1.0).
Definition canvas.hpp:828
virtual void save_layer_with_blend(float x, float y, float w, float h, float opacity, float blur_radius, BlendMode mode)
Save a compositing layer with an explicit blend mode.
Definition canvas.hpp:960
virtual void rotate(float radians)=0
virtual RendererBackend renderer_backend() const noexcept
Identity of the renderer this canvas actually wraps.
Definition canvas.hpp:246
virtual void fill_path(const Path &path, FillRule rule=FillRule::nonzero)
Fill path under rule.
Definition canvas.hpp:750
virtual void set_fill_color(Color c)=0
TextDirection
Canvas2D ctx.direction.
Definition canvas.hpp:1571
@ rtl
Definition canvas.hpp:1571
@ inherit
Definition canvas.hpp:1571
@ ltr
Definition canvas.hpp:1571
virtual void set_image_smoothing(bool enabled, ImageSmoothingQuality quality=ImageSmoothingQuality::low)
Canvas2D ctx.imageSmoothingEnabled + imageSmoothingQuality.
Definition canvas.hpp:392
BlendMode
Indices 0..15 match the existing W3C "advanced" composite ops and must stay stable — set_blend_mode i...
Definition canvas.hpp:527
@ color_dodge
Definition canvas.hpp:530
@ multiply
Definition canvas.hpp:529
@ copy
Definition canvas.hpp:542
@ destination_over
Definition canvas.hpp:534
@ soft_light
Definition canvas.hpp:530
@ overlay
Definition canvas.hpp:529
@ screen
Definition canvas.hpp:529
@ source_atop
Definition canvas.hpp:539
@ lighter
Definition canvas.hpp:543
@ color
Definition canvas.hpp:531
@ hue
Definition canvas.hpp:531
@ source_over
Definition canvas.hpp:533
@ destination_out
Definition canvas.hpp:538
@ luminosity
Definition canvas.hpp:531
@ xor_mode
Definition canvas.hpp:541
@ difference
Definition canvas.hpp:531
@ destination_in
Definition canvas.hpp:536
@ source_in
Definition canvas.hpp:535
@ source_out
Definition canvas.hpp:537
@ hard_light
Definition canvas.hpp:530
@ color_burn
Definition canvas.hpp:530
@ darken
Definition canvas.hpp:529
@ lighten
Definition canvas.hpp:529
@ destination_atop
Definition canvas.hpp:540
@ exclusion
Definition canvas.hpp:531
@ saturation
Definition canvas.hpp:531
@ normal
Definition canvas.hpp:529
virtual void begin_path()
Begin a new path.
Definition canvas.hpp:551
virtual void arc(float cx, float cy, float radius, float start_angle, float end_angle, bool anticlockwise)
Native arc subpath.
Definition canvas.hpp:572
virtual void set_font_smoothing(FontSmoothing smoothing)
CSS -webkit-font-smoothing for the text drawn and measured after it.
Definition canvas.hpp:1190
virtual void set_miter_limit(float limit)
Canvas2D ctx.miterLimit.
Definition canvas.hpp:377
virtual void draw_path_shadow(const Path &path, float dx, float dy, float blur, float spread, Color color)
Draw ONLY the drop shadow cast by path — not the path itself.
Definition canvas.hpp:805
virtual void stroke_circle(float cx, float cy, float radius)=0
static constexpr uint32_t make_font_feature_tag(const char(&s)[5])
Builds a 4-byte big-endian OpenType tag from a 4-char string.
Definition canvas.hpp:1210
virtual void draw_blurred_backdrop(float x, float y, float w, float h, float blur_radius, float corner_radius=0, Color tint=Color::rgba(0.0f, 0.0f, 0.0f, 0.314f))
Save a blurred snapshot of the current canvas content as a backdrop.
Definition canvas.hpp:1477
virtual void set_shadow_offset_x(float dx)
Definition canvas.hpp:1554
virtual void stroke_arc(float cx, float cy, float radius, float start_angle, float end_angle)=0
virtual void fill_text_anchored(const std::string &text, float x, float y, TextAnchor anchor)
Definition canvas.hpp:1125
virtual void concat_transform(float a, float b, float c, float d, float e, float f)
Concat (multiply) the supplied affine matrix onto the current transform — does NOT replace it.
Definition canvas.hpp:311
virtual void fill_circle(float cx, float cy, float radius)=0
virtual void save_layer_with_mask(float x, float y, float w, float h, float opacity, const std::string &mask_image, const std::string &mask_size)
CSS mask-image + mask-size paint slice.
Definition canvas.hpp:1058
virtual void set_line_cap(LineCap cap)=0
virtual float backing_scale() const noexcept
Effective device pixels per local canvas unit at the current transform.
Definition canvas.hpp:253
virtual void clear_fill_gradient()
Clear gradient, return to solid fill color.
Definition canvas.hpp:448
virtual void stroke_path(const Point2D *points, size_t count)
Stroke a continuous polyline — much smoother than individual stroke_line calls.
Definition canvas.hpp:685
virtual float text_x_for_byte(const std::string &text, std::size_t byte_index)
Caret x (in text-local space, measured from the text's leading edge) for the glyph boundary at byte_i...
Definition canvas.hpp:1084
virtual void draw_box_shadow(float x, float y, float w, float h, float dx, float dy, float blur, float spread, Color color, bool inset=false, float corner_radius=0.0f)
Draw a CSS-style box shadow around (or inside, when inset) a rounded rectangle anchored at (x,...
virtual LayerHandle end_layer()
Seal the layer opened by the last begin_layer() and return its handle.
Definition canvas.hpp:877
virtual void draw_image(void *native_handle, float x, float y, float w, float h)
Draw an image identified by an opaque, platform-specific handle into the rectangle (x,...
Definition canvas.hpp:732
virtual bool measure_image_from_file(const std::string &path, float &out_width, float &out_height)
Decoded-image intrinsic dimensions in pixels.
Definition canvas.hpp:1329
virtual void set_font_features(std::vector< FontFeature > features)
Definition canvas.hpp:1216
virtual void save_backdrop_filter(float x, float y, float w, float h, float blur_radius)
CSS backdrop-filter: blur(Npx) — push a compositing layer whose initial contents are the parent surfa...
Definition canvas.hpp:1493
ImageSmoothingQuality
Canvas2D image-smoothing quality enum.
Definition canvas.hpp:382
@ medium
Definition canvas.hpp:382
@ low
Definition canvas.hpp:382
@ high
Definition canvas.hpp:382
static bool sksl_declares_uniform(const std::string &sksl, const std::string &uniform_name)
Whether an SkSL shader declares a uniform of the given name.
virtual void fill_rect(float x, float y, float w, float h)=0
virtual void stroke_current_path()
Stroke the current path.
Definition canvas.hpp:619
virtual void set_line_dash(const float *intervals, int count, float phase=0.0f)
Set the line dash pattern for stroke operations.
Definition canvas.hpp:1361
virtual bool draw_with_sksl(const std::string &sksl, float x, float y, float w, float h, const ShaderUniforms &uniforms)
Draw a rectangle filled by a custom SkSL shader.
Definition canvas.hpp:1730
virtual void fill_path(const Point2D *points, size_t count, FillRule rule=FillRule::nonzero)
Fill a closed polygon defined by points, honoring rule.
Definition canvas.hpp:712
float font_size_
Current font size (set by set_font).
Definition canvas.hpp:1918
virtual void set_fill_gradient_radial(float cx, float cy, float radius, const Color *colors, const float *positions, int count)
Set a radial gradient as the fill paint.
Definition canvas.hpp:407
ImageFit
Preserve-aspect fit modes for fit_image_rect / draw_image_fitted: fill — stretch to the destination b...
Definition canvas.hpp:1805
@ none
Definition canvas.hpp:1805
@ cover
Definition canvas.hpp:1805
@ scale_down
Definition canvas.hpp:1805
@ fill
Definition canvas.hpp:1805
@ contain
Definition canvas.hpp:1805
virtual void set_stroke_pattern(const std::string &image_src, PatternTileMode tile_x, PatternTileMode tile_y)
Stroke counterpart.
Definition canvas.hpp:514
virtual void set_fill_gradient_radial_two_circles(float x0, float y0, float r0, float x1, float y1, float r1, const Color *colors, const float *positions, int count)
Canvas2D ctx.createRadialGradient(x0,y0,r0,x1,y1,r1) two-circle form.
Definition canvas.hpp:432
virtual void scale(float sx, float sy)=0
virtual void set_gradient_interpolation(GradientInterpolation m)
Colour space every LATER gradient setter blends its stops in (CSS <color-interpolation-method>),...
Definition canvas.hpp:2032
virtual void fill_text_with_max_width(const std::string &text, float x, float y, float max_width)
Canvas2D fillText(text, x, y, maxWidth) spec form.
Definition canvas.hpp:1147
static float sdf_feather_min_reach(const SDFStyle &style)
The smallest draw-rect reach that holds style's feather: 3 sigma for the glow (1) and outer (3) modes...
Definition canvas.hpp:1708
static FitResult fit_image_rect(float iw, float ih, float dx, float dy, float dw, float dh, ImageFit fit, float align_x=0.5f, float align_y=0.5f)
Pure geometry: place a source image of intrinsic size (iw x ih) into the destination box (dx,...
Definition canvas.hpp:1816
virtual void draw_layer(LayerHandle layer, float alpha=1.0f, BlendMode mode=BlendMode::normal)
Composite a sealed layer at its recorded position.
Definition canvas.hpp:883
virtual void restore_to_count(int target)
Pop the save stack down to target (typically captured earlier via save_count()).
Definition canvas.hpp:274
virtual void fill_text(const std::string &text, float x, float y)=0
virtual void arc_to(float x1, float y1, float x2, float y2, float radius)
Native arcTo.
Definition canvas.hpp:582
virtual void set_stroke_gradient_radial(float cx, float cy, float radius, const Color *colors, const float *positions, int count)
Definition canvas.hpp:466
virtual void cubic_to(float cp1x, float cp1y, float cp2x, float cp2y, float x, float y)
Add a cubic bezier curve.
Definition canvas.hpp:561
PatternTileMode
Canvas2D ctx.createPattern.
Definition canvas.hpp:497
@ repeat
Definition canvas.hpp:497
@ no_repeat
Definition canvas.hpp:497
virtual void round_rect(float x, float y, float w, float h, float tl_x, float tl_y, float tr_x, float tr_y, float br_x, float br_y, float bl_x, float bl_y)
Native rounded-rectangle subpath with per-corner radii.
Definition canvas.hpp:602
virtual void draw_layer_fitted(LayerHandle layer, Rect2D dest)
Composite a sealed layer scaled into dest.
Definition canvas.hpp:889
virtual void set_line_width(float w)=0
SDFShape
Draw an SDF shape with anti-aliased edges via GPU shader.
Definition canvas.hpp:1387
@ squircle
Definition canvas.hpp:1393
@ stadium
Definition canvas.hpp:1396
@ ring
Definition canvas.hpp:1395
@ cross
Definition canvas.hpp:1397
@ rect
Definition canvas.hpp:1388
@ flat_arc
Definition canvas.hpp:1400
@ rounded_rect
Definition canvas.hpp:1390
@ diamond
Definition canvas.hpp:1392
@ flat_segment
Definition canvas.hpp:1398
@ circle
Definition canvas.hpp:1389
@ rounded_segment
Definition canvas.hpp:1399
@ quadratic_bezier
Definition canvas.hpp:1401
@ triangle
Definition canvas.hpp:1394
virtual void line_to(float x, float y)
Add a line segment to (x, y).
Definition canvas.hpp:555
virtual void clip_path(const Path &path, FillRule rule=FillRule::nonzero)
Intersect the current clip with path. Caller owns save()/restore().
Definition canvas.hpp:783
virtual TextMetrics measure_text_full(const std::string &text)
Measure text with full font metrics using current font settings.
Definition canvas.hpp:1337
virtual void clear_font_features()
Definition canvas.hpp:1222
virtual void stroke_path(const Path &path, const StrokeStyle &style)
Stroke path with style.
Definition canvas.hpp:766
virtual bool draw_scene(const SceneRecording &rec)
Replay a recording produced by THIS backend's record_scene() at the current transform/clip.
Definition canvas.hpp:938
virtual bool supports(CanvasCapability) const
Report whether this backend renders cap's verb faithfully.
Definition canvas.hpp:1268
virtual int save_count() const
Return the current save-stack depth.
Definition canvas.hpp:266
virtual bool draw_image_from_static_data_rect(const uint8_t *data, size_t size, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh)
Source-rect draw for bytes with static storage duration and immutable contents.
Definition canvas.hpp:1966
virtual void set_stroke_gradient_conic(float cx, float cy, float start_angle, const Color *colors, const float *positions, int count)
Definition canvas.hpp:481
virtual void close_path()
Close the current path subpath.
Definition canvas.hpp:612
virtual void save_layer_with_filters(float x, float y, float w, float h, float opacity, const FilterChainEntry *chain, int count)
Definition canvas.hpp:995
virtual void draw_sdf_shape(SDFShape shape, float x, float y, float w, float h, const SDFStyle &style)
Definition canvas.hpp:1423
virtual void set_shadow_offset_y(float dy)
Definition canvas.hpp:1555
virtual void set_direction(TextDirection direction)
Definition canvas.hpp:1572
virtual void move_to(float x, float y)
Move the pen to (x, y) without drawing.
Definition canvas.hpp:553
virtual void set_fill_gradient_radial_elliptical(float cx, float cy, float rx, float ry, const Color *colors, const float *positions, int count)
Radial gradient with an independent radius per axis — the ending shape CSS calls an ellipse,...
Definition canvas.hpp:419
virtual LayerHandle begin_layer(Rect2D bounds, bool cacheable=false)
Begin recording into an offscreen layer covering bounds (in current user space).
Definition canvas.hpp:868
virtual void set_blend_mode(BlendMode mode)
Set the compositing blend mode for subsequent draw operations.
Definition canvas.hpp:547
virtual void quad_to(float cpx, float cpy, float x, float y)
Add a quadratic bezier curve to (x, y) with control point (cpx, cpy).
Definition canvas.hpp:557
virtual void clear_stroke_gradient()
Clear stroke gradient/pattern shader, restore solid stroke color.
Definition canvas.hpp:488
virtual bool measure_image_from_data(const uint8_t *data, size_t size, float &out_width, float &out_height)
Intrinsic pixel size of encoded image bytes, read from the image header without decoding pixels: the ...
Definition canvas.hpp:2001
virtual bool read_pixels(int x, int y, int width, int height, uint8_t *out)
Read RGBA pixels from the current surface into out (size must be at least width*height*4).
Definition canvas.hpp:1371
virtual void fill_current_path(FillRule rule=FillRule::nonzero)
Fill the current path.
Definition canvas.hpp:615
virtual void stroke_rounded_rect(float x, float y, float w, float h, float radius)=0
virtual void set_stroke_color(Color c)=0
virtual bool draw_sdf_shape_with_shader(SDFShape shape, float x, float y, float w, float h, const SDFStyle &style, const std::string &sksl, const ShaderDrawOptions &options)
Draw a shape through an author-supplied geometry chart shader.
Definition canvas.hpp:1464
virtual void set_line_join(LineJoin join)=0
FillStyle(ConicGradient g)
Definition canvas.hpp:179
FillStyle(LinearGradient g)
Definition canvas.hpp:177
bool is_linear() const
Definition canvas.hpp:182
FillStyle(Color c)
Definition canvas.hpp:176
FillStyle(RadialGradient g)
Definition canvas.hpp:178
const Color & color() const
Definition canvas.hpp:186
void set_tile_mode(GradientTileMode m)
Definition canvas.hpp:192
bool is_conic() const
Definition canvas.hpp:184
bool is_solid() const
Definition canvas.hpp:181
const RadialGradient & radial() const
Definition canvas.hpp:188
GradientTileMode tile_mode() const
Definition canvas.hpp:191
const ConicGradient & conic() const
Definition canvas.hpp:189
const LinearGradient & linear() const
Definition canvas.hpp:187
bool is_radial() const
Definition canvas.hpp:183
void apply_transform(const AffineTransform &t)
Transform every point in place.
Opaque handle to a subtree's recorded draw commands, produced by Canvas::record_scene() and replayed ...
Definition scene_recording.hpp:18
Definition sdf_atlas.hpp:39
Definition affine_transform.hpp:24
TextAlign
Definition canvas.hpp:221
@ right
Definition canvas.hpp:221
@ left
Definition canvas.hpp:221
@ justify
Definition canvas.hpp:221
@ center
Definition canvas.hpp:221
std::size_t safe_utf8_prefix_size(const std::string &text, std::size_t byte_index) noexcept
Return the largest prefix length <= byte_index that ends on a valid UTF-8 scalar boundary.
Definition text_utf8.hpp:19
@ oklch
Definition gradient_interpolation.hpp:36
@ hsl
Definition gradient_interpolation.hpp:33
TextVerticalAlign
Definition canvas.hpp:222
@ bottom
Definition canvas.hpp:222
@ top
Definition canvas.hpp:222
@ baseline
Definition canvas.hpp:222
std::variant< Color, LinearGradient, RadialGradient, ConicGradient > Paint
Definition canvas.hpp:203
FontSmoothing
CSS -webkit-font-smoothing as it affects glyph rasterization on macOS.
Definition text_raster_policy.hpp:40
CanvasCapability
Queryable backend capabilities.
Definition canvas_capability.hpp:19
@ images
draw_image_from_* really decode + draw
Definition canvas_capability.hpp:20
@ count
sentinel: number of real capabilities (keep LAST)
Definition canvas_capability.hpp:38
RendererBackend
Runtime identity of the concrete renderer receiving draw calls.
Definition canvas.hpp:29
@ skia_dawn
Definition canvas.hpp:35
@ core_graphics
Definition canvas.hpp:32
@ unknown
Definition canvas.hpp:30
@ skia_raster
Definition canvas.hpp:33
@ skia_ganesh
Definition canvas.hpp:34
@ recording
Definition canvas.hpp:31
FillRule
Winding rule used to decide what counts as "inside" a path.
Definition path.hpp:54
@ nonzero
Definition path.hpp:54
TextBaseline
Definition canvas.hpp:230
@ ideographic
Definition canvas.hpp:230
@ alphabetic
Definition canvas.hpp:230
@ middle
Definition canvas.hpp:230
@ hanging
Definition canvas.hpp:230
TextDirection
Definition canvas.hpp:231
@ left_to_right
Definition canvas.hpp:231
@ right_to_left
Definition canvas.hpp:231
@ bottom_to_top
Definition canvas.hpp:231
@ top_to_bottom
Definition canvas.hpp:231
constexpr const char * renderer_backend_name(RendererBackend backend) noexcept
Definition canvas.hpp:38
LineJoin
Join applied where two segments meet when stroking.
Definition path.hpp:60
@ text
Definition scene_node.hpp:96
@ shape
Definition scene_node.hpp:94
@ path
Definition scene_node.hpp:93
GradientTileMode
Gradient repeat mode.
Definition canvas.hpp:169
@ repeat
Definition canvas.hpp:169
@ clamp
Definition canvas.hpp:169
@ mirror
Definition canvas.hpp:169
LineCap
Line cap applied to the ends of open subpaths when stroking.
Definition path.hpp:57
Full CSS filter-chain layer save.
Definition canvas.hpp:974
float amount
Definition canvas.hpp:988
float ds_offset_y
Definition canvas.hpp:991
Kind kind
Definition canvas.hpp:987
float angle_deg
Definition canvas.hpp:989
Color ds_color
Definition canvas.hpp:993
Kind
Definition canvas.hpp:975
@ invert
Definition canvas.hpp:981
@ grayscale
Definition canvas.hpp:979
@ saturate
Definition canvas.hpp:983
@ drop_shadow
Definition canvas.hpp:985
@ opacity
Definition canvas.hpp:982
@ brightness
Definition canvas.hpp:977
@ sepia
Definition canvas.hpp:984
@ blur
Definition canvas.hpp:976
@ contrast
Definition canvas.hpp:978
@ hue_rotate
Definition canvas.hpp:980
float ds_offset_x
Definition canvas.hpp:990
float ds_blur
Definition canvas.hpp:992
Placement rectangle produced by fit_image_rect.
Definition canvas.hpp:1808
float w
Definition canvas.hpp:1808
float x
Definition canvas.hpp:1808
float h
Definition canvas.hpp:1808
float y
Definition canvas.hpp:1808
Definition canvas.hpp:1202
uint32_t tag
Definition canvas.hpp:1203
bool operator==(const FontFeature &) const =default
uint32_t value
Definition canvas.hpp:1204
An opaque reference to a compositing layer owned by the canvas.
Definition canvas.hpp:849
constexpr bool operator==(const LayerHandle &o) const
Definition canvas.hpp:851
constexpr bool operator!=(const LayerHandle &o) const
Definition canvas.hpp:852
Definition canvas.hpp:1404
Color fill_color
Definition canvas.hpp:1405
int feather_curve
0=gaussian, 1=linear
Definition canvas.hpp:1419
float bezier_cy
For quadratic_bezier: control point Y (normalized -1..1).
Definition canvas.hpp:1415
float arc_start
For arc (radians).
Definition canvas.hpp:1409
float arc_sweep
For arc (radians, default 270°).
Definition canvas.hpp:1410
float stroke_width
0 = filled, >0 = stroked
Definition canvas.hpp:1407
int feather_mode
Definition canvas.hpp:1420
float arm_width
For cross (fraction of half-size).
Definition canvas.hpp:1413
float bezier_cx
For quadratic_bezier: control point X (normalized -1..1).
Definition canvas.hpp:1414
float corner_radius
For rounded_rect.
Definition canvas.hpp:1408
Color stroke_color
Definition canvas.hpp:1406
float feather_sigma
Definition canvas.hpp:1418
float inner_radius
For ring (fraction of outer radius).
Definition canvas.hpp:1412
float squircle_power
For squircle (higher = more rectangular).
Definition canvas.hpp:1411
Latest-wins audio/vector payload exposed to an SkSL child shader.
Definition canvas.hpp:1661
std::uint32_t count
Definition canvas.hpp:1664
std::string name
Definition canvas.hpp:1662
bool live
Definition canvas.hpp:1665
std::uint32_t publish_sequence
Definition canvas.hpp:1667
float neutral
Definition canvas.hpp:1666
std::vector< float > samples
Definition canvas.hpp:1663
Definition canvas.hpp:1685
ShaderUniforms uniforms
Definition canvas.hpp:1686
std::shared_ptr< const ShaderDataTexture > data_texture
Definition canvas.hpp:1689
std::vector< NamedUniform > named_uniforms
Definition canvas.hpp:1687
std::optional< ShaderGeometry > geometry
Definition canvas.hpp:1690
float reach
Definition canvas.hpp:1688
Definition canvas.hpp:1670
std::string sdf_expression
Definition canvas.hpp:1676
SDFStyle style
Definition canvas.hpp:1672
std::uint32_t leaf_count
Definition canvas.hpp:1682
std::uint64_t topology_hash
Definition canvas.hpp:1677
SDFShape shape
Definition canvas.hpp:1671
std::vector< NamedUniform > leaf_uniforms
Definition canvas.hpp:1681
Full text metrics for layout and intrinsic sizing.
Definition canvas.hpp:1230
float actual_bounding_box_right
Distance from text origin to the right edge of the rendering bounding box.
Definition canvas.hpp:1241
float descent
Distance below baseline (positive value, ==fontBoundingBoxDescent).
Definition canvas.hpp:1233
float ascent
Distance above baseline (positive value, ==fontBoundingBoxAscent).
Definition canvas.hpp:1232
float width
Advance width of the text.
Definition canvas.hpp:1231
float line_height
Recommended line spacing (ascent + descent + leading).
Definition canvas.hpp:1234
float actual_bounding_box_descent
Distance from baseline to bottom of the rendering bounding box.
Definition canvas.hpp:1245
float actual_bounding_box_ascent
Distance from baseline to top of the rendering bounding box.
Definition canvas.hpp:1243
float actual_bounding_box_left
Distance from text origin to the left edge of the rendering bounding box.
Definition canvas.hpp:1239
float h
Definition canvas.hpp:75
float l
Definition canvas.hpp:75
float s
Definition canvas.hpp:75
float s
Definition canvas.hpp:74
float v
Definition canvas.hpp:74
float h
Definition canvas.hpp:74
float C
Definition canvas.hpp:76
float h
Definition canvas.hpp:76
float L
Definition canvas.hpp:76
static Color from_argb32(uint32_t argb)
Unpack from uint32_t ARGB.
Definition canvas.hpp:130
HSL to_hsl() const
Convert to HSL (h in [0,360), s and l in [0,1]).
uint8_t b8() const
Definition canvas.hpp:118
static Color decode(const uint8_t *data)
float r
Definition canvas.hpp:53
uint8_t a8() const
Definition canvas.hpp:119
static Color from_hsv(HSV hsv, float alpha=1.0f)
static constexpr Color rgba(float r, float g, float b, float a=1.0f)
Construct from float channels [0,1] (>1.0 allowed for HDR).
Definition canvas.hpp:56
Color with_hdr_intensity(float multiplier) const
Scale color intensity for HDR (channels can exceed 1.0).
Definition canvas.hpp:106
static Color hex(uint32_t rgb)
Construct from hex 0xRRGGBB (alpha = 1.0).
Definition canvas.hpp:66
uint8_t r8() const
Convert to 8-bit values for serialization/interop.
Definition canvas.hpp:116
Color with_alpha(float alpha) const
Return copy with different alpha.
Definition canvas.hpp:111
static Color from_oklch(OKLCH oklch, float alpha=1.0f)
uint32_t to_argb32() const
Pack to uint32_t ARGB (clamped to [0,255]) for Skia/platform interop.
Definition canvas.hpp:122
float b
Definition canvas.hpp:53
float a
Definition canvas.hpp:53
static constexpr Color rgba8(uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)
Construct from 8-bit channels [0,255] — convenience for legacy/hex code.
Definition canvas.hpp:61
HSV to_hsv() const
Convert to HSV (h in [0,360), s and v in [0,1]).
bool operator!=(const Color &other) const
Definition canvas.hpp:140
uint8_t g8() const
Definition canvas.hpp:117
bool operator==(const Color &other) const
Definition canvas.hpp:137
float g
Definition canvas.hpp:53
OKLCH to_oklch() const
Convert to OKLCH (perceptually uniform, CSS Color Level 4) L in [0,1], C in [0,~0....
void encode(uint8_t *out) const
Serialize to compact binary (4x float LE, 16 bytes).
static Color from_hsl(HSL hsl, float alpha=1.0f)
Color interpolate(const Color &other, float t) const
Interpolate between this color and other by factor t [0,1].
Definition canvas.hpp:98
Conic (sweep) gradient — colors sweep around a center point.
Definition canvas.hpp:162
float cx
Definition canvas.hpp:163
float start_angle
Starting angle in radians.
Definition canvas.hpp:164
float cy
Center point.
Definition canvas.hpp:163
std::vector< GradientStop > stops
Definition canvas.hpp:165
Definition gradient_interpolation.hpp:43
Definition canvas.hpp:145
float position
Definition canvas.hpp:146
Color color
Definition canvas.hpp:147
Definition canvas.hpp:150
float x0
Definition canvas.hpp:151
float x1
Definition canvas.hpp:151
std::vector< GradientStop > stops
Definition canvas.hpp:152
float y0
Definition canvas.hpp:151
float y1
Definition canvas.hpp:151
A 2D point.
Definition affine_transform.hpp:37
Definition canvas.hpp:155
float cx
Definition canvas.hpp:156
float focal_y
Focal point offset for spotlight effects.
Definition canvas.hpp:157
std::vector< GradientStop > stops
Definition canvas.hpp:158
float cy
Definition canvas.hpp:156
float radius
Definition canvas.hpp:156
float focal_x
Definition canvas.hpp:157
Axis-aligned rectangle in canvas coordinates.
Definition rectangle_list.hpp:28
Everything needed to stroke a path, as one value.
Definition path.hpp:67
LineCap cap
Definition path.hpp:69
float miter_limit
Definition path.hpp:71
float dash_phase
Definition path.hpp:77
float width
Definition path.hpp:68
std::vector< float > dash
Dash pattern: alternating on/off lengths in user units.
Definition path.hpp:76
LineJoin join
Definition path.hpp:70