mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Update RadialRainbows example to use Color#hue.
This commit is contained in:
parent
d713102734
commit
8bfa4e6073
1 changed files with 11 additions and 5 deletions
|
@ -44,16 +44,21 @@
|
||||||
gradient.type = 'radial';
|
gradient.type = 'radial';
|
||||||
var gradientColor = new GradientColor(gradient, point, point + vector);
|
var gradientColor = new GradientColor(gradient, point, point + vector);
|
||||||
|
|
||||||
var colors = ['red', 'orange', 'yellow', 'green', 'blue'];
|
|
||||||
var stops = [];
|
var stops = [];
|
||||||
for (var i = 0, l = colors.length; i < l * 15; i++) {
|
for (var i = 0, l = 60; i < l; i++) {
|
||||||
var stop = new GradientStop(colors[i % l], i / (l * 15));
|
var color = new RGBColor(1, 0, 0);
|
||||||
|
var cycles = 4;
|
||||||
|
color.hue = i / l * cycles * 360;
|
||||||
|
var stop = new GradientStop(color, i / l);
|
||||||
stops.push(stop);
|
stops.push(stop);
|
||||||
}
|
}
|
||||||
|
|
||||||
gradient.stops = stops;
|
gradient.stops = stops;
|
||||||
var path = new Path.Rectangle(new Rectangle([0, 0], document.size));
|
var path = new Path.Rectangle(new Rectangle([0, 0], document.size));
|
||||||
path.fillColor = gradientColor;
|
path.fillColor = gradientColor;
|
||||||
|
|
||||||
|
tool.eventInterval = 30;
|
||||||
|
|
||||||
var mouseDown = false;
|
var mouseDown = false;
|
||||||
|
|
||||||
function onMouseDown(event) {
|
function onMouseDown(event) {
|
||||||
|
@ -69,11 +74,12 @@
|
||||||
mouseDown = false;
|
mouseDown = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
setInterval(draw, 30);
|
|
||||||
|
|
||||||
var grow = false;
|
var grow = false;
|
||||||
var vector = new Point(150, 0);
|
var vector = new Point(150, 0);
|
||||||
|
setInterval(draw, 30);
|
||||||
function draw() {
|
function draw() {
|
||||||
|
for(var i = 0, l = gradient.stops.length; i < l; i++)
|
||||||
|
gradient.stops[i].color.hue -= 20;
|
||||||
if (grow && vector.length > 300) {
|
if (grow && vector.length > 300) {
|
||||||
grow = false;
|
grow = false;
|
||||||
} else if (!grow && vector.length < 75) {
|
} else if (!grow && vector.length < 75) {
|
||||||
|
|
Loading…
Reference in a new issue