Skip to content
FutureBlitz

    Install

    Import std.image.canvas

    std.image.canvas

    Canvas: drawing on an Image, through the runtime's fb_image_ functions. A pixel is the square from its (x, y) to (x + 1, y + 1), so the line along y = 5.5 from x = 0 covers row 5's pixels to their middles both ways. Each Fill fills a region by the nonzero rule, FillText a font's glyphs, and each Stroke what its line covers, LineWidth wide, with its Join at each corner and its Cap at each end, all drawn over the image by their color's alpha: by the exact part of each pixel the region covers, antialiased, or wholly where it holds the pixel's center.

    std/image/canvas.fb

    Types

    LineCap enum

    Public Enum LineCap

    How a stroke's open ends end.

    std/image/canvas.fb, line 35

    • BUTT enum member #

      Where the line does.

    • ROUND enum member #

      In a half circle.

    • SQUARE enum member #

      Half the line's width past where the line does.

    LineJoin enum

    Public Enum LineJoin

    How a stroke's corners are filled on their outside.

    std/image/canvas.fb, line 45

    • MITER enum member #

      To where its sides' edges meet, unless that's more than MiterLimit times the width from the inside corner, when it's a bevel.

    • ROUND enum member #

      In the circle of the line's width.

    • BEVEL enum member #

      Cut straight across.

    Canvas class

    Public Class Canvas

    What draws on an Image: lines, shapes, paths, images, and text, filled or stroked, in a color or a gradient.

    std/image/canvas.fb, line 57

    • Public New(image: Image) constructor #

      A canvas for drawing on image, antialiased, with lines 1 wide, butt caps, and miter joins up to 4 times the width, as SVG's are.

    • Public Property Image: Image property #

      The image it draws on.

    • Public Property Antialias: Bool property #

      Whether it draws each pixel by the part of it what's drawn covers, or else wholly when what's drawn holds its center.

    • @PanicsAtCaller Public Property LineWidth: Float property #

      How wide a stroke is. Panics when it's given one that's negative or not finite.

    • Public Property Cap: LineCap property #

      How a stroke's ends are drawn.

    • Public Property Join: LineJoin property #

      How a stroke's corners are filled on their outside.

    • @PanicsAtCaller Public Property MiterLimit: Float property #

      How far a miter goes, from the inside corner, times the line's width, before it's a bevel. Panics when it's given one below 1 or not finite.

    • @PanicsAtCaller Public Method FillRect(rect: Rect, color: Color32) method #

      Fills the rectangle. Panics when its corner or size isn't finite, its size is negative, or its far corner is past what a Float holds.

    • @PanicsAtCaller Public Method StrokeRect(rect: Rect, color: Color32) method #

      Strokes the rectangle's edges, closed. Panics as FillRect does.

    • @PanicsAtCaller Public Method StrokeLine(a: Vec2, b: Vec2, color: Color32) method #

      Strokes the line from a to b. Panics when either isn't finite.

    • @PanicsAtCaller Public Method StrokePolyline(points: Vec2[], color: Color32) method #

      Strokes the line through the points, open. Panics when one isn't finite.

    • @PanicsAtCaller Public Method StrokePolygon(points: Vec2[], color: Color32) method #

      Strokes the polygon's edges, closed from its last point back to its first. Panics when a point isn't finite.

    • @PanicsAtCaller Public Method FillPolygon(points: Vec2[], color: Color32) method #

      Fills the polygon, by the nonzero rule. Panics when a point isn't finite.

    • @PanicsAtCaller Public Method FillPolygon(rings: Vec2[][], color: Color32) method #

      Fills the region of rings, each closed, by the nonzero rule, as std.math's polygons are, so a ring the other way around from the one it's in is a hole. Panics when a point isn't finite.

    • @PanicsAtCaller Public Method FillCircle(center: Vec2, radius: Float, color: Color32) method #

      Fills the circle. Panics when its center or radius isn't finite, or its radius is negative.

    • @PanicsAtCaller Public Method StrokeCircle(center: Vec2, radius: Float, color: Color32) method #

      Strokes the circle. Panics as FillCircle does.

    • @PanicsAtCaller Public Method FillEllipse(center: Vec2, radii: Vec2, color: Color32) method #

      Fills the ellipse of the radii across and down. Panics when its center or radii aren't finite, or a radius is negative.

    • @PanicsAtCaller Public Method StrokeEllipse(center: Vec2, radii: Vec2, color: Color32) method #

      Strokes the ellipse, its outline LineWidth wide. Panics as FillEllipse does.

    • @PanicsAtCaller Public Method FillText(text: String, font: Font, size: Float, position: Vec2, color: Color32) method #

      Fills the text in the font at size pixels an em, its first line's baseline from position, as one region: each glyph after the last's advance and the kerning between them, unrounded, each line feed a line's height down, and a code point the font has no glyph for its .notdef. Panics when the size isn't finite or is negative, or the position isn't finite.

    Report an issue with this page or with FutureBlitz on GitHub.