2011-02-21 08:31:26 -05:00
|
|
|
<!DOCTYPE html>
|
2011-02-19 16:52:27 -05:00
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
|
|
<title>Example</title>
|
2011-05-05 11:25:17 -04:00
|
|
|
<link rel="stylesheet" href="../css/style.css">
|
2011-03-07 20:07:26 -05:00
|
|
|
<script type="text/javascript">var root = '../../'</script>
|
2011-03-07 18:11:41 -05:00
|
|
|
<script type="text/javascript" src="../../src/load.js"></script>
|
2011-03-04 06:38:38 -05:00
|
|
|
<script type="text/paperscript" canvas="canvas">
|
2011-05-16 07:51:20 -04:00
|
|
|
var point = view.center;
|
2011-03-04 06:38:38 -05:00
|
|
|
|
2011-04-07 11:02:46 -04:00
|
|
|
var colors = [];
|
2011-03-07 10:07:30 -05:00
|
|
|
for (var i = 0, l = 60; i < l; i++) {
|
|
|
|
var color = new RGBColor(1, 0, 0);
|
|
|
|
var cycles = 4;
|
|
|
|
color.hue = i / l * cycles * 360;
|
2011-04-07 11:05:25 -04:00
|
|
|
colors.push(color);
|
2011-03-04 06:38:38 -05:00
|
|
|
}
|
2011-04-07 11:02:46 -04:00
|
|
|
|
2011-05-16 07:51:20 -04:00
|
|
|
var path = new Path.Rectangle(view.bounds);
|
2011-04-07 11:02:46 -04:00
|
|
|
var gradient = new Gradient(colors, 'radial');
|
2011-05-16 07:51:20 -04:00
|
|
|
var radius = Math.max(view.size.width, view.size.height) * 0.75;
|
2011-05-05 13:40:10 -04:00
|
|
|
var gradientColor = new GradientColor(gradient, point, point + [radius, 0]);
|
2011-03-04 06:38:38 -05:00
|
|
|
path.fillColor = gradientColor;
|
2011-03-07 10:07:30 -05:00
|
|
|
|
|
|
|
tool.eventInterval = 30;
|
|
|
|
|
2011-03-04 06:38:38 -05:00
|
|
|
var mouseDown = false;
|
2011-03-04 06:44:02 -05:00
|
|
|
|
|
|
|
function onMouseDown(event) {
|
2011-03-09 11:08:20 -05:00
|
|
|
point = point + vector;
|
2011-03-04 06:44:02 -05:00
|
|
|
mouseDown = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function onMouseDrag(event) {
|
2011-03-09 11:08:20 -05:00
|
|
|
point = point + (event.point - point) / 10;
|
|
|
|
gradientColor.hilite = point;
|
|
|
|
iterate();
|
2011-03-04 06:44:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function onMouseUp(event) {
|
2011-03-09 11:08:20 -05:00
|
|
|
vector.length = 10;
|
2011-03-04 06:44:02 -05:00
|
|
|
mouseDown = false;
|
|
|
|
}
|
2011-05-07 08:58:22 -04:00
|
|
|
|
|
|
|
function onFrame() {
|
|
|
|
if (!mouseDown)
|
|
|
|
iterate();
|
|
|
|
}
|
2011-02-19 16:52:27 -05:00
|
|
|
|
2011-03-04 06:38:38 -05:00
|
|
|
var grow = false;
|
|
|
|
var vector = new Point(150, 0);
|
2011-03-09 11:08:20 -05:00
|
|
|
|
|
|
|
function iterate() {
|
2011-05-03 03:54:13 -04:00
|
|
|
for (var i = 0, l = gradient.stops.length; i < l; i++)
|
2011-03-07 10:07:30 -05:00
|
|
|
gradient.stops[i].color.hue -= 20;
|
2011-03-04 06:38:38 -05:00
|
|
|
if (grow && vector.length > 300) {
|
|
|
|
grow = false;
|
|
|
|
} else if (!grow && vector.length < 75) {
|
|
|
|
grow = true;
|
|
|
|
}
|
|
|
|
vector.length += (grow ? 1 : -1);
|
|
|
|
vector.angle += 5;
|
2011-03-09 11:08:20 -05:00
|
|
|
gradientColor.hilite = mouseDown ? point : point + vector;
|
2011-02-19 16:52:27 -05:00
|
|
|
}
|
2011-05-05 13:40:10 -04:00
|
|
|
|
2011-05-16 07:51:20 -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];
|
|
|
|
}
|
2011-02-19 16:52:27 -05:00
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body>
|
2011-05-14 06:04:02 -04:00
|
|
|
<canvas id="canvas" resize keepalive="true"></canvas>
|
2011-02-19 16:52:27 -05:00
|
|
|
</body>
|