Skip to content

Commit

Permalink
test(svg): update test case
Browse files Browse the repository at this point in the history
  • Loading branch information
plainheart committed Aug 2, 2024
1 parent df3b3f3 commit f4ad697
Showing 1 changed file with 65 additions and 51 deletions.
116 changes: 65 additions & 51 deletions test/svg-gradient.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,68 +8,82 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<div id="main"></div>
<div id="main-svg" style="display: inline-block;"></div>
<div id="main-canvas" style="display: inline-block;"></div>

<script type="text/javascript">
var zr = zrender.init(document.getElementById('main'), {
var zrSVG = zrender.init(document.getElementById('main-svg'), {
renderer: 'svg',
width: 200,
height: 200
});
zr.setBackgroundColor('navajowhite');

var linearGradient1 = new zrender.LinearGradient(0, 0, 0, 1);
linearGradient1.addColorStop(0, 'transparent');
linearGradient1.addColorStop(1, 'orange');
var zrCanvas = zrender.init(document.getElementById('main-canvas'), {
renderer: 'canvas',
width: 200,
height: 200
});

render(zrSVG)
render(zrCanvas)

function render(zr) {
zr.setBackgroundColor('navajowhite');

var linearGradient1 = new zrender.LinearGradient(0, 0, 0, 1);
linearGradient1.addColorStop(0, 'transparent');
linearGradient1.addColorStop(1, 'orange');

var linearGradient2 = new zrender.LinearGradient(0, 0, 0, 1);
linearGradient2.addColorStop(0, 'none');
linearGradient2.addColorStop(1, 'orange');
var linearGradient2 = new zrender.LinearGradient(0, 0, 0, 1);
linearGradient2.addColorStop(0, 'none');
linearGradient2.addColorStop(1, 'orange');

var linearGradient3 = new zrender.LinearGradient(0, 0, 0, 1);
linearGradient3.addColorStop(0, '');
linearGradient3.addColorStop(1, 'orange');
var linearGradient3 = new zrender.LinearGradient(0, 0, 0, 1);
linearGradient3.addColorStop(0, '');
linearGradient3.addColorStop(1, 'orange');

zr.add(
new zrender.Rect({
shape: {
x: 20,
y: 50,
width: 20,
height: 100,
},
style: {
fill: linearGradient1
}
})
);
zr.add(
new zrender.Rect({
shape: {
x: 20,
y: 50,
width: 20,
height: 100,
},
style: {
fill: linearGradient1
}
})
);

zr.add(
new zrender.Rect({
shape: {
x: 60,
y: 50,
width: 20,
height: 100,
},
style: {
fill: linearGradient2
}
})
);
zr.add(
new zrender.Rect({
shape: {
x: 60,
y: 50,
width: 20,
height: 100,
},
style: {
fill: linearGradient2
}
})
);

zr.add(
new zrender.Rect({
shape: {
x: 100,
y: 50,
width: 20,
height: 100,
},
style: {
fill: linearGradient3
}
})
);
zr.add(
new zrender.Rect({
shape: {
x: 100,
y: 50,
width: 20,
height: 100,
},
style: {
fill: linearGradient3
}
})
);
}
</script>
</body>
</html>

0 comments on commit f4ad697

Please sign in to comment.