mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
1f98d72c5b
Allow deactivation by setting the hidpi attribute to "off" on the canvas.
51 lines
No EOL
1.1 KiB
HTML
51 lines
No EOL
1.1 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta 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 stops = [new Color(1, 1, 0, 0), 'red', 'black'];
|
|
|
|
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: {
|
|
stops: stops,
|
|
radial: true,
|
|
origin: from,
|
|
destination: to
|
|
},
|
|
strokeColor: 'black'
|
|
});
|
|
|
|
var from = view.bounds.leftCenter,
|
|
to = view.bounds.bottomRight;
|
|
|
|
var rect = new Path.Rectangle({
|
|
from: from,
|
|
to: to,
|
|
fillColor: {
|
|
stops: stops,
|
|
radial: false,
|
|
origin: from,
|
|
destination: 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> |