同心円のシリーズを描画して、ある色から別の色へのグラデーションを作成します。
gradient radial ellipse
Color Drawing
View Source Code
/*
* @name Radial Gradient
* @arialabel Three circles on a black background. The middle circle is completely visible but the user can only see half of the other two. There is a gradiant from the center of the circle to the outer edge that changes every second
* @description Draws a series of concentric circles to create a gradient
* from one color to another.
*/
let dim;
function setup() {
// createCanvas(710, 400);
createCanvas(windowWidth, windowHeight);
dim = width / 2;
background(0);
colorMode(HSB, 360, 100, 100);
noStroke();
ellipseMode(RADIUS);
frameRate(1);
}
function draw() {
background(0);
for (let x = 0; x <= width; x += dim) {
drawGradient(x, height / 2);
}
}
function drawGradient(x, y) {
let radius = dim / 2;
let h = random(0, 360);
for (let r = radius; r > 0; --r) {
fill(h, 90, 90);
ellipse(x, y, r, r);
h = (h + 1) % 360;
}
}
License
Source code is available on GitHub p5.js website legacy.
All examples are licensed under CC BY-NC-SA 4.0.