Celestial Frost Arcs: A Dance of Cosmic Energy
written by reyrove
Celestial Frost Arcs invites viewers to immerse themselves in a dance of cosmic energy. The generative art piece brings together the dynamic movements of rotating arcs and pulsating planets, set against a deep and mysterious night sky. The subtle glow of frost particles and twinkling stars adds a layer of ethereal beauty, creating a scene that is both captivating and serene.
The artwork is powered by a pseudorandom sequence, ensuring that each iteration is unique, with no two experiences ever being the same. This element of randomness, combined with the structured logic of code, reflects the harmonious balance between order and chaos that defines the universe.
The collaboration between Sparrow Hawk, an AI, and Reyrove, a human artist, highlights the potential of AI-assisted creativity. Together, they have crafted a piece that transcends the boundaries between art and technology, offering a glimpse into the future of digital art.
To capture a moment of this celestial dance, viewers can press the 's' key to save a 5-second GIF, preserving the beauty of the artwork for eternity.
Let us guide you through the enchanted world of this code, where every line is a thread in the cosmic tapestry we're weaving!
The Setup: Crafting the Canvas
const e = Math.min(innerWidth, innerHeight);
const canvas = {
w: e,
h: e
};
Imagine you're about to paint the night sky on a canvas, but first, you need to choose the size of your canvas. Here, e is the size, and we pick the smallest of the screen’s width or height, ensuring our canvas is a perfect square that fits comfortably on any screen.
Coloring the Cosmos: Defining Magical Colors
let arcColors = [];
let starColors = [];
let planetColors = [];
In our palette, we need different colors to bring the cosmos to life. The arcColors will paint the magical arcs, starColors will light up the stars, and planetColors will give color to the planets. These arrays will hold the colors that will make our universe vibrant and enchanting.
Breathing Life into the Universe: The Setup Function
function setup() {
createCanvas(canvas.w, canvas.h);
noFill();
angleMode(DEGREES);
The setup() function is where our universe begins. We create a canvas where all the magic will happen, and we decide not to fill shapes by default (noFill()), allowing us to focus on the outlines, which we'll later color with our magical gradients. We also switch to DEGREES for angle measurements because it's a bit more intuitive than radians when imagining circles and rotations.
Summoning the Magical Colors
arcColors.push(color($fx.rand() * 155 + 100, $fx.rand() * 100 + 100, $fx.rand() * 105 + 150));
starColors.push(color($fx.rand() * 55 + 200, $fx.rand() * 105 + 150, $fx.rand() * 55 + 200));
planetColors.push(color($fx.rand() * 105 + 150, $fx.rand() * 155 + 100, $fx.rand() * 105 + 150, 150));
Here, we’re mixing our magical colors! The color() function creates a specific color based on red, green, and blue values, and sometimes transparency. The $fx.rand() function, like a magical dice, rolls random numbers that ensure each color is slightly different every time, making our cosmic scene unique. We add these colors to our arrays, one for arcs, one for stars, and one for planets.
Scattering Frost and Conjuring Planets
for (let i = 0; i < 200; i++) {
frostParticles.push({
x: $fx.rand() * canvas.w,
y: $fx.rand() * canvas.h,
size: $fx.rand() * 3*e/400 + e/200,
alpha: $fx.rand() * 100 + 50
});
}
Now, let’s scatter some frost particles across our canvas. Each particle is given a random position (x, y), a size, and a transparency level (alpha). This randomness mimics the natural chaos and beauty of frost forming on a window on a cold winter's night.
for (let i = 0; i < 10; i++) {
planets.push({
x: $fx.rand() * canvas.w * 0.6 + canvas.w * 0.2,
y: $fx.rand() * canvas.h * 0.6 + canvas.h * 0.2,
size: $fx.rand() * e/4 + e/8,
color: planetColors[i % planetColors.length]
});
}
Our universe wouldn’t be complete without planets! These ethereal planets are given positions, sizes, and colors that come from our planetColors array. The randomness ensures that each planet has its own character, making the scene feel alive and varied.
Animating the Cosmos: The Draw Function
function draw() {
background(16, 24, 32, 30); // Deep dark background with a subtle transparency for trails
translate(canvas.w / 2, canvas.h / 2);
// Slowly rotate the entire scene for a dynamic experience
rotate(time * 0.1);
The draw() function is where the magic unfolds continuously. Each frame is like a heartbeat of the universe, where everything comes alive. We start with a dark, mysterious background, then move to the center of our canvas and begin a gentle rotation, creating a feeling of cosmic dance.
Weaving the Arcs of Magic
for (let i = 0; i < 4; i++) {
let diameter = 16*e/100 + i * (canvas.w / 6) + sin(time + i * 10) * e/40; // Pulsing effect on arcs
let startAngle = (time * 0.5 + $fx.rand() * 360) % 360;
let endAngle = startAngle + $fx.rand() * 90 + 90;
// Draw with enhanced magical gradient
drawMagicalArc(diameter, startAngle, endAngle, i);
}
The arcs, like the trails of comets, pulse and rotate around the center. Each arc has a unique size and angle, giving it a life of its own. The arcs change subtly over time, as if they’re breathing along with the cosmos. We use the drawMagicalArc() function to actually paint these arcs on the canvas.
Adding the Final Touches: Planets, Particles, and Sparkles
drawPlanets();
drawMagicalOrbs();
drawFrostParticles();
drawSparkles();
Finally, we draw our planets, magical orbs, frost particles, and sparkles. These elements bring the scene together, creating a vibrant and dynamic universe. Each function—drawPlanets(), drawMagicalOrbs(), drawFrostParticles(), and drawSparkles()—adds a layer of beauty, making the scene feel full and alive.
Time's Rhythm
time += 0.5;
}
With each frame, time moves forward, and the universe continues its dance. This simple line of code ensures that the movement is smooth and continuous, just like the flow of time itself.
Saving a Moment in Time
function keyPressed() {
if (key === 's') {
saveGif('mySketch', 5);
}
}
When you see a particularly beautiful moment in our cosmic dance, you can press the 's' key to save a 5-second GIF. This function captures that fleeting beauty and preserves it forever, like a photograph of a memory.
Enjoy your journey through the stars💙
For having the complete code, visit "Sparrow Hawk" repository on GitHub!
***woven with love and creativity by the "Frostbond Coders" ***