Skip to content
canvas

canvas

Mojo package 🡭

canvas

Modules

  • aa_area: Signed-area anti-aliasing for nonzero path and stroke fills.
  • aa_crossing: Supersampled scanline coverage for anti-aliased path and polygon fills.
  • batch: Rendering a Canvas batch: the primitives recorded between begin_batch and end_batch, drawn in one banded pass.
  • batch_ops: What a Canvas batch records: the op, the batch holding them, and the constructors for the ops with no geometry to gather.
  • blend: Blend and composite modes: what a drawing operation does to the pixels already there, beyond the source-over every primitive uses by default.
  • blur: Gaussian blur, approximated by three successive box blurs, and draw_shadowed, the drop-shadow / glow composite built on it.
  • bounds: A DrawTarget that draws nothing and remembers where the ink would have gone: BoundsTarget.
  • buffer: The pixel raster buffer at the core of the canvas package.
  • color: RGBA color type and basic blending.
  • compose: Compositing one canvas onto another: everything else in this package draws shapes into a buffer, and this draws a buffer into a buffer.
  • fill_rule: Fill rules: how fill_polygon/fill_path and their gradient variants decide which regions of a self-intersecting or multi-sub-path shape count as inside.
  • geometry: Geometric types shared by the primitives that take more than a single (x, y) pair.
  • gradient: Color gradients: LinearGradient, RadialGradient and ConicGradient, consumed by the gradient fills in canvas.shapes.rects (fill_rect_gradient, fill_rect_radial_gradient) and path.mojo (fill_path_gradient, fill_path_radial_gradient, fill_path_conic_gradient and their _aa variants). Those are the only gradient-aware fills; circle/ellipse/polygon variants aren’t built, and ConicGradient has no rect fill of its own.
  • machine: What the CPU this process is running on looks like, for the few thresholds that depend on it.
  • mask: Alpha masks: a per-pixel coverage, 0-255, that a fill is painted through, a layer is composited through, or drawing is clipped to – the shape of an operation separated from how the shape was made.
  • named_colors: Named colors: the CSS Color Module Level 3 / X11 “extended color keywords” list (https://www.w3.org/TR/css-color-3/#svg-color) plus REBECCAPURPLE (Level 4), as Color constants, so a caller can write CORNFLOWERBLUE instead of Color(100, 149, 237). Each name is the CSS keyword uppercased with no separators (CORNFLOWERBLUE, not CORNFLOWER_BLUE), so it matches the spec and any color picker directly. Both CSS spellings of the gray names (GRAY/GREY, DARKGRAY/DARKGREY, …) are included with identical values.
  • path: A general path type: move/line/quadratic-curve/cubic-curve/arc-to/ close, built up through chained calls, then flattened into straight- line segments and handed to canvas.shapes’ polyline/polygon/fill machinery.
  • pattern: Raster patterns as a fill source: PatternSource, a ColorSource (gradient.mojo) that samples a small Canvas tile instead of projecting onto a gradient axis. Consumed by fill_path_pattern/ fill_path_pattern_aa (path.mojo) and fill_rect_pattern (canvas.shapes.rects), the pattern-fill counterparts of the gradient fills those modules already carry.
  • resize: Box-filter downsampling: shrink a Canvas by an integer factor, each output pixel the average of the corresponding factor x factor block of input pixels.
  • workers: Helpers for splitting parallel passes into row bands, and the one place the library runs a band as a task.

Packages