mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-28 17:02:24 -05:00
Add more unit tests for SvgImport.
Some currently failing.
This commit is contained in:
parent
484d696df3
commit
7a4794dacf
7 changed files with 170 additions and 68 deletions
|
@ -11,67 +11,67 @@
|
|||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="1000" height="500" id="svg">
|
||||
<g transform="scale(0.5)">
|
||||
<path d="M300,200 h-150 a150,150 0 1,0 150,-150 z"
|
||||
fill="red" stroke="blue" stroke-width="5" />
|
||||
<path d="M275,175 v-150 a150,150 0 0,0 -150,150 z"
|
||||
fill="yellow" stroke="blue" stroke-width="5" />
|
||||
|
||||
<path d="M600,350 l 50,-25
|
||||
a25,25 -30 0,1 50,-25 l 50,-25
|
||||
a25,50 -30 0,1 50,-25 l 50,-25
|
||||
a25,75 -30 0,1 50,-25 l 50,-25
|
||||
a25,100 -30 0,1 50,-25 l 50,-25"
|
||||
fill="none" stroke="red" stroke-width="5" />
|
||||
<g font-family="Verdana" transform="translate(0,400)">
|
||||
<defs>
|
||||
<g id="baseEllipses" font-size="20" >
|
||||
<ellipse cx="125" cy="125" rx="100" ry="50"
|
||||
fill="none" stroke="#888888" stroke-width="2" />
|
||||
<ellipse cx="225" cy="75" rx="100" ry="50"
|
||||
fill="none" stroke="#888888" stroke-width="2" />
|
||||
<text x="35" y="70">Arc start</text>
|
||||
<text x="225" y="145">Arc end</text>
|
||||
</g>
|
||||
</defs>
|
||||
<rect x="1" y="1" width="1198" height="523"
|
||||
fill="none" stroke="blue" stroke-width="1" />
|
||||
|
||||
<g font-size="30" >
|
||||
<g transform="translate(0,0)">
|
||||
<use xlink:href="#baseEllipses"/>
|
||||
</g>
|
||||
<g transform="translate(400,0)">
|
||||
<text x="50" y="210">large-arc-flag=0</text>
|
||||
<text x="50" y="250">sweep-flag=0</text>
|
||||
<use xlink:href="#baseEllipses"/>
|
||||
<path d="M 125,75 a100,50 0 0,0 100,50"
|
||||
fill="none" stroke="red" stroke-width="6" />
|
||||
</g>
|
||||
<g transform="translate(800,0)">
|
||||
<text x="50" y="210">large-arc-flag=0</text>
|
||||
<text x="50" y="250">sweep-flag=1</text>
|
||||
<use xlink:href="#baseEllipses"/>
|
||||
<path d="M 125,75 a100,50 0 0,1 100,50"
|
||||
fill="none" stroke="red" stroke-width="6" />
|
||||
</g>
|
||||
<g transform="translate(400,250)">
|
||||
<text x="50" y="210">large-arc-flag=1</text>
|
||||
<text x="50" y="250">sweep-flag=0</text>
|
||||
<use xlink:href="#baseEllipses"/>
|
||||
<path d="M 125,75 a100,50 0 1,0 100,50"
|
||||
fill="none" stroke="red" stroke-width="6" />
|
||||
</g>
|
||||
<g transform="translate(800,250)">
|
||||
<text x="50" y="210">large-arc-flag=1</text>
|
||||
<text x="50" y="250">sweep-flag=1</text>
|
||||
<use xlink:href="#baseEllipses"/>
|
||||
<path d="M 125,75 a100,50 0 1,1 100,50"
|
||||
fill="none" stroke="red" stroke-width="6" />
|
||||
</g>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="1000" height="500" id="svg" viewBox="0 0 1000 500">
|
||||
<g transform="scale(0.5)">
|
||||
<path d="M300,200 h-150 a150,150 0 1,0 150,-150 z"
|
||||
fill="red" stroke="blue" stroke-width="5" />
|
||||
<path d="M275,175 v-150 a150,150 0 0,0 -150,150 z"
|
||||
fill="yellow" stroke="blue" stroke-width="5" />
|
||||
<path d="M600,350 l 50,-25
|
||||
a25,25 -30 0,1 50,-25 l 50,-25
|
||||
a25,50 -30 0,1 50,-25 l 50,-25
|
||||
a25,75 -30 0,1 50,-25 l 50,-25
|
||||
a25,100 -30 0,1 50,-25 l 50,-25"
|
||||
fill="none" stroke="red" stroke-width="5" />
|
||||
<g font-family="Verdana" transform="translate(0,400)">
|
||||
<defs>
|
||||
<g id="baseEllipses" font-size="20" >
|
||||
<ellipse cx="125" cy="125" rx="100" ry="50"
|
||||
fill="none" stroke="#888888" stroke-width="2" />
|
||||
<ellipse cx="225" cy="75" rx="100" ry="50"
|
||||
fill="none" stroke="#888888" stroke-width="2" />
|
||||
<text x="35" y="70">Arc start</text>
|
||||
<text x="225" y="145">Arc end</text>
|
||||
</g>
|
||||
</defs>
|
||||
<rect x="1" y="1" width="1198" height="523"
|
||||
fill="none" stroke="blue" stroke-width="1" />
|
||||
|
||||
<g font-size="30" >
|
||||
<g transform="translate(0,0)">
|
||||
<use xlink:href="#baseEllipses"/>
|
||||
</g>
|
||||
<g transform="translate(400,0)">
|
||||
<text x="50" y="210">large-arc-flag=0</text>
|
||||
<text x="50" y="250">sweep-flag=0</text>
|
||||
<use xlink:href="#baseEllipses"/>
|
||||
<path d="M 125,75 a100,50 0 0,0 100,50"
|
||||
fill="none" stroke="red" stroke-width="6" />
|
||||
</g>
|
||||
<g transform="translate(800,0)">
|
||||
<text x="50" y="210">large-arc-flag=0</text>
|
||||
<text x="50" y="250">sweep-flag=1</text>
|
||||
<use xlink:href="#baseEllipses"/>
|
||||
<path d="M 125,75 a100,50 0 0,1 100,50"
|
||||
fill="none" stroke="red" stroke-width="6" />
|
||||
</g>
|
||||
<g transform="translate(400,250)">
|
||||
<text x="50" y="210">large-arc-flag=1</text>
|
||||
<text x="50" y="250">sweep-flag=0</text>
|
||||
<use xlink:href="#baseEllipses"/>
|
||||
<path d="M 125,75 a100,50 0 1,0 100,50"
|
||||
fill="none" stroke="red" stroke-width="6" />
|
||||
</g>
|
||||
<g transform="translate(800,250)">
|
||||
<text x="50" y="210">large-arc-flag=1</text>
|
||||
<text x="50" y="250">sweep-flag=1</text>
|
||||
<use xlink:href="#baseEllipses"/>
|
||||
<path d="M 125,75 a100,50 0 1,1 100,50"
|
||||
fill="none" stroke="red" stroke-width="6" />
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
<canvas id="canvas" width="1000" height="500"></canvas>
|
||||
</body>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Multiple Paths Test 2</title>
|
||||
<title>Symbols Test</title>
|
||||
<link rel="stylesheet" href="../css/style.css">
|
||||
<script type="text/javascript" src="../../dist/paper-full.js"></script>
|
||||
<script type="text/paperscript" canvas="canvas">
|
||||
|
@ -10,15 +10,14 @@
|
|||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<svg version="1.1" id="svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="595" height="841" xml:space="preserve">
|
||||
<svg version="1.1" id="svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="595" height="841">
|
||||
<symbol id="circle" viewBox="0 0 48 48" overflow="visible">
|
||||
<path fill="#FF0049" d="M24,0c0-13.255-10.745-24-24-24S-24-13.255-24,0s10.745,24,24,24S24,13.255,24,0z"/>
|
||||
</symbol>
|
||||
<use xlink:href="#circle" width="48" height="48" x="-24" y="-24" transform="matrix(1.1667 1.1667 1.1667 -1.1667 177.0005 96)" overflow="visible"/>
|
||||
<use xlink:href="#circle" width="48" height="48" x="-24" y="-24" transform="matrix(0.5625 0 0 -0.5625 92 152)" overflow="visible"/>
|
||||
<use xlink:href="#circle" width="48" height="48" x="-24" y="-24" transform="matrix(2.2415 -2.0119 -2.0119 -2.2415 176.9971 246.9941)" overflow="visible"/>
|
||||
<use xlink:href="#circle" width="48" height="48" x="-24" y="-24" transform="matrix(1 0 0 -1 84 65)" overflow="visible"/>
|
||||
<use xlink:href="#circle" width="48" height="48" x="-24" y="-24" transform="matrix(1.1667 1.1667 1.1667 -1.1667 177.0005 96)"/>
|
||||
<use xlink:href="#circle" width="48" height="48" x="-24" y="-24" transform="matrix(0.5625 0 0 -0.5625 92 152)"/>
|
||||
<use xlink:href="#circle" width="48" height="48" x="-24" y="-24" transform="matrix(2.2415 -2.0119 -2.0119 -2.2415 176.9971 246.9941)"/>
|
||||
<use xlink:href="#circle" width="48" height="48" x="-24" y="-24" transform="matrix(1 0 0 -1 84 65)"/>
|
||||
</svg>
|
||||
<canvas id="canvas" width="595" height="841"></canvas>
|
||||
</body>
|
||||
|
|
83
test/assets/blendModes.svg
Normal file
83
test/assets/blendModes.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 182 KiB |
8
test/assets/symbol.svg
Normal file
8
test/assets/symbol.svg
Normal file
|
@ -0,0 +1,8 @@
|
|||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="150" height="150">
|
||||
<defs>
|
||||
<symbol viewBox="-75,-75,150,150" id="symbol-1">
|
||||
<path d="M-75,75l0,-150l150,0l0,150z" fill="red"></path>
|
||||
</symbol>
|
||||
</defs>
|
||||
<use x="0" y="0" xlink:href="#symbol-1" width="150" height="150" overflow="visible"></use>
|
||||
</svg>
|
After Width: | Height: | Size: 392 B |
9
test/assets/symbols.svg
Normal file
9
test/assets/symbols.svg
Normal file
|
@ -0,0 +1,9 @@
|
|||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="595" height="841" viewBox="0 0 595 841">
|
||||
<symbol id="circle" viewBox="0 0 48 48" overflow="visible">
|
||||
<path fill="#FF0049" d="M24,0c0-13.255-10.745-24-24-24S-24-13.255-24,0s10.745,24,24,24S24,13.255,24,0z"/>
|
||||
</symbol>
|
||||
<use xlink:href="#circle" width="48" height="48" x="-24" y="-24" transform="matrix(1.1667 1.1667 1.1667 -1.1667 177.0005 96)"/>
|
||||
<use xlink:href="#circle" width="48" height="48" x="-24" y="-24" transform="matrix(0.5625 0 0 -0.5625 92 152)"/>
|
||||
<use xlink:href="#circle" width="48" height="48" x="-24" y="-24" transform="matrix(2.2415 -2.0119 -2.0119 -2.2415 176.9971 246.9941)"/>
|
||||
<use xlink:href="#circle" width="48" height="48" x="-24" y="-24" transform="matrix(1 0 0 -1 84 65)"/>
|
||||
</svg>
|
After Width: | Height: | Size: 839 B |
|
@ -490,7 +490,7 @@ var compareSVG = function(done, actual, expected, message, options) {
|
|||
|
||||
function compare() {
|
||||
comparePixels(actual, expected, message, Base.set({
|
||||
tolerance: 1e-2,
|
||||
tolerance: 1e-3,
|
||||
resolution: 72
|
||||
}, options));
|
||||
done();
|
||||
|
|
|
@ -135,6 +135,8 @@ test('Import SVG without insertion', function() {
|
|||
function importSVG(assert, url, message, options) {
|
||||
var done = assert.async();
|
||||
project.importSVG(url, {
|
||||
applyMatrix: false,
|
||||
|
||||
onLoad: function(item, svg) {
|
||||
if (!message) {
|
||||
message = 'The imported SVG "' + url + '" should visually be '
|
||||
|
@ -142,6 +144,7 @@ function importSVG(assert, url, message, options) {
|
|||
}
|
||||
compareSVG(done, item, svg, message, options);
|
||||
},
|
||||
|
||||
onError: function(error) {
|
||||
var ok = !!(options && options.expectError);
|
||||
QUnit.push(ok, false, !ok, ok && message
|
||||
|
@ -154,7 +157,7 @@ function importSVG(assert, url, message, options) {
|
|||
|
||||
if (!isNode) {
|
||||
// JSDom does not have SVG rendering, so we can't test there.
|
||||
var svgFiles = ['viewbox', 'clipping', 'gradients-1'];
|
||||
var svgFiles = ['viewbox', 'clipping', 'symbol', 'symbols', 'blendModes', 'gradients-1'];
|
||||
// TODO: Investigate why Phantom struggles with this file:
|
||||
if (!isPhantom)
|
||||
svgFiles.push('gradients-2');
|
||||
|
|
Loading…
Reference in a new issue