Module:Sandbox/Con-struct (t)/Test1/svg-head
Jump to navigation
Jump to search
CodeDiscussionEditHistoryLinksLink count Subpages:DocumentationTestsResultsSandboxLive code All modules
Lua
Documentation for this module may be created at Module:Sandbox/Con-struct (t)/Test1/svg-head/doc
Code
-- --
function svgTitle (sTitle, sDescription)
local sTitle2, sReturn
if sTitle then
sTitle2 = '<title>' .. (sTitle or '') .. '</title>\n'
else
sTitle2 = ''
end
sReturn = '\n' ..
sTitle2 ..
'<desc>\n' ..
' This svg graphic is to edit with an text editor.\n' ..
' Please do not overwrite this file by saving with an image editor.\n'
if sDescription then
-- sDescription = string.gsub (sDescription, '\n', '\n ')
sReturn = sReturn ..
' ----------------\n' ..
' ' .. sDescription .. '\n'
end
return
sReturn ..
'</desc>\n'
end
-- white background because transparency is grey in some wikipedias, e.g. en; x,y,width,height identical to viewBox --
function svgBackground (dChartHeightStretch, dChartWidthStretch, dChartElementSize, dLeft, dRight, dTop, dBottom, sBackgroundImageSVG)
local sReturn, sBackground, sBackgroundLink
if sBackgroundImageSVG then
sBackground =
' <!-- Background Image SVG -->\n' ..
' <def><pattern id="imagebackground-fill" width="100%" height="100%" patternUnits="objectBoundingBox">\n' ..
sBackgroundImageSVG ..
' </pattern></def>\n'
sBackgroundShow = '"url(#imagebackground-fill)"\n'
else
sBackground = ''
sBackgroundShow = '"white"'
end
return '\n' ..
'<!-- also a workaround for librsvg: a <rect> must be placed somewhere before text for a good display of text -->\n' ..
sBackground ..
'<rect id="imagebackground" x="' ..
-1 * dLeft .. '" y="' ..
-1 * (dChartHeightStretch + dTop) .. '" width="' ..
1 * (dChartWidthStretch + dLeft + dRight) .. '" height="' ..
1 * (dChartHeightStretch + dTop + dBottom) .. '" stroke-width="' ..
round (dChartElementSize / 1000, 2) .. '" stroke="none" fill=' ..
sBackgroundShow ..
'/>\n'
end