# Journey through the stars

**URL:** <https://discourse.processing.org/t/journey-through-the-stars/48473>\
**Category:** Gallery\
**Created:** [April 26, 2026, 10:15pm UTC](https://discourse.processing.org/t/journey-through-the-stars/48473 "2026-04-26T22:15:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [April 26, 2026, 10:15pm UTC](https://discourse.processing.org/t/journey-through-the-stars/48473/1 "2026-04-26T22:15:20Z")

</div>

Hello folks!

Best enjoyed in the darkness of space.

> **Code**
>
> ```processing
> /*
> * Eye Candy
> * 
> * Author: glv
> * Date: 2026-04-26
> * 
> * Description:
> * It started out as a starfield.
> * It is now a network of threads,
> * connecting and binding them together
> * in an inexorable evolution,
> * leaving a path to follow between the stars.
> * Watch it grow.
> * Choose the right path.
> */
> 
> PVector[] starfield;
> 
> void settings()
> {
> size(500, 500, JAVA2D); // JAVA2D better performance than P2D
> }
> 
> void setup()
> {  
> background(255);
> surface.setLocation(10, 10);
> starfield = new PVector[1000];
> makeStarfield();  
> sortStarfield();
> colorMode(HSB, 360, 100, 100, 100);
> strokeWeight(3);
> }
>   
> void draw()
> {
> background(0);
> updateStarfield();
> sortStarfield();  
> float phase = (25 + frameCount*0.5 + 360)%360;
>   
> for (int i = 0; i < starfield.length; i++)
> {      
> float xi = starfield[i].x;
> float yi = starfield[i].y;  
>       
> for (int j = i + 1; j < starfield.length; j++)
> {   
> float xj = starfield[j].x;
> float yj = starfield[j].y;
>               
> float dx = xj - xi;
> 
> if (dx > 19)
> break;
> 
> float dy = yj - yi;
> if (dy > 19 || dy < -19)
> continue;
>       
> float dd = dx*dx + dy*dy;
> 
> if (dd < 360)
> {
> // Complicated song and dance:                  
> float cl = 120 - dd/3;
> float hue = (phase-cl+360)%360;
> float alpha = cl*5.0/6;
>         
> stroke(hue, 100, 100, alpha);
> line(xi, yi, xj, yj);
> } 
> } 
> }
> }
> 
> // Bubble sort x
> void sortStarfield() 
> {
> PVector t;
> boolean done = false;
>   
> while(!done) 
> {
> done = true; // Assume sorted unless a swap occurs
>     
> for (int i = 0; i < starfield.length - 1; i++) 
> {
> if (starfield[i].x > starfield[i + 1].x) 
> {
> // Swap elements if they're out of order
> t = starfield[i];
> starfield[i] = starfield[i + 1];
> starfield[i + 1] = t;
>         
> done = false; // Mark that a swap occurred, so continue sorting
> }
> }
> }
> }
>   
> void updateStarfield()
> {
> for (int i=0; i<starfield.length; i++)
> {
> starfield[i].x += random(-0.5, 0.5);
> starfield[i].y += random(-0.5, 0.5);
> }
> }
> 
> void makeStarfield()
> {
> for (int i=0; i<starfield.length; i++)
> {   
> float a = random(TWO_PI);
> float r = sqrt(random(1)) * 200;
> float x = 250 + r*cos(a);
> float y = 250 + r*sin(a); 
> starfield[i] = new PVector(x, y);
> }  
> }
> 
> ```

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/5/2/52f92ce81ba385f8565ccaa2685e148de755610f.png)

Suggested listening while running sketch:

> **David Bowie - Space Oddity (Official Video)**
>
> [https://www.youtube.com/watch?v=iYYRH4apXDo](https://www.youtube.com/watch?v=iYYRH4apXDo)

`:)`
