DpiTexture
SVG texture for scalable UI.
DpiTexture stores SVG and creates raster variants for scalable UI. It is a resource for icons and other vector elements, rather than a general SVG document with a browser API. BaseScale sets base resolution; SetSizeOverride changes only logical size. Drawing can use variants for current CanvasItem oversampling.
Edit palettes through a copy: Duplicate the dictionary before editing, then SetColorMap with the changed copy. Mutating shared ColorMap in place does not refresh the internal palette. PremultAlpha requires matching material blending. For plugins, see SVG preparation and import.
Source, scale, palette and flags are stored with the resource; logical size override is not saved. Resource operations and pixel values were checked in Windows Forward+/Vulkan. Drawing at different oversampling levels, manual DPI/theme switching and visual edge acceptance were not established here.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
DpiTextureConstructor
public DpiTexture();Creates an empty resource: source is empty, BaseScale and Saturation are 1, flags are disabled and the palette is empty. Set valid SVG through SetSource before requesting dimensions, an image or RID. Construction alone does not produce a usable icon.
Properties6
BaseScaleProperty
public float BaseScale { get; set; }Base SVG rasterization multiplier; defaults to 1. A value of 2 produces twice as many pixels per axis and changes the natural texture size. Supply a finite positive value. The inspector hint 0.01…10 does not clamp the setter to that range. Changing it invalidates caches.
ColorMapProperty
public Reckfell.Collections.Dictionary ColorMap { get; set; }Color → Color replacement dictionary; empty by default. Do not edit the returned dictionary in place: stored contents can change without refreshing the internal palette or image. Duplicate the dictionary first, edit the copy, then assign it back. The setter skips dictionaries with equal contents. This is not an automatic editor theme.
FixAlphaBorderProperty
public bool FixAlphaBorder { get; set; }Defaults to false. Before GPU upload, fixes RGB in transparent edge pixels using neighboring colors. It can reduce dark fringes under filtering; it does not add an opaque outline or guarantee repair of every image. Changing it invalidates caches.
PremultAlphaProperty
public bool PremultAlpha { get; set; }Defaults to false. Rasterization multiplies RGB by alpha while preserving alpha itself. Use matching blending, such as CanvasItemMaterial.BlendModeEnum.PremultAlpha or blend_premul_alpha in a canvas_item shader. This transforms pixel data; it does not enable material transparency.
SaturationProperty
public float Saturation { get; set; }Saturation multiplier; defaults to 1, while 0 produces grayscale. The setter does not clamp to the inspector hint range 0…1. Use finite values in 0…1 for ordinary UI. Changing it invalidates image caches.
_SourceProperty
public string _Source { get; set; }Internal stored SVG-source property connected to SetSource/GetSource. Use those methods in ordinary code. It contains text, not a URI; changing it causes the same cache invalidation. This is not a separate second image source.
Methods15
CreateFromStringDpiTexture
public static DpiTexture CreateFromString(string source, float scale = 1f, float saturation = 1f, Reckfell.Collections.Dictionary colorMap = null);Creates a separate DpiTexture and sets SVG, scale, saturation and palette. This is not SVG syntax validation: rasterization is lazy when an image, dimensions or RID are requested. The factory returns no Error. Supply valid SVG and a finite positive scale.
| Name | Type | Default |
|---|---|---|
source | string | — |
scale | float | 1f |
saturation | float | 1f |
colorMap | Reckfell.Collections.Dictionary | null |
sourceValid SVG text, not a file path.
scaleFinite positive base scale; defaults to 1.
saturationFinite saturation multiplier; defaults to 1.
colorMapOptional Color → Color dictionary; null uses an empty one. Do not mutate the shared dictionary after assignment.
DpiTextureNew resource; the caller owns its reference. Construction does not prove SVG validity.
GetBaseScalefloat
public float GetBaseScale();Returns BaseScale. Base SVG rasterization multiplier; defaults to 1. A value of 2 produces twice as many pixels per axis and changes the natural texture size. Supply a finite positive value. The inspector hint 0.01…10 does not clamp the setter to that range. Changing it invalidates caches.
floatCurrent base multiplier; defaults to 1.
GetColorMapReckfell.Collections.Dictionary
public Reckfell.Collections.Dictionary GetColorMap();Returns ColorMap. Color → Color replacement dictionary; empty by default. Do not edit the returned dictionary in place: stored contents can change without refreshing the internal palette or image. Duplicate the dictionary first, edit the copy, then assign it back. The setter skips dictionaries with equal contents. This is not an automatic editor theme.
Reckfell.Collections.DictionaryShared replacement dictionary; copy before editing.
GetFixAlphaBorderbool
public bool GetFixAlphaBorder();Returns FixAlphaBorder. Defaults to false. Before GPU upload, fixes RGB in transparent edge pixels using neighboring colors. It can reduce dark fringes under filtering; it does not add an opaque outline or guarantee repair of every image. Changing it invalidates caches.
boolCurrent alpha-edge-fixing state.
GetPremultAlphabool
public bool GetPremultAlpha();Returns PremultAlpha. Defaults to false. Rasterization multiplies RGB by alpha while preserving alpha itself. Use matching blending, such as CanvasItemMaterial.BlendModeEnum.PremultAlpha or blend_premul_alpha in a canvas_item shader. This transforms pixel data; it does not enable material transparency.
boolCurrent RGB-by-alpha multiplication state.
GetSaturationfloat
public float GetSaturation();Returns Saturation. Saturation multiplier; defaults to 1, while 0 produces grayscale. The setter does not clamp to the inspector hint range 0…1. Use finite values in 0…1 for ordinary UI. Changing it invalidates image caches.
floatCurrent saturation multiplier; defaults to 1.
GetScaledRidRid
public Rid GetScaledRid();Returns the RID variant for the currently drawn CanvasItem oversampling. Outside drawing, oversampling = 0 falls back to base scale 1. The resource owns the handle: do not free it manually or treat it as stable after texture changes. This method does not set window or editor scale.
RidBorrowed RID for the current variant, or the base RID outside drawing.
GetSourcestring
public string GetSource();Returns stored SVG text rather than a file path or raster pixels. Reading the string does not prove rasterization succeeded.
stringStored SVG string; it can be empty on a new resource.
SetBaseScalevoid
public void SetBaseScale(float baseScale);Sets BaseScale. Base SVG rasterization multiplier; defaults to 1. A value of 2 produces twice as many pixels per axis and changes the natural texture size. Supply a finite positive value. The inspector hint 0.01…10 does not clamp the setter to that range. Changing it invalidates caches.
| Name | Type | Default |
|---|---|---|
baseScale | float | — |
baseScaleFinite positive rasterization multiplier.
SetColorMapvoid
public void SetColorMap(Reckfell.Collections.Dictionary colorMap);Sets ColorMap. Color → Color replacement dictionary; empty by default. Do not edit the returned dictionary in place: stored contents can change without refreshing the internal palette or image. Duplicate the dictionary first, edit the copy, then assign it back. The setter skips dictionaries with equal contents. This is not an automatic editor theme.
| Name | Type | Default |
|---|---|---|
colorMap | Reckfell.Collections.Dictionary | — |
colorMapColor → Color dictionary; edit a separate copy before assignment.
SetFixAlphaBordervoid
public void SetFixAlphaBorder(bool fixAlphaBorder);Sets FixAlphaBorder. Defaults to false. Before GPU upload, fixes RGB in transparent edge pixels using neighboring colors. It can reduce dark fringes under filtering; it does not add an opaque outline or guarantee repair of every image. Changing it invalidates caches.
| Name | Type | Default |
|---|---|---|
fixAlphaBorder | bool | — |
fixAlphaBorderEnable RGB fixing at transparent edges.
SetPremultAlphavoid
public void SetPremultAlpha(bool premultAlpha);Sets PremultAlpha. Defaults to false. Rasterization multiplies RGB by alpha while preserving alpha itself. Use matching blending, such as CanvasItemMaterial.BlendModeEnum.PremultAlpha or blend_premul_alpha in a canvas_item shader. This transforms pixel data; it does not enable material transparency.
| Name | Type | Default |
|---|---|---|
premultAlpha | bool | — |
premultAlphaMultiply RGB by alpha during rasterization.
SetSaturationvoid
public void SetSaturation(float saturation);Sets Saturation. Saturation multiplier; defaults to 1, while 0 produces grayscale. The setter does not clamp to the inspector hint range 0…1. Use finite values in 0…1 for ordinary UI. Changing it invalidates image caches.
| Name | Type | Default |
|---|---|---|
saturation | float | — |
saturationFinite multiplier; use 0…1 for ordinary UI.
SetSizeOverridevoid
public void SetSizeOverride(Vector2I size);Sets logical dimensions without rerasterizing SVG. A 16×16 SVG at BaseScale = 2 produces a 32×32 image; overriding to 48×24 changes GetWidth/GetHeight to 48×24 while GetImage remains 32×32. Zero restores the natural size on that axis; Vector2I.Zero clears the override. Supply nonnegative components. The override is not stored as a resource property. Use BaseScale to increase resolution.
| Name | Type | Default |
|---|---|---|
size | Vector2I | — |
sizeNonnegative logical dimensions; 0 restores the natural size on that axis.
SetSourcevoid
public void SetSource(string source);Replaces SVG source and invalidates image, RID and alpha-test caches; an identical string causes no update. Supply SVG text, not a asset:// path. This void method returns no syntax error; failure can appear during subsequent rasterization.
| Name | Type | Default |
|---|---|---|
source | string | — |
sourceValid SVG source text.