Description
The CreateFromSvgSource
method is a static method of the Texture
class in the Sandbox API. It allows you to create a texture from an SVG (Scalable Vector Graphics) source string. This method provides options to specify the dimensions and color of the resulting texture.
Usage
To use the CreateFromSvgSource
method, you need to provide the SVG content as a string. Optionally, you can specify the width and height of the texture. If these are not provided, the method will use the default dimensions. You can also specify a color to apply to the SVG, which will override any colors defined in the SVG itself.
The method returns a Texture
object that can be used in rendering operations within the Sandbox environment.
Example
// Example of creating a texture from SVG source
string svgContent = "<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'><rect width='100' height='100' style='fill:blue'/></svg>";
int? width = 200; // Optional width
int? height = 200; // Optional height
Color? color = new Color(1.0f, 0.0f, 0.0f); // Optional color override
Texture texture = Texture.CreateFromSvgSource(svgContent, width, height, color);
// Use the texture in your game or application