DgsCreateSVG: Difference between revisions
Jump to navigation
Jump to search
(→Syntax) |
m (→Example) |
||
Line 12: | Line 12: | ||
===Returns=== | ===Returns=== | ||
* Returns an [[svg]] if created successfully, ''false'' otherwise. | * Returns an [[svg]] if created successfully, ''false'' otherwise. | ||
==Example== | |||
<section name="Client" class="client" show="true"> | |||
<syntaxhighlight lang="lua"> | |||
loadstring(exports.dgs:dgsImportFunction())() | |||
local rawSvgData = [[ | |||
<svg viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg"> | |||
<circle cx="250" cy="250" r="250" fill="#0fc0fc" /> | |||
</svg> | |||
]] | |||
function init() | |||
-- Create an SVG containing a circle, using the raw XML data above | |||
svg = dgsCreateSVG(500, 500, rawSvgData) | |||
dgsCreateImage(0,0,500,500,svg,false) -- render the svg | |||
end | |||
addEventHandler("onClientResourceStart", resourceRoot, init) | |||
</syntaxhighlight></section> |
Revision as of 17:40, 25 February 2022
Creates an svg from size (blank document), filepath or raw data , similar to svgCreate.
Syntax
svg dgsCreateSVG(int width, int height,string pathORrawData)
Required Arguments
- width: Desired width, preferably power of two (16, 32, 64 etc.), maximum is 4096
- height : Desired height, preferably power of two (16, 32, 64 etc.), maximum is 4096
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.
- pathOrRawData: A string representing the path to your SVG file, or the raw SVG data
Returns
- Returns an svg if created successfully, false otherwise.
Example
Click to collapse [-]
Clientloadstring(exports.dgs:dgsImportFunction())() local rawSvgData = [[ <svg viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg"> <circle cx="250" cy="250" r="250" fill="#0fc0fc" /> </svg> ]] function init() -- Create an SVG containing a circle, using the raw XML data above svg = dgsCreateSVG(500, 500, rawSvgData) dgsCreateImage(0,0,500,500,svg,false) -- render the svg end addEventHandler("onClientResourceStart", resourceRoot, init)