summaryrefslogtreecommitdiffstats
path: root/src/svg.js
blob: a7e92d0bc3b42662e12128d3ea91dcf8bdd3b20a (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
import * as Classes from './classes.js'
import * as adopter from './adopter.js'
import * as tools from './tools.js'
import './attr.js'
import './arrange.js'
import './data.js'
import './classHandling.js'
import find from './selector.js'
import './css.js'
import './transform.js'
import './memory.js'
import './sugar.js'
import { getMethodsFor } from './methods.js'
import { registerMorphableType, makeMorphable, TransformBag, ObjectBag, NonMorphable } from './Morphable.js'

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

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

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

// satisfy tests, fix later
import * as ns from './namespaces.js'
import { easing } from './Controller.js'
import * as events from './event.js'
import parser from './parser.js'
import * as defaults from './defaults.js'
const extend = tools.extend

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'))

extend(Classes.EventTarget, getMethodsFor('EventTarget'))
extend(Classes.Dom, getMethodsFor('Dom'))
extend(Classes.Element, getMethodsFor('Element'))
extend(Classes.Shape, getMethodsFor('Shape'))
// extend(Classes.Element, getConstructor('Memory'))
extend(Classes.Container, getMethodsFor('Container'))

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 adopter.makeInstance(element)
}

Object.assign(SVG, Classes)
Object.assign(SVG, tools)
Object.assign(SVG, adopter)
SVG.utils = utils
SVG.regex = regex
SVG.get = SVG
SVG.find = find
Object.assign(SVG, ns)
SVG.easing = easing
Object.assign(SVG, events)
SVG.TransformBag = TransformBag
SVG.ObjectBag = ObjectBag
SVG.NonMorphable = NonMorphable
SVG.parser = parser
SVG.defaults = defaults