-
-
Notifications
You must be signed in to change notification settings - Fork 54
/
index.cjs
58 lines (46 loc) · 1.56 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
53
54
55
56
57
58
const fs = require('fs')
// const a = require('.')
const { SVG, registerWindow } = require('../svg.js/dist/svg.node.cjs')
const main = async () => {
const { createSVGWindow, config } = await import('./main-module.js')
config
.setFontDir('./fonts')
.setFontFamilyMappings({ OpenSans: 'OpenSans-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)
// const svgDoc = SVG(document.documentElement)
// svgDoc.svg(data)
// const 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())
}
main()