forked from svgdotjs/svgdom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.cjs
52 lines (42 loc) · 1.39 KB
/
index.cjs
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
40
41
42
43
44
45
46
47
48
49
50
51
52
const fs = require('fs')
const { createSVGWindow, config } = require('./main-require.cjs')
const { SVG, registerWindow } = require('../svg.js/dist/svg.node.js')
config
.setFontDir('./fonts')
.setFontFamilyMappings({ Montserrat: 'Montserrat-Regular.ttf' })
.preloadFonts()
fs.readFile('./squares.svg', 'utf8', (err, data) => {
if (err) {
console.error(err)
return
}
const window = createSVGWindow()
const document = window.document
registerWindow(window, document)
var svgDoc = SVG(document.documentElement)
svgDoc.svg(data)
var mygroup = svgDoc.findOne('#layer1')
console.log(mygroup.svg())
console.log(mygroup.cx(), mygroup.cy())
})
// const { createSVGWindow, setFontDir, setFontFamilyMappings } = require('./main-require.cjs')
// const svgjs = require('../svg.js/dist/svg.node.js')
// const { SVG, registerWindow } = svgjs
// const window = createSVGWindow()
// const document = window.document
// setFontDir('./fonts')
// setFontFamilyMappings({
// Calibri2: 'calibri.ttf',
// Arial2: 'arial.ttf',
// Comic2: 'comic.ttf',
// Coop2: 'COOPBL.TTF',
// Finale2: 'FinaleCopyistText.ttf',
// Free2: 'FREESCPT.TTF',
// Georgia2: 'georgia.ttf'
// })
// registerWindow(window, document)
// const canvas = SVG(document.documentElement)
// .size(2000, 1000)
// .viewbox(-300, -300, 2000, 1000)
// canvas.rect(100, 100).move(200, 100).size(200)
// console.log(canvas.svg())