Skip to main content

DPITexture

Experimental: This class may be changed or removed in future versions.

Inherits: Texture2D < Texture < Resource < RefCounted < Object

An automatically scalable Texture2D based on an SVG image.

Description

An automatically scalable Texture2D based on an SVG image. DPITexture\ s are used to automatically re-rasterize icons and other texture based UI theme elements to match viewport scale and font oversampling. See also ProjectSettings.display/window/stretch/mode ("canvas_items" mode) and Viewport.oversampling_override.

Properties

floatbase_scale1.0
Dictionarycolor_map{}
boolresource_local_to_scenefalse (overrides Resource.resource_local_to_scene)
floatsaturation1.0

Methods

DPITexturecreate_from_string\ (\ source: String, scale: float = 1.0, saturation: float = 1.0, color_map: Dictionary = {}\ ) static
RIDget_scaled_rid\ (\ ) const
Stringget_source\ (\ ) const
voidset_size_override\ (\ size: Vector2i\ )
voidset_source\ (\ source: String\ )

Property Descriptions

float base_scale = 1.0 🔗

  • void set_base_scale\ (\ value: float\ )
  • float get_base_scale\ (\ )

Texture scale. 1.0 is the original SVG size. Higher values result in a larger image.


Dictionary color_map = {} 🔗

If set, remaps texture colors according to Color-Color map.


float saturation = 1.0 🔗

  • void set_saturation\ (\ value: float\ )
  • float get_saturation\ (\ )

Overrides texture saturation.


Method Descriptions

DPITexture create_from_string\ (\ source: String, scale: float = 1.0, saturation: float = 1.0, color_map: Dictionary = {}\ ) static 🔗

Creates a new DPITexture and initializes it by allocating and setting the SVG data from string.


RID get_scaled_rid\ (\ ) const 🔗

Returns the RID of the texture rasterized to match the oversampling of the currently drawn canvas item.


String get_source\ (\ ) const 🔗

Returns SVG source code.


void set_size_override\ (\ size: Vector2i\ ) 🔗

Resizes the texture to the specified dimensions.


void set_source\ (\ source: String\ ) 🔗

Sets SVG source code.