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