summaryrefslogtreecommitdiffstats
path: root/src/svg.js
blob: de24923161fa2092998548186b8c8bbdf11855f9 (plain)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// import {extend} from './tools.js'
// import * as Element from './Element.js'
// import Defs from './Defs.js'
//
// extend(Defs, [EventTarget, Element, Parent])

import {makeInstance} from './adopter.js'
import * as Classes from './classes.js'
import * as adopter from './adopter.js'
import * as tools from './tools.js'
import * as containers from './containers.js'
import * as elements from './elements.js'
import './attr.js'
import './arrange.js'
import find from './selector.js'
import './css.js'
import './transform.js'
import './memory.js'
import './sugar.js'
import {getMethodsFor, getConstructor} from './methods.js'
import {registerMorphableType, makeMorphable} from './Morphable.js'
const extend = tools.extend

import './EventTarget.js'
import './Element.js'
import './Parent.js'

extend([
  Classes.Doc,
  Classes.Symbol,
  Classes.Image,
  Classes.Pattern,
  Classes.Marker
], getMethodsFor('viewbox'))

extend([
  Classes.Line,
  Classes.Polyline,
  Classes.Polygon,
  Classes.Path
], getMethodsFor('marker'))

extend(Classes.Text, getMethodsFor('Text'))
extend(Classes.Path, getMethodsFor('Path'))

extend(Classes.Defs, getMethodsFor('Defs'))

extend([
  Classes.Text,
  Classes.Tspan
], getMethodsFor('Tspan'))

extend([
  Classes.Rect,
  Classes.Ellipse,
  Classes.Circle,
  Classes.Gradient
], getMethodsFor('radius'))

const containerMethods = getMethodsFor('Container')
// FIXME: We need a container array
for (let i in containers) {
  extend(containers[i], containerMethods)
}

const elementMethods = getMethodsFor('Element')
const eventTargetMethods = getMethodsFor('EventTarget')
for (let i in elements) {
  extend(elements[i], elementMethods)
  extend(elements[i], eventTargetMethods)
  extend(elements[i], getConstructor('EventTarget'))
  extend(elements[i], getConstructor('Element'))
  extend(elements[i], getConstructor('Memory'))
}

registerMorphableType([
  Classes.SVGNumber,
  Classes.Color,
  Classes.Box,
  Classes.Matrix,
  Classes.SVGArray,
  Classes.PointArray,
  Classes.PathArray
])

makeMorphable()

// The main wrapping element
export default function SVG (element) {
  return makeInstance(element)
}

Object.assign(SVG, Classes)
Object.assign(SVG, tools)
Object.assign(SVG, adopter)

import * as utils from './utils.js'
SVG.utils = utils

import * as regex from './regex.js'
SVG.regex = regex




// satisfy tests, fix later
import * as ns from './namespaces'
SVG.get = SVG
SVG.select = find
Object.assign(SVG, ns)
import Base from './Base.js'
SVG.Element = SVG.Parent = SVG.Shape = SVG.Container = Base