-
Notifications
You must be signed in to change notification settings - Fork 1
/
render-svg.js
39 lines (36 loc) · 1.09 KB
/
render-svg.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
Proofe of concept about generating SVG files from data input
*/
var jsdom = require('jsdom').jsdom;
var fs = require('fs');
var boilerplate = fs.readFileSync('index.html');
var doc = jsdom(boilerplate);
//doc.implementation.addFeature('http://www.w3.org/TR/SVG11/feature#BasicStructure', '1.1')
var window = doc.parentWindow;
window.onload = function() {
window.Raphael.prototype.renderfix = function(){};
var svgContainer = window.document.getElementById('svg');
var paper = window.Raphael(svgContainer, 640, 480);
paper
.rect(0, 0, 640, 480, 10)
.attr({
fill: '#fff',
stroke: 'none'
});
var circle = paper
.circle(320, 240, 60)
.attr({
fill: '#223fa3',
stroke: '#000',
'stroke-width': 80,
'stroke-opacity': 0.5
});
paper
.rect(circle.attr('cx') - 10, circle.attr('cy') - 10, 20, 20)
.attr({
fill: '#fff',
stroke: 'none'
});
// could be written to file
console.log(svgContainer.innerHTML);
};