std1.0.0-beta-7 SafeC docs

std :: gui::gui_canvas

Struct std::GuiCanvas

#include <std/gui/gui_canvas.h> source

struct GuiCanvas {
    ?&unsigned char px;
    int width;
    int height;
    int stride;
    struct GuiCanvasState st;
    struct Vec<struct GuiCanvasState> saved;
    struct GuiPath path;
    struct Vec<struct GuiEdge> edges;
    struct Vec<float> acc;
    struct Vec<float> xs;
    struct Vec<int> sorted;
    struct Vec<int> active;
    struct Vec<float> fpts;
    struct Vec<int> fcont;
    struct Vec<float> dpts;
    struct Vec<int> dcont;
    struct Vec<float> spts;
    struct Vec<int> scont;
    struct Vec<float> row;
    struct Vec<float> lut;
    struct GuiPath scratchPath;
}

Fields

§?&unsigned char pxsource

target pixels: premultiplied RGBA8888

§int widthsource
§int heightsource
§int stridesource

bytes per row

§struct Vec<struct GuiCanvasState> savedsource

the save() stack

§struct GuiPath pathsource

the current path (begin_path/move_to/...)

§struct Vec<struct GuiEdge> edgessource

scratch buffers, kept between calls to avoid reallocating

§struct Vec<float> accsource
§struct Vec<float> xssource
§struct Vec<int> sortedsource
§struct Vec<int> activesource
§struct Vec<float> fptssource

flattened polylines: x,y pairs ...

§struct Vec<int> fcontsource

... and (first point, point count, closed) triples

§struct Vec<float> dptssource

dashed polylines

§struct Vec<int> dcontsource
§struct Vec<float> sptssource

stroke outline polygons

§struct Vec<int> scontsource
§struct Vec<float> rowsource

one row of coverage

§struct Vec<float> lutsource

gradient colors (256 premultiplied RGBA)

§struct GuiPath scratchPathsource

Methods

§static struct GuiCanvas for_window(&GuiWindow win)source · definition
§static struct GuiCanvas for_image(&GuiImage img)source · definition

Draws into an image (premultiplying its pixels first if they're straight-alpha, see GuiImage.premultiplied).

§static struct GuiCanvas for_pixels(&unsigned char px, int width, int height, int stride)source · definition

Any premultiplied RGBA8888 buffer.

§void retarget_window(&GuiWindow win)source · definition

Point at the window's (possibly reallocated) buffer again. Resets the clip if the size changed.

§void reset()source · definition

Back to the initial state (identity transform, black fill, no clip, empty save stack and path).

§void drop()source · definition
§void free() consumesource · definition

= drop()

§void save()source · definition
§void restore()source · definition
§void translate(float tx, float ty)source · definition
§void scale(float sx, float sy)source · definition
§void rotate(float radians)source · definition
§void transform(struct GuiMatrix m)source · definition

Pre-multiplies the current transform by m (m applies first).

§void set_transform(struct GuiMatrix m)source · definition
§void reset_transform()source · definition
§struct GuiMatrix get_transform() constsource · definition
§void set_fill_color(struct GuiColor c)source · definition
§void set_fill_paint(const &GuiPaint p)source · definition
§void set_stroke_color(struct GuiColor c)source · definition
§void set_stroke_paint(const &GuiPaint p)source · definition
§void set_line_width(float w)source · definition
§void set_line_cap(int lineCap)source · definition
§void set_line_join(int lineJoin)source · definition
§void set_miter_limit(float limit)source · definition
§void set_dash([]const float lengths, float offset)source · definition

Alternating on/off lengths (n <= GUI_DASH_MAX; an odd count repeats once more, as in SVG); n = 0 turns dashing off.

§void set_global_alpha(float a)source · definition
§void set_blend_mode(int mode)source · definition
§void set_fill_rule(int rule)source · definition
§void set_image_filter(int filter)source · definition
§void set_anti_alias(int on)source · definition

0 = aliased (hard pixel edges: coverage rounded to 0 or 1).

§void clip_rect(float x, float y, float w, float h)source · definition
§void clip_path(const &GuiPath p)source · definition
§void clip()source · definition

with the current path

§void reset_clip()source · definition
§struct GuiRect clip_bounds() constsource · definition

The clip's device-space bounds.

§void begin_path()source · definition
§void move_to(float x, float y)source · definition
§void line_to(float x, float y)source · definition
§void quad_to(float cx, float cy, float x, float y)source · definition
§void cubic_to(float c1x, float c1y, float c2x, float c2y, float x, float y)source · definition
§void arc(float cx, float cy, float r, float a0, float a1, int ccw)source · definition
§void arc_to(float x1, float y1, float x2, float y2, float r)source · definition
§void rect(float x, float y, float w, float h)source · definition
§void rounded_rect(float x, float y, float w, float h, float r)source · definition
§void ellipse(float cx, float cy, float rx, float ry)source · definition
§void close_path()source · definition
§void fill()source · definition
§void stroke()source · definition
§void fill_path(const &GuiPath p)source · definition
§void stroke_path(const &GuiPath p)source · definition
§void fill_rect(float x, float y, float w, float h)source · definition
§void stroke_rect(float x, float y, float w, float h)source · definition
§void clear_rect(float x, float y, float w, float h)source · definition

Makes the rectangle transparent (within the clip).

§void clear(struct GuiColor c)source · definition

Fills the whole target with 'c', ignoring transform, clip and blend.

§void fill_rounded_rect(float x, float y, float w, float h, float r)source · definition
§void stroke_rounded_rect(float x, float y, float w, float h, float r)source · definition
§void fill_circle(float cx, float cy, float r)source · definition
§void stroke_circle(float cx, float cy, float r)source · definition
§void fill_ellipse(float cx, float cy, float rx, float ry)source · definition
§void draw_line(float x0, float y0, float x1, float y1)source · definition
§void stroke_to_path(const &GuiPath p, &GuiPath out)source · definition

The filled outline of stroking 'p' with the current line settings, in user space — e.g. to hit-test or clip to a stroke.

§void draw_image(const &GuiImage img, float x, float y)source · definition
§void draw_image_scaled(const &GuiImage img, float x, float y, float w, float h)source · definition
§void draw_image_rect( const &GuiImage img, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh, )source · definition

The (sx,sy,sw,sh) part of the image into (dx,dy,dw,dh).

§void set_font(const &GuiTypeface face, float sizePx)source · definition
§void set_font_size(float sizePx)source · definition
§void set_text_align(int align)source · definition
§void set_text_baseline(int baseline)source · definition
§float fill_text(const &char text, float x, float y)source · definition

Draws one line of UTF-8 text with the fill paint at (x, y) (see set_text_baseline/set_text_align). Returns its advance width.

§float fill_text_n([]const char text, float x, float y)source · definition
§float measure_text(const &char text) constsource · definition
§void fill_text_layout(const &GuiTextLayout layout, float x, float y)source · definition

Draws a built layout with its top-left at (x, y).

§struct GuiColor get_pixel(int x, int y) constsource · definition

The straight-alpha color at device pixel (x, y) (transparent if out of bounds).