Skip to content
FutureBlitz

    Install

    Import std.image.svg

    Svg

    std.image.svg

    class

    Public Class Svg

    An SVG's shapes, which Rasterize draws into an Image.

    Examples

    Local svg = Try Svg.Parse(r"""
        <svg xmlns="http://www.w3.org/2000/svg" width="20" height="10">
          <rect width="20" height="10" fill="#ff0000"/>
        </svg>
        """)
    Expect(svg.Width == 20.0 && svg.Height == 10.0)
    Local image = svg.Rasterize(2)
    Expect(image.Width == 40 && image[20, 10] == Color32.Red)

    std/image/svg.fb, line 28

    • Public Static Method Parse(text: String): Svg Throws IOError static method #

      The SVG in text. Throws an IOError of INVALID_DATA when the text isn't an SVG, or is one without a size, by its width and height or its viewBox.

    • Public Property Width: Double property #

      How wide it is, in pixels at 96 dots an inch.

    • Public Property Height: Double property #

      How tall it is, in pixels at 96 dots an inch.

    • @PanicsAtCaller Public Method Rasterize(scale: Double = 1): Image method #

      It drawn at scale, in an image of its size times the scale, each side rounded up. Panics when the scale isn't above 0, or the image would have more pixels than an Image holds.

    • @PanicsAtCaller Public Method Rasterize(width: Int, height: Int): Image method #

      It drawn as large as it fits in an image of width by height, in the middle of it. Panics when the size is one an Image can't be.

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