|
|
|
|
|
Modifying an SVG image (XML functions)
SVG (Scalable Vector Graphics) is a vector image format: this means that the image is drawn on demand and is not "fixed".. The advantage of these images is that they never pixelate. SVG is an XML-based format: in WLanguage, it is very easy to modify the properties and attributes of these images. The advantage of modifying an SVG image in the code is that the same source image can be used in several themes/colors. To modify an SVG image in the code: - Load an SVG image:
To open and edit an SVG image in the code, simply use the xmlDocument type:
MySVG is xmlDocument  // Opens the original document MySVG = XMLOpen(...  "C:\[..]\Badge-SVG.svg", fromFile)
- Modify the image:
To modify the image, simply access the properties (attributes) or values to be modified.
// Changes the color // - of the borders MySVG.svg.path..Attribute["fill"] = ... Â "#9C27B0" // - text MonSVG.svg.text..Attribute["fill"] = ... Â "#E91E63" Â // Changes the text MonSVG.svg.text..Text = "Great!"
- Save the modified image:
The string that corresponds to the modified XML document must be rebuilt. The SVG content can be saved to a file or displayed directly in an Image control.
// Rebuilds the SVG image // to display it in the Image control IMG_Preview = XMLBuildString(MySVG)
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|