aboutsummaryrefslogtreecommitdiff
path: root/gamemode/utility/svg
diff options
context:
space:
mode:
Diffstat (limited to 'gamemode/utility/svg')
-rw-r--r--gamemode/utility/svg/cl_svg.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/gamemode/utility/svg/cl_svg.lua b/gamemode/utility/svg/cl_svg.lua
index 6a17f0a..7fa53d5 100644
--- a/gamemode/utility/svg/cl_svg.lua
+++ b/gamemode/utility/svg/cl_svg.lua
@@ -100,9 +100,32 @@ hook.Add("Think","process_svg_materials",function()
for i = k,#toprocess do
toprocess[i] = toprocess[i + 1]
end
+ if v[3] then
+ v[3]()
+ end
end
end)
+function svg.SetMaterialSVG(what,spath,background,foreground)
+ local html = vgui.Create("DHTML")
+ local svgdata = readsvg(spath)
+ local bgf = ""
+ local fgf = ""
+ if background ~= nil then
+ bgf = string.format("svg{background:%s}",background)
+ end
+ if foreground ~= nil then
+ fgf = string.format("svg path{fill:%s}",foreground)
+ end
+ html:SetHTML(string.format([[
+<style>%s%sbody{overflow:hidden}</style><body>%s</body>
+]],background and bgf or "",foreground and fgf or "",svgdata))
+ local mat = {}
+ toprocess[#toprocess + 1] = {mat,html,function()
+ what:SetMaterial(mat.material)
+ end}
+end
+
function svg.SvgOnDpanel(spath,background,foreground,dpanel)
local ret = {}
ret.html = vgui.Create("DHTML",dpanel)