* @copyright Wout Fierens <wout@mick-wout.com>
* @license MIT
*
-* BUILT: Sat Nov 24 2018 11:07:45 GMT+0100 (GMT+01:00)
+* BUILT: Sat Nov 24 2018 14:31:28 GMT+0100 (GMT+01:00)
*/;
var SVG = (function () {
'use strict';
return [ox, oy];
}
+ var utils = /*#__PURE__*/Object.freeze({
+ map: map,
+ filter: filter,
+ radians: radians,
+ degrees: degrees,
+ camelCase: camelCase,
+ unCamelCase: unCamelCase,
+ capitalize: capitalize,
+ proportionalSize: proportionalSize,
+ getOrigin: getOrigin
+ });
+
// Default namespaces
var ns = 'http://www.w3.org/2000/svg';
var xmlns = 'http://www.w3.org/2000/xmlns/';
var xlink = 'http://www.w3.org/1999/xlink';
var svgjs = 'http://svgjs.com/svgjs';
+ var namespaces = /*#__PURE__*/Object.freeze({
+ ns: ns,
+ xmlns: xmlns,
+ xlink: xlink,
+ svgjs: svgjs
+ });
+
var globals = {
window: typeof window === 'undefined' ? null : window,
document: typeof document === 'undefined' ? null : document
register(Use);
/* Optional Modules */
+ var SVG = makeInstance;
extend([Svg$1, Symbol, Image, Pattern, Marker], getMethodsFor('viewbox'));
extend([Line, Polyline, Polygon, Path], getMethodsFor('marker'));
extend(Text, getMethodsFor('Text'));
ObjectBag: ObjectBag,
NonMorphable: NonMorphable,
defaults: defaults,
+ utils: utils,
+ namespaces: namespaces,
+ regex: regex,
+ SVG: SVG,
parser: parser,
find: baseFind,
registerWindow: registerWindow,
Queue: Queue,
Runner: Runner,
Timeline: Timeline,
- SVGArray: SVGArray,
+ Array: SVGArray,
Box: Box,
Color: Color,
EventTarget: EventTarget,
Matrix: Matrix,
- SVGNumber: SVGNumber,
+ Number: SVGNumber,
PathArray: PathArray,
Point: Point,
PointArray: PointArray,
TextPath: TextPath,
Tspan: Tspan,
Use: Use,
- map: map,
- filter: filter,
- radians: radians,
- degrees: degrees,
- camelCase: camelCase,
- unCamelCase: unCamelCase,
- capitalize: capitalize,
- proportionalSize: proportionalSize,
- getOrigin: getOrigin,
- ns: ns,
- xmlns: xmlns,
- xlink: xlink,
- svgjs: svgjs,
on: on,
off: off,
dispatch: dispatch,
wrapWithAttrCheck: wrapWithAttrCheck
});
- function SVG(element) {
+ function SVG$1(element) {
return makeInstance(element);
}
- Object.assign(SVG, svgMembers);
- SVG.utils = SVG;
- SVG.regex = regex;
- SVG.get = SVG;
+ Object.assign(SVG$1, svgMembers);
- return SVG;
+ return SVG$1;
}());
expect(path.parent() instanceof SVG.Svg).toBeTruthy()
})
it('defines a xmlns attribute', function() {
- expect(path.parent().node.getAttribute('xmlns')).toBe(SVG.ns)
+ expect(path.parent().node.getAttribute('xmlns')).toBe(SVG.namespaces.ns)
})
it('defines a version attribute', function() {
expect(path.parent().node.getAttribute('version')).toBe('1.1')
})
it('defines a xmlns:xlink attribute', function() {
- expect(path.parent().node.getAttribute('xmlns:xlink')).toBe(SVG.xlink)
+ expect(path.parent().node.getAttribute('xmlns:xlink')).toBe(SVG.namespaces.xlink)
})
it('initializes a defs node', function() {
expect(path.defs() instanceof SVG.Defs).toBe(true)
var array, arr1, arr2
it('parses a matrix array correctly to string', function() {
- array = new SVG.SVGArray([ .343, .669, .119, 0, 0
+ array = new SVG.Array([ .343, .669, .119, 0, 0
, .249, -.626, .130, 0, 0
, .172, .334, .111, 0, 0
, .000, .000, .000, 1, -0 ])
expect(array + '').toBe('0.343 0.669 0.119 0 0 0.249 -0.626 0.13 0 0 0.172 0.334 0.111 0 0 0 0 0 1 0')
})
it('parses space seperated string and converts it to array', function() {
- expect((new SVG.SVGArray('1 2 3 4')).valueOf()).toEqual([1,2,3,4])
+ expect((new SVG.Array('1 2 3 4')).valueOf()).toEqual([1,2,3,4])
})
it('parses comma seperated string and converts it to array', function() {
- expect((new SVG.SVGArray('1,2,3,4')).valueOf()).toEqual([1,2,3,4])
+ expect((new SVG.Array('1,2,3,4')).valueOf()).toEqual([1,2,3,4])
})
describe('reverse()', function() {
it('reverses the array', function() {
- array = new SVG.SVGArray([1 ,2 ,3, 4, 5]).reverse()
+ array = new SVG.Array([1 ,2 ,3, 4, 5]).reverse()
expect(array.valueOf()).toEqual([5, 4, 3, 2, 1])
})
it('returns itself', function() {
- array = new SVG.SVGArray()
+ array = new SVG.Array()
expect(array.reverse()).toBe(array)
})
})
describe('clone()', function() {
it('creates a deep clone of the array', function() {
- array = new SVG.SVGArray([1, 2, 3, 4, 5])
+ array = new SVG.Array([1, 2, 3, 4, 5])
clone = array.clone()
expect(array).toEqual(clone)
expect(array).not.toBe(clone)
- array = new SVG.SVGArray([[1,2], [3, 4], [5]])
+ array = new SVG.Array([[1,2], [3, 4], [5]])
clone = array.clone()
expect(array).toEqual(array)
expect(draw.defs().find('pattern image').length).toBe(1)
expect(draw.defs().find('pattern image')[0].attr('href')).toBe(imageUrl)
})
- it('correctly creates SVG.SVGArray if array given', function() {
+ it('correctly creates SVG.Array if array given', function() {
rect.attr('something', [2,3,4])
expect(rect.attr('something')).toBe('2 3 4')
})
it('set all properties in el.dom to the svgjs:data attribute', function(){
var rect = draw.rect(100,100)
rect.dom.foo = 'bar'
- rect.dom.number = new SVG.SVGNumber('3px')
+ rect.dom.number = new SVG.Number('3px')
rect.writeDataToDom()
var g = draw.group()
rect = g.rect(100,100)
g.dom.foo = 'bar'
- rect.dom.number = new SVG.SVGNumber('3px')
+ rect.dom.number = new SVG.Number('3px')
g.writeDataToDom()
// it('should be possible to animate numeric attributes', function () {
// var startValue = 0
// , endValue = 150
-// , morph = new SVG.SVGNumber(startValue).morph(endValue)
+// , morph = new SVG.Number(startValue).morph(endValue)
//
// var text = draw.text(function(add) {
// add.tspan('We go ')
// it('should be possible to pass percentage strings to numeric attributes', function () {
// var startValue = '0%'
// , endValue = '80%'
-// , morph = new SVG.SVGNumber(startValue).morph(endValue)
+// , morph = new SVG.Number(startValue).morph(endValue)
//
// var text = draw.text(function(add) {
// add.tspan('We go ')
// it('should be possible to animate numeric styles', function () {
// var startValue = 0
// , endValue = 5
-// , morph = new SVG.SVGNumber(startValue).morph(endValue)
+// , morph = new SVG.Number(startValue).morph(endValue)
//
// rect.css('stroke-width', startValue)
// fx.css('stroke-width', endValue)
// it('should be possible to pass percentage strings to numeric styles', function () {
// var startValue = '0%'
// , endValue = '5%'
-// , morph = new SVG.SVGNumber(startValue).morph(endValue)
+// , morph = new SVG.Number(startValue).morph(endValue)
//
// rect.css('stroke-width', startValue)
// fx.css('stroke-width', endValue)
//
// describe('add()', function() {
// it('adds to animations obj by default', function() {
-// fx.add('x', new SVG.SVGNumber(20))
+// fx.add('x', new SVG.Number(20))
// expect(fx.situation.animations.x.value).toBe(20)
// })
//
// it('adds to specified obj', function() {
-// fx.add('x', new SVG.SVGNumber(20), 'animations')
-// fx.add('x', new SVG.SVGNumber(20), 'attrs')
-// fx.add('x', new SVG.SVGNumber(20), 'styles')
+// fx.add('x', new SVG.Number(20), 'animations')
+// fx.add('x', new SVG.Number(20), 'attrs')
+// fx.add('x', new SVG.Number(20), 'styles')
// expect(fx.situation.animations.x.value).toBe(20)
// expect(fx.situation.attrs.x.value).toBe(20)
// expect(fx.situation.styles.x.value).toBe(20)
// expect(obj instanceof SVG.Color).toBeTruthy()
// })
//
-// it('accepts numbers and converts them to SVG.SVGNumber', function() {
+// it('accepts numbers and converts them to SVG.Number', function() {
// var obj = new SVG.MorphObj('0', '10')
-// expect(obj instanceof SVG.SVGNumber).toBeTruthy()
+// expect(obj instanceof SVG.Number).toBeTruthy()
//
// var obj = new SVG.MorphObj(0, 10)
-// expect(obj instanceof SVG.SVGNumber).toBeTruthy()
+// expect(obj instanceof SVG.Number).toBeTruthy()
// })
//
// it('accepts any other values', function() {
var morpher = new SVG.Morphable().from(10).to(5)
expect(morpher instanceof SVG.Morphable).toBe(true)
- expect(morpher.type()).toBe(SVG.SVGNumber)
- expect(morpher.at(0.5) instanceof SVG.SVGNumber).toBe(true)
+ expect(morpher.type()).toBe(SVG.Number)
+ expect(morpher.at(0.5) instanceof SVG.Number).toBe(true)
expect(morpher.at(0.5).valueOf()).toBe(7.5)
})
expect(morpher.at(0.5).valueOf()).toEqual(jasmine.objectContaining({a: 7.5, b: 15}))
})
- it(`Creates a morphable out of an SVG.SVGNumber`, function () {
- var morpher = new SVG.SVGNumber(5).to(10)
+ it(`Creates a morphable out of an SVG.Number`, function () {
+ var morpher = new SVG.Number(5).to(10)
expect(morpher instanceof SVG.Morphable).toBe(true)
- expect(morpher.type()).toBe(SVG.SVGNumber)
- expect(morpher.at(0.5) instanceof SVG.SVGNumber).toBe(true)
+ expect(morpher.type()).toBe(SVG.Number)
+ expect(morpher.at(0.5) instanceof SVG.Number).toBe(true)
expect(morpher.at(0.5).valueOf()).toBe(7.5)
})
expect(morpher.at(0.5)).toEqual(jasmine.objectContaining(new SVG.Matrix(2, 3, 4, 5, 6, 7)))
})
- it(`Creates a morphable out of an SVG.SVGArray`, function () {
- var morpher = new SVG.SVGArray([1,2,3,4,5,6]).to([3,4,5,6,7,8])
+ it(`Creates a morphable out of an SVG.Array`, function () {
+ var morpher = new SVG.Array([1,2,3,4,5,6]).to([3,4,5,6,7,8])
expect(morpher instanceof SVG.Morphable).toBe(true)
- expect(morpher.type()).toBe(SVG.SVGArray)
- expect(morpher.at(0.5) instanceof SVG.SVGArray).toBe(true)
+ expect(morpher.type()).toBe(SVG.Array)
+ expect(morpher.at(0.5) instanceof SVG.Array).toBe(true)
expect(morpher.at(0.5).toArray()).toEqual(jasmine.arrayContaining([2, 3, 4, 5, 6, 7]))
})
describe('from()', function () {
it('sets the type of the runner', function () {
var morpher = new SVG.Morphable().from(5)
- expect(morpher.type()).toBe(SVG.SVGNumber)
+ expect(morpher.type()).toBe(SVG.Number)
})
it('sets the from attribute to an array representation of the morphable type', function () {
describe('type()', function () {
it('sets the type of the runner', function () {
- var morpher = new SVG.Morphable().type(SVG.SVGNumber)
- expect(morpher._type).toBe(SVG.SVGNumber)
+ var morpher = new SVG.Morphable().type(SVG.Number)
+ expect(morpher._type).toBe(SVG.Number)
})
it('gets the type of the runner', function () {
- var morpher = new SVG.Morphable().type(SVG.SVGNumber)
- expect(morpher.type()).toBe(SVG.SVGNumber)
+ var morpher = new SVG.Morphable().type(SVG.Number)
+ expect(morpher.type()).toBe(SVG.Number)
})
})
describe('to()', function () {
it('sets the type of the runner', function () {
var morpher = new SVG.Morphable().to(5)
- expect(morpher.type()).toBe(SVG.SVGNumber)
+ expect(morpher.type()).toBe(SVG.Number)
})
it('sets the from attribute to an array representation of the morphable type', function () {
var number
beforeEach(function() {
- number = new SVG.SVGNumber
+ number = new SVG.Number
})
describe('new', function() {
expect(number.unit).toBe('')
})
it('accepts the unit as a second argument', function() {
- number = new SVG.SVGNumber(30, '%')
+ number = new SVG.Number(30, '%')
expect(number.value).toBe(30)
expect(number.unit).toBe('%')
})
it('parses a pixel value', function() {
- number = new SVG.SVGNumber('20px')
+ number = new SVG.Number('20px')
expect(number.value).toBe(20)
expect(number.unit).toBe('px')
})
it('parses a percent value', function() {
- number = new SVG.SVGNumber('99%')
+ number = new SVG.Number('99%')
expect(number.value).toBe(0.99)
expect(number.unit).toBe('%')
})
it('parses a seconds value', function() {
- number = new SVG.SVGNumber('2s')
+ number = new SVG.Number('2s')
expect(number.value).toBe(2000)
expect(number.unit).toBe('s')
})
it('parses a negative percent value', function() {
- number = new SVG.SVGNumber('-89%')
+ number = new SVG.Number('-89%')
expect(number.value).toBe(-0.89)
expect(number.unit).toBe('%')
})
it('falls back to 0 if given value is NaN', function() {
- number = new SVG.SVGNumber(NaN)
+ number = new SVG.Number(NaN)
expect(number.value).toBe(0)
})
it('falls back to maximum value if given number is positive infinite', function() {
- number = new SVG.SVGNumber(1.7976931348623157E+10308)
+ number = new SVG.Number(1.7976931348623157E+10308)
expect(number.value).toBe(3.4e+38)
})
it('falls back to minimum value if given number is negative infinite', function() {
- number = new SVG.SVGNumber(-1.7976931348623157E+10308)
+ number = new SVG.Number(-1.7976931348623157E+10308)
expect(number.value).toBe(-3.4e+38)
})
})
describe('valueOf()', function() {
it('returns a numeric value for default units', function() {
expect(typeof number.valueOf()).toBe('number')
- number = new SVG.SVGNumber('12')
+ number = new SVG.Number('12')
expect(typeof number.valueOf()).toBe('number')
- number = new SVG.SVGNumber(13)
+ number = new SVG.Number(13)
expect(typeof number.valueOf()).toBe('number')
})
it('returns a numeric value for pixel units', function() {
- number = new SVG.SVGNumber('10px')
+ number = new SVG.Number('10px')
expect(typeof number.valueOf()).toBe('number')
})
it('returns a numeric value for percent units', function() {
- number = new SVG.SVGNumber('20%')
+ number = new SVG.Number('20%')
expect(typeof number.valueOf()).toBe('number')
})
it('converts to a primitive when multiplying', function() {
describe('plus()', function() {
it('returns a new instance', function() {
expect(number.plus(4.5)).not.toBe(number)
- expect(number.plus(4.5) instanceof SVG.SVGNumber).toBeTruthy()
+ expect(number.plus(4.5) instanceof SVG.Number).toBeTruthy()
})
it('adds a given number', function() {
expect(number.plus(3.5).valueOf()).toBe(3.5)
expect(number.plus('83px').valueOf()).toBe(83)
})
it('use the unit of this number as the unit of the returned number by default', function (){
- expect(new SVG.SVGNumber('12s').plus('3%').unit).toBe('s')
+ expect(new SVG.Number('12s').plus('3%').unit).toBe('s')
})
it('use the unit of the passed number as the unit of the returned number when this number as no unit', function() {
expect(number.plus('15%').unit).toBe('%')
expect(number.minus('85px').valueOf()).toBe(-85)
})
it('use the unit of this number as the unit of the returned number by default', function (){
- expect(new SVG.SVGNumber('12s').minus('3%').unit).toBe('s')
+ expect(new SVG.Number('12s').minus('3%').unit).toBe('s')
})
it('use the unit of the passed number as the unit of the returned number when this number as no unit', function() {
expect(number.minus('15%').unit).toBe('%')
expect(number.times('85px').valueOf()).toBe(340)
})
it('use the unit of this number as the unit of the returned number by default', function (){
- expect(new SVG.SVGNumber('12s').times('3%').unit).toBe('s')
+ expect(new SVG.Number('12s').times('3%').unit).toBe('s')
})
it('use the unit of the passed number as the unit of the returned number when this number as no unit', function() {
expect(number.times('15%').unit).toBe('%')
expect(number.divide('45px').valueOf()).toBe(2)
})
it('use the unit of this number as the unit of the returned number by default', function (){
- expect(new SVG.SVGNumber('12s').divide('3%').unit).toBe('s')
+ expect(new SVG.Number('12s').divide('3%').unit).toBe('s')
})
it('use the unit of the passed number as the unit of the returned number when this number as no unit', function() {
expect(number.divide('15%').unit).toBe('%')
it('redirects to x() / y() with adding the current value', function() {
rect.dx(5)
rect.dy(5)
- expect(rect.x).toHaveBeenCalledWith(jasmine.objectContaining(new SVG.SVGNumber('5')))
- expect(rect.y).toHaveBeenCalledWith(jasmine.objectContaining(new SVG.SVGNumber('5')))
+ expect(rect.x).toHaveBeenCalledWith(jasmine.objectContaining(new SVG.Number('5')))
+ expect(rect.y).toHaveBeenCalledWith(jasmine.objectContaining(new SVG.Number('5')))
})
it('allows to add a percentage value', function() {
rect.dx('5%')
rect.dy('5%')
- expect(rect.x).toHaveBeenCalledWith(jasmine.objectContaining(new SVG.SVGNumber('10%')))
- expect(rect.y).toHaveBeenCalledWith(jasmine.objectContaining(new SVG.SVGNumber('10%')))
+ expect(rect.x).toHaveBeenCalledWith(jasmine.objectContaining(new SVG.Number('10%')))
+ expect(rect.y).toHaveBeenCalledWith(jasmine.objectContaining(new SVG.Number('10%')))
})
it('allows to add a percentage value when no x/y is set', function() {
rect.dx('5%')
rect.dy('5%')
- expect(rect.x).toHaveBeenCalledWith(jasmine.objectContaining(new SVG.SVGNumber('5%')))
- expect(rect.y).toHaveBeenCalledWith(jasmine.objectContaining(new SVG.SVGNumber('5%')))
+ expect(rect.x).toHaveBeenCalledWith(jasmine.objectContaining(new SVG.Number('5%')))
+ expect(rect.y).toHaveBeenCalledWith(jasmine.objectContaining(new SVG.Number('5%')))
})
})
describe('leading()', function() {
it('returns the leading value of the text without an argument', function() {
- expect(text.leading() instanceof SVG.SVGNumber)
+ expect(text.leading() instanceof SVG.Number)
expect(text.leading().valueOf()).toBe(1.3)
})
it('sets the leading value of the text with the first argument', function() {
text.setData(JSON.parse(text.attr('svgjs:data')))
expect(text.dom.foo).toBe('bar')
- expect(text.dom.leading instanceof SVG.SVGNumber).toBeTruthy()
+ expect(text.dom.leading instanceof SVG.Number).toBeTruthy()
expect(text.dom.leading.value).toBe(3)
expect(text.dom.leading.unit).toBe('px')
})
+++ /dev/null
-// describe('Transformations:', function() {
-// var translated, scaled, rotated, skewed
-//
-// beforeEach(function() {
-// translated = draw.rect(100,100).translate(100,100)
-// scaled = draw.rect(100,100).scale(2)
-// rotated = draw.rect(100,100).rotate(45, 50, 50)
-// skewed = draw.rect(100,100).skew(30)
-// })
-//
-// /* SVG.Transformation is not tested because it is an abstract prototype */
-//
-// describe('SVG.Transformation', function() {
-// it('marks the transformation as inversed when inverse flag given', function() {
-// var trans = new SVG.Transformation([], true)
-// expect(trans.inversed).toBeTruthy()
-// })
-// })
-//
-// describe('SVG.Translate', function() {
-// var trans
-//
-// beforeEach(function(){
-// trans = new SVG.Translate(translated.transform())
-// })
-//
-//
-// it('creates an object of type SVG.Transformation', function() {
-// expect(trans instanceof SVG.Transformation).toBeTruthy()
-// })
-//
-// it('uses transformedX and transformedY as arguments', function() {
-// expect(trans.arguments).toEqual(['transformedX', 'transformedY'])
-// })
-//
-// it('s method is translate()', function() {
-// expect(trans.method).toEqual('translate')
-// })
-//
-// it('sets the necessary parameters at creation', function() {
-// expect(trans.transformedX).toBe(100)
-// expect(trans.transformedY).toBe(100)
-// })
-//
-// describe('undo', function() {
-// it('sets the undo matrix which can undo the translation', function() {
-// var extracted = (new SVG.Matrix(1,0,0,1,20,20)).extract()
-// trans.undo(extracted)
-// expect(trans._undo.toString()).toEqual('matrix(1,0,0,1,-20,-20)')
-//
-// var extracted = (new SVG.Matrix(10,0,0,10,20,20)).extract()
-// trans.undo(extracted)
-// expect(trans._undo.toString()).toEqual('matrix(1,0,0,1,-2,-2)')
-//
-// var extracted = (new SVG.Matrix(10,50,50,30,20,20)).extract()
-// trans.undo(extracted)
-// expect(trans._undo.e).toBeCloseTo(-extracted.transformedX)
-// expect(trans._undo.f).toBeCloseTo(-extracted.transformedY)
-// })
-// })
-//
-// describe('at', function() {
-// it('creates a matrix at a certain position', function() {
-// expect(trans.at(0.3).toString()).toEqual('matrix(1,0,0,1,30,30)')
-// })
-// it('returns the inversed matrix from a specific position when created with inverse flag', function() {
-// expect((new SVG.Translate(translated.transform(), true)).at(0.3).toString()).toEqual('matrix(1,0,0,1,-30,-30)')
-// })
-// it('returns the resulting transformation which has to be made to set an absolute translation', function() {
-// trans.undo(new SVG.Matrix(10,50,50,30,20,20).extract())
-//
-// expect(trans.at(0.4).a).toEqual(1)
-// expect(trans.at(0.4).b).toEqual(0)
-// expect(trans.at(0.4).c).toEqual(0)
-// expect(trans.at(0.4).d).toEqual(1)
-// expect(trans.at(0.4).e).toBeCloseTo(100 * 0.4 + trans._undo.e * 0.4)
-// expect(trans.at(0.4).f).toBeCloseTo(100 * 0.4 + trans._undo.f * 0.4)
-// })
-// })
-// })
-//
-// describe('SVG.Rotate', function() {
-// var trans
-//
-// beforeEach(function(){
-// trans = new SVG.Rotate(45, 50, 50)
-// })
-//
-//
-// it('creates an object of type SVG.Transformation', function() {
-// expect(trans instanceof SVG.Transformation).toBeTruthy()
-// })
-//
-// it('uses rotation, cx and cy as arguments', function() {
-// expect(trans.arguments).toEqual(['rotation', 'cx', 'cy'])
-// })
-//
-// it('s method is rotate()', function() {
-// expect(trans.method).toEqual('rotate')
-// })
-//
-// it('sets the necessary parameters at creation', function() {
-// expect(trans.rotation).toBe(45)
-// expect(trans.cx).toBe(50)
-// expect(trans.cy).toBe(50)
-// })
-//
-// describe('undo', function() {
-// it('sets an undo object which holds rotation', function() {
-// var extracted = (new SVG.Matrix(1,0,0,1,0,0)).rotate(20, 50, 50).extract()
-// trans.undo(extracted)
-// expect(trans._undo.rotation).toBeCloseTo(20)
-// })
-// })
-//
-// describe('at', function() {
-// it('creates a matrix at a certain position', function() {
-// expect(trans.at(0.3).toString()).toEqual((new SVG.Matrix()).rotate(0.3 * 45, 50, 50).toString())
-// })
-// it('returns the resulting transformation which has to be made to set an absolute translation', function() {
-// trans.undo((new SVG.Matrix()).rotate(20, 50, 50).extract())
-//
-// expect(trans.at(0.4).a).toBeCloseTo(1,1)
-// expect(trans.at(0.4).b).toEqual(jasmine.any(Number))
-// expect(trans.at(0.4).c).toEqual(jasmine.any(Number))
-// expect(trans.at(0.4).d).toBeCloseTo(1,1)
-// expect(trans.at(0.4).e).toEqual(jasmine.any(Number))
-// expect(trans.at(0.4).f).toEqual(jasmine.any(Number))
-// })
-// })
-// })
-//
-//
-// describe('SVG.Scale', function() {
-// var trans
-//
-// beforeEach(function(){
-// trans = new SVG.Scale(2,2,50,50)
-// })
-//
-//
-// it('creates an object of type SVG.Transformation', function() {
-// expect(trans instanceof SVG.Transformation).toBeTruthy()
-// })
-//
-// it('uses scaleX, scaleY, cx and cy as arguments', function() {
-// expect(trans.arguments).toEqual(['scaleX', 'scaleY', 'cx', 'cy'])
-// })
-//
-// it('s method is scale()', function() {
-// expect(trans.method).toEqual('scale')
-// })
-//
-// it('sets the necessary parameters at creation', function() {
-// expect(trans.scaleX).toBe(2)
-// expect(trans.scaleY).toBe(2)
-// expect(trans.cx).toBe(50)
-// expect(trans.cy).toBe(50)
-// })
-//
-// describe('undo', function() {
-// it('sets the undo matrix which can undo the translation', function() {
-// var extracted = (new SVG.Matrix(4,0,0,4,0,0)).extract()
-// trans.undo(extracted)
-// expect(trans._undo.toString()).toEqual('matrix(0.25,0,0,0.25,37.5,37.5)')
-//
-// var extracted = (new SVG.Matrix(10,0,0,10,20,20)).extract()
-// trans.undo(extracted)
-// expect(trans._undo.a).toBeCloseTo(1/extracted.scaleX)
-// expect(trans._undo.d).toBeCloseTo(1/extracted.scaleY)
-// expect(trans._undo.e).toBeCloseTo(45)
-// expect(trans._undo.f).toBeCloseTo(45)
-//
-// var extracted = (new SVG.Matrix(10,50,50,30,20,20)).extract()
-// trans.undo(extracted)
-// expect(trans._undo.a).toBeCloseTo(1/extracted.scaleX)
-// expect(trans._undo.d).toBeCloseTo(1/extracted.scaleY)
-// })
-// })
-//
-// describe('at', function() {
-// it('creates a matrix at a certain position', function() {
-// expect(trans.at(0.75).toString()).toEqual('matrix(1.75,0,0,1.75,-37.5,-37.5)')
-// })
-// it('returns the inversed matrix from a specific position when created with inverse flag', function() {
-// var morphed = (new SVG.Scale(scaled.transform(2,2,50,50), true)).at(0.25)
-//
-// expect(morphed.a).toBeCloseTo(0.8)
-// expect(morphed.d).toBeCloseTo(0.8)
-// })
-// it('returns the resulting transformation which has to be made to set an absolute translation', function() {
-//
-// var morphed = trans.undo((new SVG.Matrix(10,0,0,10,0,0)).extract()).at(0.5)
-//
-// expect(morphed.a).toBeCloseTo(0.6)
-// expect(morphed.b).toEqual(0)
-// expect(morphed.c).toEqual(0)
-// expect(morphed.d).toBeCloseTo(0.6)
-// expect(morphed.e).toBeCloseTo(20)
-// expect(morphed.f).toBeCloseTo(20)
-// })
-// })
-// })
-//
-// describe('SVG.Skew', function() {
-// var trans
-//
-// beforeEach(function(){
-// trans = new SVG.Skew(30,-30,50,50)
-// })
-//
-//
-// it('creates an object of type SVG.Transformation', function() {
-// expect(trans instanceof SVG.Transformation).toBeTruthy()
-// })
-//
-// it('uses scaleX, scaleY, cx and cy as arguments', function() {
-// expect(trans.arguments).toEqual(['skewX', 'skewY', 'cx', 'cy'])
-// })
-//
-// it('s method is skew()', function() {
-// expect(trans.method).toEqual('skew')
-// })
-//
-// it('sets the necessary parameters at creation', function() {
-// expect(trans.skewX).toBe(30)
-// expect(trans.skewY).toBe(-30)
-// expect(trans.cx).toBe(50)
-// expect(trans.cy).toBe(50)
-// })
-//
-// describe('undo', function() {
-// it('sets the undo matrix which can undo the translation', function() {
-// var extracted = (new SVG.Matrix()).skew(90, 90, 0, 0).extract()
-// trans.undo(extracted)
-// expect(trans._undo.a).toBeCloseTo(0)
-// expect(trans._undo.b).toBeCloseTo(0)
-// expect(trans._undo.c).toBeCloseTo(0)
-// expect(trans._undo.d).toBeCloseTo(0)
-// expect(trans._undo.e).toBeCloseTo(50)
-// expect(trans._undo.f).toBeCloseTo(50)
-//
-// var extracted = (new SVG.Matrix(10,0,0,10,20,20)).extract()
-// trans.undo(extracted)
-// expect(trans._undo.a).toBeCloseTo(1)
-// expect(trans._undo.b).toBeCloseTo(0)
-// expect(trans._undo.c).toBeCloseTo(0)
-// expect(trans._undo.d).toBeCloseTo(1)
-// expect(trans._undo.e).toBeCloseTo(0)
-// expect(trans._undo.f).toBeCloseTo(0)
-// })
-// })
-//
-// describe('at', function() {
-// it('creates a matrix at a certain position', function() {
-// expect(trans.at(0.75)).toEqual((new SVG.Matrix()).morph((new SVG.Matrix()).skew(30, -30, 50, 50)).at(0.75))
-// })
-// it('returns the inversed matrix from a specific position when created with inverse flag', function() {
-// var morphed = (new SVG.Scale(skewed.transform(20,-20,50,50), true)).at(0.25)
-//
-// expect(morphed.a).toBeCloseTo(0.963)
-// expect(morphed.b).toBeCloseTo(0)
-// expect(morphed.c).toBeCloseTo(0)
-// expect(morphed.d).toBeCloseTo(0.963)
-// expect(morphed.e).toBeCloseTo(0)
-// expect(morphed.f).toBeCloseTo(0)
-// })
-// it('returns the resulting transformation which has to be made to set an absolute translation', function() {
-//
-// var morphed = trans.undo((new SVG.Matrix(10,0,0,10,0,0)).skew(20, 30, 20, 10).extract()).at(0.5)
-//
-// expect(morphed.a).toBeCloseTo(1.266)
-// expect(morphed.b).toBeCloseTo(-0.7310)
-// expect(morphed.c).toBeCloseTo(0.1351)
-// expect(morphed.d).toBeCloseTo(0.9220)
-// expect(morphed.e).toBeCloseTo(-20.05593)
-// expect(morphed.f).toBeCloseTo(40.4468)
-// })
-// })
-// })
-// })
})
it('sets the target element id to its href attribute', function() {
- expect(use.node.getAttributeNS(SVG.xlink, 'href')).toBe('#' + rect)
+ expect(use.node.getAttributeNS(SVG.namespaces.xlink, 'href')).toBe('#' + rect)
})
it('adopts the geometry of the target element', function() {
})
it('sets the target element id and file path to its href attribute', function() {
- expect(use.node.getAttributeNS(SVG.xlink, 'href')).toBe(file + '#' + id)
+ expect(use.node.getAttributeNS(SVG.namespaces.xlink, 'href')).toBe(file + '#' + id)
})
})
-
-})
\ No newline at end of file
+
+})
import './modules/optional/sugar.js'
import './modules/optional/transform.js'
-import { extend } from './utils/adopter.js'
+import { extend, makeInstance } from './utils/adopter.js'
import { getMethodNames, getMethodsFor } from './utils/methods.js'
import Box from './types/Box.js'
import Circle from './elements/Circle.js'
import Text from './elements/Text.js'
import Tspan from './elements/Tspan.js'
import * as defaults from './modules/core/defaults.js'
+import * as utils from './utils/utils.js'
+import * as namespaces from './modules/core/namespaces.js'
+import * as regex from './modules/core/regex.js'
export {
Morphable,
NonMorphable
}
-export { defaults }
-export * from './utils/utils.js'
-export * from './modules/core/namespaces.js'
+export { defaults, utils, namespaces, regex }
+export const SVG = makeInstance
export { default as parser } from './modules/core/parser.js'
export { default as find } from './modules/core/selector.js'
export * from './modules/core/event.js'
export { default as Timeline } from './animation/Timeline.js'
/* Types */
-export { default as SVGArray } from './types/SVGArray.js'
+export { default as Array } from './types/SVGArray.js'
export { default as Box } from './types/Box.js'
export { default as Color } from './types/Color.js'
export { default as EventTarget } from './types/EventTarget.js'
export { default as Matrix } from './types/Matrix.js'
-export { default as SVGNumber } from './types/SVGNumber.js'
+export { default as Number } from './types/SVGNumber.js'
export { default as PathArray } from './types/PathArray.js'
export { default as Point } from './types/Point.js'
export { default as PointArray } from './types/PointArray.js'
import * as svgMembers from './main.js'
-import * as regex from './modules/core/regex.js'
import { makeInstance } from './utils/adopter'
// The main wrapping element
}
Object.assign(SVG, svgMembers)
-
-SVG.utils = SVG
-SVG.regex = regex
-SVG.get = SVG