arr1.morph(arr2)
expect(arr1.at(0.5).value).toEqual([1.5, 2.5, 3.5, 4.5])
})
- it('returns itself if no destination was specified', function() {
- expect(arr1.at(0.5)).toBe(arr1)
+ it('throws when no destination was specified', function() {
+ expect(arr1.at).toThrow()
})
})
})
arr1.morph(arr2)
expect(arr1.at(0.5).value).toEqual([[1.5, 2.5], [3.5, 4.5]])
})
- it('returns itself if no destination was specified', function() {
- expect(arr1.at(0.5)).toBe(arr1)
+ it('throws when no destination was specified', function() {
+ expect(arr1.at).toThrow()
})
})
})
expect(morphedPathArray.value[1][4]).toBe(1)
expect(morphedPathArray.value[1][5]).toBe(0)
})
- it('return itself if the destination attribute is null', function(){
+ it('throws when no destination was specified', function(){
var pathArray = new SVG.PathArray('M 13 13 A 25 37 0 0 1 43 25')
- pathArray.destination = null
- expect(pathArray.at(0.45)).toBe(pathArray)
+ expect(pathArray.at).toThrow()
})
})
expect(box2.toString()).toBe('50 -100 300 300')
expect(box3.toString()).toBe('30 0 250 300')
})
- it('returns itself when no destination given', function() {
+ it('throws itself when no destination was specified', function() {
var box = new SVG.Box(10, 100, 200, 300)
- expect(box.at(0.5)).toBe(box)
+ expect(box.at).toThrow()
})
})
})
expect(morphed.b).toBe(255)
})
- it('returns itself when no destination specified', function() {
- expect(color.at(0.5)).toBe(color)
+ it('throws when no destination specified', function() {
+ expect(color.at).toThrow()
})
})
expect(matrix2.toString()).toBe('matrix(1,0,0,1,4,3)')
expect(matrix3.toString()).toBe('matrix(1.5,0,0,3,2,1.5)')
})
- it('returns itself when no destination specified', function() {
+ it('throws when no destination specified', function() {
var matrix = new SVG.Matrix(2, 0, 0, 5, 0, 0)
- expect(matrix.at(0.5)).toBe(matrix)
+ expect(matrix.at).toThrow()
})
})
it('use the unit of this number as the unit of the returned number when the destination number as no unit', function() {
expect(expect(new SVG.Number('100s').morph(50).at(0.5).unit).toBe('s'))
})
- it('returns itself when no destination specified', function() {
- expect(number.at(0.5)).toBe(number)
+ it('throws when no destination specified', function() {
+ expect(number.at).toThrow()
})
})
expect(point3).toEqual(new SVG.Point(1.5, 1.5))
})
- it('returns itself when no destination specified', function() {
+ it('throws when no destination specified', function() {
var point = new SVG.Point(1,1)
- expect(point.at(0.4)).toBe(point)
+ expect(point.at).toThrow()
})
})
// Get morphed array at given position
at: function (pos) {
// make sure a destination is defined
- if (!this.destination) return this
+ if (!this.destination) throw new Error('No destination set')
// generate morphed array
for (var i = 0, il = this.value.length, array = []; i < il; i++) {
},
at: function (pos) {
- if (!this.destination) return this
+ if (!this.destination) throw new Error('No destination set')
return new SVG.Box(
this.x + (this.destination.x - this.x) * pos
// Get morphed color at given position
at: function (pos) {
// make sure a destination is defined
- if (!this.destination) return this
+ if (!this.destination) throw new Error('No destination set')
// normalise pos
pos = pos < 0 ? 0 : pos > 1 ? 1 : pos
// Get morphed matrix at a given position
at: function (pos) {
// make sure a destination is defined
- if (!this.destination) return this
+ if (!this.destination) throw new Error('No destination set')
// calculate morphed matrix at a given position
var matrix = new SVG.Matrix({
// Get morphed number at given position
at: function (pos) {
// Make sure a destination is defined
- if (!this.destination) return this
+ if (!this.destination) throw new Error('No destination set')
// Generate new morphed number
return new SVG.Number(this.destination)
// Get morphed path array at given position
at: function (pos) {
// make sure a destination is defined
- if (!this.destination) return this
+ if (!this.destination) throw new Error('No destination set')
var sourceArray = this.value
var destinationArray = this.destination.value
// Get morphed point at a given position
at: function (pos) {
// make sure a destination is defined
- if (!this.destination) return this
+ if (!this.destination) throw new Error('No destination set')
// calculate morphed matrix at a given position
var point = new SVG.Point({
// Get morphed array at given position
at: function (pos) {
// make sure a destination is defined
- if (!this.destination) return this
+ if (!this.destination) throw new Error('No destination set')
// generate morphed point string
for (var i = 0, il = this.value.length, array = []; i < il; i++) {