2011-02-21 08:31:26 -05:00
|
|
|
<!DOCTYPE html>
|
2011-02-19 16:52:27 -05:00
|
|
|
<html>
|
|
|
|
<head>
|
2014-08-16 13:24:54 -04:00
|
|
|
<meta charset="UTF-8">
|
|
|
|
<title>Radial Rainbows</title>
|
|
|
|
<link rel="stylesheet" href="../css/style.css">
|
|
|
|
<script type="text/javascript" src="../../dist/paper-full.js"></script>
|
|
|
|
<script type="text/paperscript" canvas="canvas">
|
|
|
|
var point = view.center;
|
2011-07-07 10:09:02 -04:00
|
|
|
|
2014-08-16 13:24:54 -04:00
|
|
|
var colors = [];
|
|
|
|
var cycles = 4;
|
|
|
|
for (var i = 0, l = 60; i < l; i++) {
|
|
|
|
var brightness = 1 - (i / l) * 1.5;
|
|
|
|
var hue = i / l * cycles * 360;
|
|
|
|
var color = {
|
|
|
|
hue: hue,
|
|
|
|
saturation: 1,
|
|
|
|
brightness: brightness
|
|
|
|
};
|
|
|
|
colors.push(color);
|
|
|
|
}
|
2011-04-07 11:02:46 -04:00
|
|
|
|
2014-08-16 13:24:54 -04:00
|
|
|
var path = new Path.Rectangle(view.bounds);
|
|
|
|
var gradient = new Gradient(colors, true);
|
|
|
|
var radius = Math.max(view.size.width, view.size.height) * 0.75;
|
|
|
|
path.fillColor = new Color(gradient, point, point + [radius, 0]);
|
|
|
|
var gradientColor = path.fillColor;
|
2011-07-07 10:09:02 -04:00
|
|
|
|
2014-08-16 13:24:54 -04:00
|
|
|
var mouseDown = false,
|
|
|
|
mousePoint = view.center;
|
2011-07-07 10:09:02 -04:00
|
|
|
|
2014-08-16 13:24:54 -04:00
|
|
|
function onMouseDown(event) {
|
|
|
|
mouseDown = true;
|
|
|
|
mousePoint = event.point;
|
|
|
|
}
|
2011-07-07 10:09:02 -04:00
|
|
|
|
2014-08-16 13:24:54 -04:00
|
|
|
function onMouseDrag(event) {
|
|
|
|
mousePoint = event.point;
|
|
|
|
}
|
2011-07-07 10:09:02 -04:00
|
|
|
|
2014-08-16 13:24:54 -04:00
|
|
|
function onMouseUp(event) {
|
|
|
|
vector.length = 10;
|
|
|
|
mouseDown = false;
|
|
|
|
}
|
2011-07-07 10:09:02 -04:00
|
|
|
|
2014-08-16 13:24:54 -04:00
|
|
|
var grow = false;
|
|
|
|
var vector = new Point(150, 0);
|
2011-07-07 10:09:02 -04:00
|
|
|
|
2014-08-16 13:24:54 -04:00
|
|
|
function onFrame() {
|
|
|
|
for (var i = 0, l = gradient.stops.length; i < l; i++)
|
|
|
|
gradient.stops[i].color.hue -= 20;
|
|
|
|
if (grow && vector.length > 300) {
|
|
|
|
grow = false;
|
|
|
|
} else if (!grow && vector.length < 75) {
|
|
|
|
grow = true;
|
|
|
|
}
|
|
|
|
if (mouseDown) {
|
|
|
|
point = point + (mousePoint - point) / 10;
|
|
|
|
} else {
|
|
|
|
vector.length += (grow ? 1 : -1);
|
|
|
|
vector.angle += 5;
|
|
|
|
}
|
|
|
|
gradientColor.highlight = mouseDown ? point : point + vector;
|
|
|
|
}
|
2011-07-07 10:09:02 -04:00
|
|
|
|
2014-08-16 13:24:54 -04:00
|
|
|
function onResize(event) {
|
|
|
|
point = view.center;
|
|
|
|
path.bounds = view.bounds;
|
|
|
|
var gradientColor = path.fillColor;
|
|
|
|
gradientColor.origin = point;
|
|
|
|
var radius = Math.max(view.size.width, view.size.height) * 0.75;
|
|
|
|
gradientColor.destination = point + [radius, 0];
|
|
|
|
}
|
|
|
|
</script>
|
2011-02-19 16:52:27 -05:00
|
|
|
</head>
|
|
|
|
<body>
|
2014-08-16 13:24:54 -04:00
|
|
|
<canvas id="canvas" hidpi="off" resize></canvas>
|
2011-05-30 18:27:39 -04:00
|
|
|
</body>
|
2014-04-06 07:44:19 -04:00
|
|
|
</html>
|