class MGraphicsSVG
SVG object handle
The function MGraphics.svg_render() can draw an SVG file directly from a filename. However, drawing from an instance of MGraphicsSVG can be more efficient, since the SVG file does not need to be reloaded. You can also use the functions MGraphicsSVG.mapcolor() and MGraphicsSVG.mapreset() to map the colors in the SVG source to a new color, which can be useful to render the same image multiple times with different states.
Example
// Using an SVG file in Max's search path
var my_svg = new MGraphicsSVG("icon.svg");
var disabled = false;
function paint() {
my_svg.mapreset();
if (disabled) {
my_svg.mapcolor(
[0, 0, 0, 1.0],
[0.5, 0.5, 0.5, 1.0]
)
}
mgraphics.svg_render(my_svg);
}
Constructors
new MGraphicsSVG(filename: string);
Create an SVG object whose colors can be remapped
Parameter | Type | Description |
---|---|---|
filename | string | Name of the SVG file, in Max's search path |
Methods
mapcolor
Remap source SVG color
mapcolor(source_color: [number, number, number, number], map_color: [number, number, number, number]): void;
Name | Type | Description |
---|---|---|
source_color | [number, number, number, number] | Origin color in RGBA format |
map_color | [number, number, number, number] | Destination color in RGBA format |
mapreset
Clear all color remappings
mapreset(): void;