paper.js/examples/SVG Export/Gradients.html

42 lines
No EOL
1.1 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Gradients</title>
<link rel="stylesheet" href="../css/style.css">
<script type="text/javascript" src="../../dist/paper.js"></script>
<script type="text/paperscript" canvas="canvas">
var radial = new Gradient([new Color(1, 1, 0, 0), 'red', 'black'], true);
var linear = new Gradient([new Color(1, 1, 0, 0), 'red', 'black'], false);
var radius = view.bounds.width * 0.4,
from = new Point(view.center.x),
to = from + [radius, 0];
var circle = new Path.Circle({
center: from,
radius: radius,
fillColor: new GradientColor(radial, from, to),
strokeColor: 'black'
});
var from = view.bounds.leftCenter,
to = view.bounds.bottomRight;
var rect = new Path.Rectangle({
from: from,
to: to,
fillColor: new GradientColor(linear, from, to),
strokeColor: 'black'
});
rect.rotate(45).scale(0.7);
document.getElementById('svg').appendChild(project.exportSvg());
</script>
</head>
<body>
<canvas id="canvas" width="300" height="600"></canvas>
<svg id="svg" width="300" height="600"></svg>
</body>
</html>