Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::view::CanvasDrawCmd Struct Reference

A draw command recorded from JS for replay in paint(). More...

#include <canvas_widget.hpp>

Public Types

enum class  Type {
  fill_rect , stroke_rect , fill_rounded_rect , stroke_rounded_rect ,
  fill_circle , stroke_circle , stroke_line , stroke_arc ,
  fill_text , set_font , set_text_align , set_text_baseline ,
  stroke_text , set_font_full , set_fill_color , set_stroke_color ,
  set_line_width , set_line_cap , set_line_join , set_global_alpha ,
  set_blend_mode , set_fill_gradient_linear , set_fill_gradient_radial , clear_fill_gradient ,
  set_fill_gradient_radial_two_circles , set_fill_gradient_conic , set_stroke_gradient_linear , set_stroke_gradient_radial ,
  set_stroke_gradient_radial_two_circles , set_stroke_gradient_conic , clear_stroke_gradient , set_fill_pattern ,
  set_stroke_pattern , begin_path , move_to , line_to ,
  quad_to , cubic_to , close_path , fill_path ,
  stroke_path , clip_path , path_arc , path_arc_to ,
  path_ellipse , path_round_rect , save , restore ,
  translate , scale , rotate , clip_rect ,
  set_transform , clip , draw_image , draw_sdf ,
  set_line_dash , put_image_data , set_shadow_color , set_shadow_blur ,
  set_shadow_offset_x , set_shadow_offset_y , set_miter_limit , set_image_smoothing ,
  set_direction , set_filter , clear , clear_rect ,
  replay_group
}

Public Attributes

Type type = Type::clear
float x = 0
float y = 0
float w = 0
float h = 0
float x2 = 0
float y2 = 0
float x3 = 0
float y3 = 0
canvas::Color color {255, 255, 255, 255}
float extra = 0
std::string text
std::string shader_sksl
std::vector< canvas::Canvas::NamedUniform > shader_uniforms
std::optional< canvas::Canvas::ShaderGeometry > shader_geometry
int int_val = 0
std::vector< canvas::Color > gradient_colors
std::vector< float > gradient_positions
bool use_active_style = false
 When true on a fill_rect / stroke_rect cmd, the paint loop must NOT call set_fill_color / set_stroke_color from color before drawing.
bool has_source_rect = false
 When true on a draw_image cmd, x2/y2/x3/y3 carry the source rect (sx, sy, sw, sh) for the 9-arg ctx.drawImage(img, sx,sy,sw,sh, dx,dy,dw,dh) form.

Detailed Description

A draw command recorded from JS for replay in paint().

Maps to CanvasRenderingContext2D methods.

Member Enumeration Documentation

◆ Type

Enumerator
fill_rect 
stroke_rect 
fill_rounded_rect 
stroke_rounded_rect 
fill_circle 
stroke_circle 
stroke_line 
stroke_arc 
fill_text 
set_font 
set_text_align 
set_text_baseline 
stroke_text 
set_font_full 
set_fill_color 
set_stroke_color 
set_line_width 
set_line_cap 
set_line_join 
set_global_alpha 
set_blend_mode 
set_fill_gradient_linear 
set_fill_gradient_radial 
clear_fill_gradient 
set_fill_gradient_radial_two_circles 

Canvas2D ctx.createRadialGradient(x0,y0,r0,x1,y1,r1) two-circle form.

Inner circle (x0,y0,r0) packed as (x, y, extra), outer circle (x1,y1,r1) packed as (x2, y2, w). Routes to set_fill_gradient_radial_two_circles (Skia: MakeTwoPointConical; CG: full CGContextDrawRadialGradient with both circles).

set_fill_gradient_conic 
set_stroke_gradient_linear 
set_stroke_gradient_radial 
set_stroke_gradient_radial_two_circles 
set_stroke_gradient_conic 
clear_stroke_gradient 
set_fill_pattern 
set_stroke_pattern 
begin_path 
move_to 
line_to 
quad_to 
cubic_to 
close_path 
fill_path 
stroke_path 
clip_path 
path_arc 
path_arc_to 
path_ellipse 
path_round_rect 
save 
restore 
translate 
scale 
rotate 
clip_rect 
set_transform 
clip 
draw_image 
draw_sdf 
set_line_dash 

pattern in gradient_positions, phase in extra

put_image_data 

RGBA pixels in text (binary), int_val=width, x2=height (as int).

set_shadow_color 

color in color

set_shadow_blur 

blur (px) in extra

set_shadow_offset_x 

dx (px) in extra

set_shadow_offset_y 

dy (px) in extra

set_miter_limit 

limit in extra

set_image_smoothing 

enabled in int_val (0/1), quality in extra (0=low,1=med,2=high)

set_direction 
set_filter 
clear 
clear_rect 
replay_group 

Member Data Documentation

◆ color

canvas::Color pulp::view::CanvasDrawCmd::color {255, 255, 255, 255}

◆ extra

float pulp::view::CanvasDrawCmd::extra = 0

◆ gradient_colors

std::vector<canvas::Color> pulp::view::CanvasDrawCmd::gradient_colors

◆ gradient_positions

std::vector<float> pulp::view::CanvasDrawCmd::gradient_positions

◆ h

float pulp::view::CanvasDrawCmd::h = 0

◆ has_source_rect

bool pulp::view::CanvasDrawCmd::has_source_rect = false

When true on a draw_image cmd, x2/y2/x3/y3 carry the source rect (sx, sy, sw, sh) for the 9-arg ctx.drawImage(img, sx,sy,sw,sh, dx,dy,dw,dh) form.

The renderer routes through Canvas::draw_image_from_*_rect so the source sub-rectangle of the decoded image maps onto the destination rect (sprite-sheet slicing). Without the flag the dst-only path runs.

◆ int_val

int pulp::view::CanvasDrawCmd::int_val = 0

◆ shader_geometry

std::optional<canvas::Canvas::ShaderGeometry> pulp::view::CanvasDrawCmd::shader_geometry

◆ shader_sksl

std::string pulp::view::CanvasDrawCmd::shader_sksl

◆ shader_uniforms

std::vector<canvas::Canvas::NamedUniform> pulp::view::CanvasDrawCmd::shader_uniforms

◆ text

std::string pulp::view::CanvasDrawCmd::text

◆ type

Type pulp::view::CanvasDrawCmd::type = Type::clear

◆ use_active_style

bool pulp::view::CanvasDrawCmd::use_active_style = false

When true on a fill_rect / stroke_rect cmd, the paint loop must NOT call set_fill_color / set_stroke_color from color before drawing.

The most recent set_fill_color, set_stroke_color, or set_fill_gradient_* on the underlying canvas stays active. Bridge sets this when the JS caller omitted the color arg (e.g. canvasRect(id, x, y, w, h) — Canvas2D ctx.fillRect() shim that relies on a previously-set ctx.fillStyle, including gradients).

◆ w

float pulp::view::CanvasDrawCmd::w = 0

◆ x

float pulp::view::CanvasDrawCmd::x = 0

◆ x2

float pulp::view::CanvasDrawCmd::x2 = 0

◆ x3

float pulp::view::CanvasDrawCmd::x3 = 0

◆ y

float pulp::view::CanvasDrawCmd::y = 0

◆ y2

float pulp::view::CanvasDrawCmd::y2 = 0

◆ y3

float pulp::view::CanvasDrawCmd::y3 = 0

The documentation for this struct was generated from the following file: