add unit support to svg rendering
This commit is contained in:
parent
16fa8a746c
commit
5777739cbb
11
cvlp_lib.js
11
cvlp_lib.js
|
@ -99,9 +99,16 @@ function json2svg(json) {
|
|||
svg.setAttribute('xmlns',svgNS)
|
||||
svg.setAttribute('version',1.1)
|
||||
svg.setAttribute('xmlns:inkscape','http://www.inkscape.org/namespaces/inkscape')
|
||||
// set unit
|
||||
if (json.unit=="mil") { // mil units are not supported in SVG, convert to inch
|
||||
svg.setAttribute('height',(json.height/1000)+'in')
|
||||
svg.setAttribute('width',(json.width/1000)+'in')
|
||||
} else {
|
||||
svg.setAttribute('height',json.height+''+json.unit)
|
||||
svg.setAttribute('width',json.width+''+json.unit)
|
||||
}
|
||||
svg.setAttribute('viewBox','0 0 '+json.width+' '+json.height)
|
||||
// add info
|
||||
svg.setAttribute('height',json.height)
|
||||
svg.setAttribute('width',json.width)
|
||||
var svg_title = document.createElementNS(svgNS,'title');
|
||||
svg_title.textContent = json.name;
|
||||
svg.appendChild(svg_title);
|
||||
|
|
Loading…
Reference in New Issue