| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../resources/ahem.js"></script> |
| <style> |
| :root { |
| font: 10px Ahem; |
| } |
| </style> |
| </head> |
| <body> |
| <template id="target-template"> |
| <svg width="200px" height="300px" viewBox="0 0 1500 1000"> |
| <rect class="target" x="10" y="10" width="10" height="10" /> |
| </svg> |
| </template> |
| <script src="../svg-attribute-interpolation/resources/interpolation-test.js"></script> |
| <script> |
| 'use strict'; |
| |
| // Same unit |
| |
| assertAttributeInterpolation({ |
| property: 'height', |
| underlying: '20', |
| from: '-10', |
| fromComposite: 'add', |
| to: '40', |
| toComposite: 'add' |
| }, [ |
| {at: -0.4, is: 0}, |
| {at: 0, is: 10}, |
| {at: 0.2, is: 20}, |
| {at: 0.6, is: 40}, |
| {at: 1, is: 60}, |
| {at: 1.4, is: 80} |
| ]); |
| assertAttributeInterpolation({ |
| property: 'height', |
| underlying: '20%', |
| from: '-10%', |
| fromComposite: 'add', |
| to: '40%', |
| toComposite: 'add' |
| }, [ |
| {at: -0.4, is: '0%'}, |
| {at: 0, is: '10%'}, |
| {at: 0.2, is: '20%'}, |
| {at: 0.6, is: '40%'}, |
| {at: 1, is: '60%'}, |
| {at: 1.4, is: '80%'} |
| ]); |
| assertAttributeInterpolation({ |
| property: 'height', |
| underlying: '20em', |
| from: '-10em', |
| fromComposite: 'add', |
| to: '40em', |
| toComposite: 'add' |
| }, [ |
| {at: -0.4, is: '0em'}, |
| {at: 0, is: '10em'}, |
| {at: 0.2, is: '20em'}, |
| {at: 0.6, is: '40em'}, |
| {at: 1, is: '60em'}, |
| {at: 1.4, is: '80em'} |
| ]); |
| assertAttributeInterpolation({ |
| property: 'height', |
| underlying: '20ex', |
| from: '-10ex', |
| fromComposite: 'add', |
| to: '40ex', |
| toComposite: 'add' |
| }, [ |
| {at: -0.4, is: '0ex'}, |
| {at: 0, is: '10ex'}, |
| {at: 0.2, is: '20ex'}, |
| {at: 0.6, is: '40ex'}, |
| {at: 1, is: '60ex'}, |
| {at: 1.4, is: '80ex'} |
| ]); |
| assertAttributeInterpolation({ |
| property: 'height', |
| underlying: '20rem', |
| from: '-10rem', |
| fromComposite: 'add', |
| to: '40rem', |
| toComposite: 'add' |
| }, [ |
| {at: -0.4, is: '0rem'}, |
| {at: 0, is: '10rem'}, |
| {at: 0.2, is: '20rem'}, |
| {at: 0.6, is: '40rem'}, |
| {at: 1, is: '60rem'}, |
| {at: 1.4, is: '80rem'} |
| ]); |
| |
| assertAttributeInterpolation({ |
| property: 'height', |
| underlying: '20', |
| from: '10', |
| fromComposite: 'replace', |
| to: '40', |
| toComposite: 'add' |
| }, [ |
| {at: -0.4, is: 0}, |
| {at: 0, is: 10}, |
| {at: 0.2, is: 20}, |
| {at: 0.6, is: 40}, |
| {at: 1, is: 60}, |
| {at: 1.4, is: 80} |
| ]); |
| assertAttributeInterpolation({ |
| property: 'height', |
| underlying: '20%', |
| from: '10%', |
| fromComposite: 'replace', |
| to: '40%', |
| toComposite: 'add' |
| }, [ |
| {at: -0.4, is: '0%'}, |
| {at: 0, is: '10%'}, |
| {at: 0.2, is: '20%'}, |
| {at: 0.6, is: '40%'}, |
| {at: 1, is: '60%'}, |
| {at: 1.4, is: '80%'} |
| ]); |
| assertAttributeInterpolation({ |
| property: 'height', |
| underlying: '20em', |
| from: '10em', |
| fromComposite: 'replace', |
| to: '40em', |
| toComposite: 'add' |
| }, [ |
| {at: -0.4, is: '0em'}, |
| {at: 0, is: '10em'}, |
| {at: 0.2, is: '20em'}, |
| {at: 0.6, is: '40em'}, |
| {at: 1, is: '60em'}, |
| {at: 1.4, is: '80em'} |
| ]); |
| assertAttributeInterpolation({ |
| property: 'height', |
| underlying: '20ex', |
| from: '10ex', |
| fromComposite: 'replace', |
| to: '40ex', |
| toComposite: 'add' |
| }, [ |
| {at: -0.4, is: '0ex'}, |
| {at: 0, is: '10ex'}, |
| {at: 0.2, is: '20ex'}, |
| {at: 0.6, is: '40ex'}, |
| {at: 1, is: '60ex'}, |
| {at: 1.4, is: '80ex'} |
| ]); |
| assertAttributeInterpolation({ |
| property: 'height', |
| underlying: '20rem', |
| from: '10rem', |
| fromComposite: 'replace', |
| to: '40rem', |
| toComposite: 'add' |
| }, [ |
| {at: -0.4, is: '0rem'}, |
| {at: 0, is: '10rem'}, |
| {at: 0.2, is: '20rem'}, |
| {at: 0.6, is: '40rem'}, |
| {at: 1, is: '60rem'}, |
| {at: 1.4, is: '80rem'} |
| ]); |
| |
| assertAttributeInterpolation({ |
| property: 'height', |
| underlying: '10', |
| from: neutralKeyframe, |
| to: '60', |
| toComposite: 'replace' |
| }, [ |
| {at: -0.4, is: 0}, |
| {at: 0, is: 10}, |
| {at: 0.2, is: 20}, |
| {at: 0.6, is: 40}, |
| {at: 1, is: 60}, |
| {at: 1.4, is: 80} |
| ]); |
| assertAttributeInterpolation({ |
| property: 'height', |
| underlying: '10%', |
| from: neutralKeyframe, |
| to: '60%', |
| toComposite: 'replace' |
| }, [ |
| {at: -0.4, is: '0%'}, |
| {at: 0, is: '10%'}, |
| {at: 0.2, is: '20%'}, |
| {at: 0.6, is: '40%'}, |
| {at: 1, is: '60%'}, |
| {at: 1.4, is: '80%'} |
| ]); |
| assertAttributeInterpolation({ |
| property: 'height', |
| underlying: '10em', |
| from: neutralKeyframe, |
| to: '60em', |
| toComposite: 'replace' |
| }, [ |
| {at: -0.4, is: '0em'}, |
| {at: 0, is: '10em'}, |
| {at: 0.2, is: '20em'}, |
| {at: 0.6, is: '40em'}, |
| {at: 1, is: '60em'}, |
| {at: 1.4, is: '80em'} |
| ]); |
| assertAttributeInterpolation({ |
| property: 'height', |
| underlying: '10ex', |
| from: neutralKeyframe, |
| to: '60ex', |
| toComposite: 'replace' |
| }, [ |
| {at: -0.4, is: '0ex'}, |
| {at: 0, is: '10ex'}, |
| {at: 0.2, is: '20ex'}, |
| {at: 0.6, is: '40ex'}, |
| {at: 1, is: '60ex'}, |
| {at: 1.4, is: '80ex'} |
| ]); |
| assertAttributeInterpolation({ |
| property: 'height', |
| underlying: '10rem', |
| from: neutralKeyframe, |
| to: '60rem', |
| toComposite: 'replace' |
| }, [ |
| {at: -0.4, is: '0rem'}, |
| {at: 0, is: '10rem'}, |
| {at: 0.2, is: '20rem'}, |
| {at: 0.6, is: '40rem'}, |
| {at: 1, is: '60rem'}, |
| {at: 1.4, is: '80rem'} |
| ]); |
| |
| // Mixed units |
| |
| assertAttributeInterpolation({ |
| property: 'height', |
| underlying: '10', |
| from: '10mm', |
| fromComposite: 'add', |
| to: '20px', |
| toComposite: 'add' |
| }, [ |
| {at: -0.4, is: '54.913387298583984'}, |
| {at: 0, is: '47.79527559055118'}, |
| {at: 0.2, is: '44.23622131347656'}, |
| {at: 0.6, is: '37.11811065673828'}, |
| {at: 1, is: '30px'}, |
| {at: 1.4, is: '22.881889343261719'} |
| ]); |
| assertAttributeInterpolation({ |
| property: 'height', |
| underlying: '10mm', |
| from: '10mm', |
| fromComposite: 'add', |
| to: '20px', |
| toComposite: 'add' |
| }, [ |
| {at: -0.4, is: '82.70866141732283'}, |
| {at: 0, is: '20mm'}, |
| {at: 0.2, is: '72.03149606299212'}, |
| {at: 0.6, is: '64.91338582677164'}, |
| {at: 1, is: '57.79527559055118'}, |
| {at: 1.4, is: '50.677165354330704'} |
| ]); |
| |
| assertAttributeInterpolation({ |
| property: 'height', |
| underlying: '10', |
| from: '10mm', |
| fromComposite: 'replace', |
| to: '10px', |
| toComposite: 'add' |
| }, [ |
| {at: -0.4, is: '44.913387298583984'}, |
| {at: 0, is: '10mm'}, |
| {at: 0.2, is: '34.23622131347656'}, |
| {at: 0.6, is: '27.11811065673828'}, |
| {at: 1, is: '20px'}, |
| {at: 1.4, is: '12.881889343261719'} |
| ]); |
| assertAttributeInterpolation({ |
| property: 'height', |
| underlying: '10mm', |
| from: '20mm', |
| fromComposite: 'replace', |
| to: '20px', |
| toComposite: 'add' |
| }, [ |
| {at: -0.4, is: '82.70866141732283'}, |
| {at: 0, is: '20mm'}, |
| {at: 0.2, is: '72.03149606299212'}, |
| {at: 0.6, is: '64.91338582677164'}, |
| {at: 1, is: '57.79527559055118'}, |
| {at: 1.4, is: '50.677165354330704'} |
| ]); |
| |
| assertAttributeInterpolation({ |
| property: 'height', |
| underlying: '10', |
| from: neutralKeyframe, |
| to: '60px', |
| toComposite: 'replace' |
| }, [ |
| {at: -0.4, is: 0}, |
| {at: 0, is: 10}, |
| {at: 0.2, is: 20}, |
| {at: 0.6, is: 40}, |
| {at: 1, is: 60}, |
| {at: 1.4, is: 80} |
| ]); |
| assertAttributeInterpolation({ |
| property: 'height', |
| underlying: '10mm', |
| from: neutralKeyframe, |
| to: '20px', |
| toComposite: 'replace' |
| }, [ |
| {at: -0.4, is: '44.913387298583984'}, |
| {at: 0, is: '10mm'}, |
| {at: 0.2, is: '34.23622131347656'}, |
| {at: 0.6, is: '27.11811065673828'}, |
| {at: 1, is: '20px'}, |
| {at: 1.4, is: '12.881889343261719'} |
| ]); |
| |
| </script> |
| </body> |
| </html> |