xxxxxxxxxx
let t = 0.1; // 時間を表す変数
function setup() {
const minWH = min(windowWidth, windowHeight);
createCanvas(minWH, minWH, WEBGL); // Enable 3D mode
pixelDensity(1);
clrs = ["#0015FF", "#FF00A1", "#90FE00", "#8400FF", "#00FFF7", "#FF7300"]; // New colors
r = min(width, height) * 0.25;
const n = 365;
poss = [];
for (let i = 0, a = -HALF_PI; i < n; i++, a += TWO_PI / n) {
const x = cos(a) * r;
const y = sin(a) * r;
const z = random(-r, r); // Generate random Z coordinate
poss.push({x, y, z, i});
}
noStroke();
background(0, 0, 8);
}
function draw() {
blendMode(BLEND)
blendMode(ADD)
translate(0, 0, -height / 2); // Shift the canvas to be visible
for (let p of poss) {
push();
translate(p.x, p.y, p.z); // Use Z coordinate for translation
let clr = color(random(clrs));
clr.setAlpha(random(32, 160));
stroke(clr)
drawCirclePoint(p, r * (0.5 + 0.5 * sin(t))); // Radius changes with time t
pop();
}
t += 0.01; // Advance time
}
function drawCirclePoint(p, maxr) {
push();
let a = t + random(TWO_PI);
let l = random();
let vec = createVector(l, 0, 0).setHeading(a);
let lineLen = (1 - pow(l, p.i + 1)) * maxr;
let lineThickness = map(lineLen, 0, maxr, 5, 0.5); // Adjusted thickness mapping for strong beginning
strokeWeight(lineThickness);
let clr = color(random(clrs));
clr.setAlpha(random(32, 160));
stroke(clr);
let spreadDistance = 50; // Set the distance at which the lines start to spread
let spreadFactor = l * 10; // Adjusted spread factor for fireworks effect
if (lineLen > spreadDistance) {
lineLen *= spreadFactor;
}
line(0, 0, 0, vec.x * lineLen, vec.y * lineLen, random(-100, 100)); // Add Z coordinate to the line
pop();
t += 0.005; // adjust time progression
}
function keyTyped() {
if (key === 's') {
saveCanvas('screenshot', 'png');
}
}