Skip to content
Snippets Groups Projects
Commit 6d0d0091 authored by Neil Gershenfeld's avatar Neil Gershenfeld
Browse files

constructing raster+vector SVG

parent 76c79cc1
Branches
No related tags found
No related merge requests found
...@@ -269,20 +269,37 @@ function save_svg_masks() { ...@@ -269,20 +269,37 @@ function save_svg_masks() {
var svg = document.createElementNS(svgNS,"svg") var svg = document.createElementNS(svgNS,"svg")
svg.setAttributeNS("http://www.w3.org/2000/xmlns/", svg.setAttributeNS("http://www.w3.org/2000/xmlns/",
"xmlns:xlink","http://www.w3.org/1999/xlink") "xmlns:xlink","http://www.w3.org/1999/xlink")
svg.setAttribute('width',100) svg.setAttribute('width','10in')
svg.setAttribute('height',100) svg.setAttribute('height','10in')
svg.style.backgroundColor = 'rgb(255,255,255)' svg.style.backgroundColor = 'rgb(255,255,255)'
var g = document.createElementNS(svgNS,'g') var g = document.createElementNS(svgNS,'g')
svg.appendChild(g) svg.appendChild(g)
var rect = document.createElementNS('http://www.w3.org/2000/svg','rect')
rect.setAttribute('x','0in')
rect.setAttribute('y','0in')
rect.setAttribute('width','10in')
rect.setAttribute('height','10in')
rect.setAttribute('stroke','none')
rect.setAttribute('fill','white')
svg.appendChild(rect)
var img = document.createElementNS('http://www.w3.org/2000/svg','image')
img.setAttribute('x','5in')
img.setAttribute('y','5in')
img.setAttribute('width','5in')
img.setAttribute('height','5in')
img.setAttributeNS('http://www.w3.org/1999/xlink','href','hsv.png')
svg.appendChild(img)
var line = document.createElementNS('http://www.w3.org/2000/svg','line') var line = document.createElementNS('http://www.w3.org/2000/svg','line')
line.setAttribute('stroke','red') line.setAttribute('stroke','red')
line.setAttribute('stroke-width',1) line.setAttribute('stroke-width',1)
line.setAttribute('stroke-linecap','round') line.setAttribute('stroke-linecap','round')
var x1 = 0 var x1 = 0
var y1 = 0 var y1 = 0
var x2 = 100 var x2 = '10in'
var y2 = 100 var y2 = '10in'
line.setAttribute('x1',x1) line.setAttribute('x1',x1)
line.setAttribute('y1',y1) line.setAttribute('y1',y1)
line.setAttribute('x2',x2) line.setAttribute('x2',x2)
...@@ -290,18 +307,19 @@ function save_svg_masks() { ...@@ -290,18 +307,19 @@ function save_svg_masks() {
svg.appendChild(line) svg.appendChild(line)
var text = document.createElementNS('http://www.w3.org/2000/svg','text') var text = document.createElementNS('http://www.w3.org/2000/svg','text')
text.setAttribute('x','10') text.setAttribute('x','5in')
text.setAttribute('y','20') text.setAttribute('y','5in')
text.setAttribute('fill','red') text.setAttribute('fill','red')
text.setAttribute('font-size','1in')
text.textContent = 'palette' text.textContent = 'palette'
svg.appendChild(text) svg.appendChild(text)
var circle = document.createElementNS('http://www.w3.org/2000/svg','circle') var circle = document.createElementNS('http://www.w3.org/2000/svg','circle')
circle.setAttribute('cx',25) circle.setAttribute('cx','5in')
circle.setAttribute('cy',25) circle.setAttribute('cy','5in')
circle.setAttribute('r',20) circle.setAttribute('r','2.5in')
circle.setAttribute('stroke','red') circle.setAttribute('stroke','red')
circle.setAttribute('strokeWidth','red') circle.setAttribute('stroke-width',1)
circle.setAttribute('fill','none') circle.setAttribute('fill','none')
svg.appendChild(circle) svg.appendChild(circle)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment