paper.js/examples/Animated/RadialRainbows.html
2011-03-06 15:10:35 +01:00

92 lines
No EOL
3.9 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Example</title>
<script type="text/javascript" src="../../lib/bootstrap.js"></script>
<script type="text/javascript" src="../../lib/parse-js.js"></script>
<script type="text/javascript" src="../../src/Paper.js"></script>
<script type="text/javascript" src="../../src/tool/ToolEvent.js"></script>
<script type="text/javascript" src="../../src/tool/ToolHandler.js"></script>
<script type="text/javascript" src="../../src/tool/Tool.js"></script>
<script type="text/javascript" src="../../src/basic/Point.js"></script>
<script type="text/javascript" src="../../src/basic/Rectangle.js"></script>
<script type="text/javascript" src="../../src/basic/Size.js"></script>
<script type="text/javascript" src="../../src/basic/Matrix.js"></script>
<script type="text/javascript" src="../../src/document/DocumentView.js"></script>
<script type="text/javascript" src="../../src/document/Document.js"></script>
<script type="text/javascript" src="../../src/document/Symbol.js"></script>
<script type="text/javascript" src="../../src/item/Item.js"></script>
<script type="text/javascript" src="../../src/item/PlacedSymbol.js"></script>
<script type="text/javascript" src="../../src/item/Group.js"></script>
<script type="text/javascript" src="../../src/item/Layer.js"></script>
<script type="text/javascript" src="../../src/item/Raster.js"></script>
<script type="text/javascript" src="../../src/item/PathStyle.js"></script>
<script type="text/javascript" src="../../src/path/Segment.js"></script>
<script type="text/javascript" src="../../src/path/PathItem.js"></script>
<script type="text/javascript" src="../../src/path/Path.js"></script>
<script type="text/javascript" src="../../src/path/CompoundPath.js"></script>
<script type="text/javascript" src="../../src/path/Path.Constructors.js"></script>
<script type="text/javascript" src="../../src/color/Color.js"></script>
<script type="text/javascript" src="../../src/color/RGBColor.js"></script>
<script type="text/javascript" src="../../src/color/GrayColor.js"></script>
<script type="text/javascript" src="../../src/color/GradientColor.js"></script>
<script type="text/javascript" src="../../src/color/Gradient.js"></script>
<script type="text/javascript" src="../../src/color/GradientStop.js"></script>
<script type="text/javascript" src="../../src/util/CanvasProvider.js"></script>
<script type="text/javascript" src="../../src/util/Events.js"></script>
<script type="text/javascript" src="../../src/util/PaperScript.js"></script>
<script type="text/paperscript" canvas="canvas">
var vector = new Point(document.size.height, 0);
var point = new Point(document.size) / 2;
var gradient = new Gradient();
gradient.type = 'radial';
var gradientColor = new GradientColor(gradient, point, point + vector);
var colors = ['red', 'orange', 'yellow', 'green', 'blue'];
var stops = [];
for (var i = 0, l = colors.length; i < l * 15; i++) {
var stop = new GradientStop(colors[i % l], i / (l * 15));
stops.push(stop);
}
gradient.stops = stops;
var path = new Path.Rectangle(new Rectangle([0, 0], document.size));
path.fillColor = gradientColor;
var mouseDown = false;
function onMouseDown(event) {
mouseDown = true;
gradientColor.hilite = event.point;
}
function onMouseDrag(event) {
gradientColor.hilite = event.point;
}
function onMouseUp(event) {
mouseDown = false;
}
setInterval(draw, 30);
var grow = false;
var vector = new Point(150, 0);
function draw() {
if (grow && vector.length > 300) {
grow = false;
} else if (!grow && vector.length < 75) {
grow = true;
}
vector.length += (grow ? 1 : -1);
vector.angle += 5;
if (!mouseDown) {
gradientColor.hilite = point + vector;
document.redraw();
}
}
</script>
</head>
<body>
<canvas id='canvas' width=1024 height=768></canvas>
</body>