core.svg.create_from_raw

Client

Creates a new SVG instance from a raw string


Syntax

local instance = core.svg.create_from_raw(
    raw,
    mipmaps = false
)

Only needed if you already know a mipmap-based filter is coming.

  • Use it when — the SVG is going to use NEAREST_MIPMAP, LINEAR_MIPMAP, or an ANISOTROPIC variant.
  • Before compressing — if both mipmaps and compression are needed, pass true here; self:compress cannot generate mipmaps, so this is the only opportunity.

Parameters

TypeNameDescription
stringrawRaw markup string
boolmipmapsDetermines whether to generate a mipmap chain for the underlying svg texture

Returns

TypeNameDescription
svginstanceCreated SVG instance

Examples

Create an SVG instance from raw markup
local entity = core.svg.create_from_raw([[
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
        <circle cx="50" cy="50" r="50"/>
    </svg>
]])
Create a procedural SVG and update it later
local entity = core.svg.create_from_raw([[
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
        <rect width="100" height="100" fill="red"/>
    </svg>
]])

entity:update([[
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
        <circle cx="50" cy="50" r="50" fill="blue"/>
    </svg>
]])

On this page