r/processing • • 2d ago

p5js Neural Canvas, CNN Visualization with p5.js

95 Upvotes

Neural Canvas, CNN Visualization with p5.js

Used p5.js to build a neural network visualizer where you can see neurons and convolutional feature maps in real time.

The model was trained in Python using JAX. I exported the parameters to JavaScript using JSON, used Math.js for feedforward computations, and p5.js for visualization.

GitHub: https://github.com/MuhammadEssa2002/neural_canvas

Live demo: https://muhammadessa2002.github.io/neural_canvas/


r/processing • • 2d ago

Homework hint request showSumOfArray(), showAverageOfArray(), and showCountBetween70and90()

0 Upvotes

Hey! I was given this assignment from an intro to problem solving class and I was just thrown into it without much help besides the first stuff in it, but that's really it and the assignment wasn't talked about in class. When I ask the professor for help and saying I don't understand she simply says to "play around with it". I don't need the answers, just a push in the right direction if able ^^. It's due Friday and the forums on processing aren't helping at all.

Here it is

// For this programming assignment, you will write the last 3 functions/subprograms.

// at the end of this file.

// Your code will use the array called "numbers" and the variable holding the

// count of the number of values in the array called "numberCount".

// The subprograms you will write are:

// 1. showSumOfArray() - this method adds the values in the array and then

// displays the sum.

// 2. showAverageOfArray() - this method calculates the average of the values

// in the array and then displays the average.

// 3. showCountBetween70and90() - this method counts the number of values in the

// array that are between 70 and 90 and then displays that count.

char c; // holds single character

int mx, my; // assigned mouseX and mouseY

String initialText = "(Enter Numbers)";

String str = ""; // holds string input

int strNumber; // holds numeric representation of string input

int[] numbers = new int[10];

String arrayString = ""; // For displaying the array

int numberCount = 0; // holds number of values in the array

String errorMSG = "";

String sum = ""; // Used to display the sum

String average = ""; // Used to display the average

String between70and90 = ""; // Used to display the count of values between 70 and 90

int tbx = 50, tby = 50, tbw = 200, tbh = 40; // textbox

int dx = 530, dy = 50, dw = 150, dh = 40; // display

int rx = 700, ry = 50, rw = 150, rh = 40; // reset

int b1x = 50, b1y = 140, b1w = 300, b1h = 40; // place in array button

int b2x = 50, b2y = 200, b2w = 300, b2h = 40; // show sum buton

int b3x = 50, b3y = 260, b3w = 300, b3h = 40; // show average button

int b4x = 50, b4y = 320, b4w = 300, b4h = 40; // show count between 70 and 90 button

void setup() {

size(900, 600);

textSize(24);

strokeWeight(3);

}

void draw() {

background(234, 247, 251);

fill(0, 96, 128);

text("Enter a number and click on \"Place In Array\" to put the number in the array",50,30);

// textbox

fill(250);

rect(tbx, tby, tbw, tbh);

fill(100);

text(initialText, tbx + 9, tby + 30);

// text in textbox to show THE number

fill(0);

text(str, tbx + 9, tby + 30);

fill(255,0,0);

text(errorMSG, tbx + tbw + 20, tby + 30); // test msg

fill(0);

// Display Array Button

fill(21, 162, 208);

rect(dx, dy, dw, dh);

fill(0);

text("DisplayArray", dx + 3, dy +30);

text(arrayString, dx + 40, dy + 80);

// Reset Button

fill(21, 162, 208);

rect(rx, ry, rw, rh);

fill(0);

text("Reset Array", rx + 15, ry +30);

// Place in Array Button

fill(21, 162, 208);

rect(b1x, b1y, b1w, b1h);

fill(0);

text("Place In Array", b1x + 2, b1y +30);

// Show Sum Button

fill(21, 162, 208);

rect(b2x, b2y, b2w, b2h);

fill(0);

text("Show Sum", b2x + 2, b2y + 30);

text(sum, b2x + b2w + 5, b2y + 30);

// Show Average Button

fill(21, 162, 208);

rect(b3x, b3y, b3w, b3h);

fill(0);

text("Show Average", b3x + 2, b3y +30);

text(average, b3x + b3w + 5, b3y + 30);

// Number Between 70 & 90 Button

fill(21, 162, 208);

rect(b4x, b4y, b4w, b4h);

fill(0);

text("Number Between 70 & 90", b4x + 2, b4y +30);

text(between70and90, b4x + b4w + 5, b4y + 30);

}

void keyPressed() {

c = key;

initialText = "";

if ((int)c != 8 && (int)c != 65535 && c >= '0' && c <= '9') {

str += c;

}

if ((int)c == 8) {

if (str.length() > 0) {

str = str.substring(0, str.length() - 1);

} else if (str.length() == 0) {

str = "";

}

}

}

void mousePressed() {

mx = mouseX;

my = mouseY;

if ( onDisplayArrayButton(mx, my) ) {

displayArray();

} else if (onResetButton(mx, my)) {

resetArray();

} else if (onPlaceInArrayButton(mx, my)) {

placeInArray();

} else if (onShowSumButton(mx, my)) {

showSumOfArray();

} else if (onShowAverageButton(mx, my)) {

showAverageOfArray();

} else if (onCountBetween70and90Button(mx, my)) {

showCountBetween70and90();

}

}

boolean onPlaceInArrayButton(int x, int y) {

if (x > b1x && x < (b1x + b1w) && y > b1y && y < (b1y + b1h)) {

return true;

} else {

return false;

}

}

boolean onDisplayArrayButton(int x, int y) {

if (x > dx && x < (dx + dw) && y > dy && y < (dy + dh)) {

return true;

} else {

return false;

}

}

boolean onShowSumButton(int x, int y) {

if ( x > b2x && x < (b2x + b2w) && y > b2y && y < (b2y + b2h) ) {

return true;

} else {

return false;

}

}

boolean onShowAverageButton(int x, int y) {

if (x > b3x && x < (b3x + b3w) && y > b3y && y < (b3y + b3h) ) {

return true;

} else {

return false;

}

}

boolean onCountBetween70and90Button(int x, int y) {

if (x > b4x && x < (b4x + b4w) && y > b4y && y < (b4y + b4h)) {

return true;

} else {

return false;

}

}

boolean onResetButton(int x, int y) {

if (x > rx && x < (rx + rw) && y > ry && y < (ry + rh)) {

return true;

} else {

return false;

}

}

void displayArray() {

int c = 0;

String s;

arrayString = "";

while (c < numberCount) {

s = Integer.toString(numbers[c]);

arrayString += s + "\n";

c = c + 1;

}

}

void resetArray() {

arrayString = "";

for (int i = 0; i < numberCount; i++) {

numbers[i] = 0;

}

errorMSG = "";

sum = "";

average = "";

between70and90 = "";

numberCount = 0;

}

void placeInArray() {

if (numberCount == 10) {

errorMSG = "ARRAY IS FULL";

str = "";

}

if (str.length() > 0 && numberCount < 10) {

strNumber = Integer.parseInt(str);

numbers[numberCount] = strNumber;

numberCount = numberCount + 1;

str = "";

}

}

(these three parts are what we have to edit)

void showSumOfArray() {

// Write the code that will summ the values

// in the numbers array.

// Then display the result by rewriting the line below.

sum = "This displays the sum";

}

void showAverageOfArray() {

// Write the code that will summ the values

// in the numbers array and calculate the average.

// Then display the result by rewriting the line below.

average = "This displays the average";

}

void showCountBetween70and90() {

// write the code that will keep a count of the

// number of values in the numbers array that are between 70

// and 90. Then display the count by rewriting

// the line below.

between70and90 = "This displays the count of values between 70 and 90";

}

This is what it looks like when I currently run it.

That's all I have, the professor expects us to know already how to program when coming into the class whenever it's a intro intro to programming class. There's tons of people who aren't becoming programmers who have to take the course like cybersecurity. For whoever is reading this far thank you so much! It means the world


r/processing • • 5d ago

Juegos del movimiento browiano!!

0 Upvotes

Estos son juegos con sistema browiano:

LOS JUEGOS DEL HAMBRE

int numTributos = 24;

int longitudInicial = 30;

float radioArena = 260;

Tributo[] tributos;

void setup() {

size(750, 750);

colorMode(HSB, 360, 100, 100, 100);

iniciarArena();

}

void iniciarArena() {

tributos = new Tributo[numTributos];

float centroX = width / 2.0;

float centroY = height / 2.0;

for (int i = 0; i < numTributos; i++) {

// Posicionar en círculo como en la arena de Los Juegos del Hambre

float angulo = map(i, 0, numTributos, 0, TWO_PI);

float x = centroX + cos(angulo) * radioArena;

float y = centroY + sin(angulo) * radioArena;

float tono = map(i, 0, numTributos, 0, 360);

tributos[i] = new Tributo(i + 1, x, y, tono);

}

}

void draw() {

background(0, 0, 10);

dibujarArena();

// 1. Actualizar posiciones de los que siguen vivos

for (Tributo t : tributos) {

if (t.vivo) {

t.actualizar();

}

}

// 2. Comprobar colisiones (si la cabeza de A toca a B, B muere)

for (int i = 0; i < numTributos; i++) {

if (!tributos[i].vivo) continue;

for (int j = 0; j < numTributos; j++) {

if (i == j || !tributos[j].vivo) continue;

if (tributos[i].tocaA(tributos[j])) {

tributos[j].vivo = false;

tributos[i].longitudMax += 10; // La serpiente ganadora crece

}

}

}

// 3. Dibujar serpientes vivas y contar sobrevivientes

int vivos = 0;

Tributo ultimoVivo = null;

for (Tributo t : tributos) {

if (t.vivo) {

t.dibujar();

vivos++;

ultimoVivo = t;

}

}

mostrarHUD(vivos, ultimoVivo);

}

void dibujarArena() {

float cx = width / 2.0;

float cy = height / 2.0;

// Límite exterior de la arena

noFill();

stroke(0, 0, 30);

strokeWeight(2);

circle(cx, cy, (radioArena + 40) * 2);

// Cornucopia en el centro

fill(45, 70, 80, 40);

noStroke();

circle(cx, cy, 45);

}

void mostrarHUD(int vivos, Tributo ganador) {

fill(0, 0, 95);

textSize(16);

textAlign(LEFT, TOP);

text("Tributos vivos: " + vivos + " / " + numTributos, 20, 20);

textSize(12);

fill(0, 0, 65);

text("Presiona cualquier tecla para reiniciar", 20, 44);

if (vivos == 1 && ganador != null) {

textAlign(CENTER, CENTER);

textSize(28);

fill(ganador.tono, 80, 100);

text("¡GANADOR: TRIBUTO #" + ganador.id + "!", width / 2.0, 50);

}

}

class Tributo {

int id;

ArrayList<PVector> historial;

float x, y;

float paso = 5.5;

float tono;

int longitudMax;

boolean vivo = true;

Tributo(int id, float inicioX, float inicioY, float tono) {

this.id = id;

this.x = inicioX;

this.y = inicioY;

this.tono = tono;

this.longitudMax = longitudInicial;

this.historial = new ArrayList<PVector>();

this.historial.add(new PVector(x, y));

}

void actualizar() {

// Movimiento browniano en 2D

x += randomGaussian() * paso;

y += randomGaussian() * paso;

// Mantener dentro del círculo de la arena

float cx = width / 2.0;

float cy = height / 2.0;

float maxR = radioArena + 35;

float d = dist(x, y, cx, cy);

if (d > maxR) {

float angulo = atan2(y - cy, x - cx);

x = cx + cos(angulo) * maxR;

y = cy + sin(angulo) * maxR;

}

historial.add(new PVector(x, y));

while (historial.size() > longitudMax) {

historial.remove(0);

}

}

// Verifica si la cabeza de este tributo toca cualquier parte del otro

boolean tocaA(Tributo otro) {

float radioColision = 8.0;

for (PVector segmento : otro.historial) {

if (dist(this.x, this.y, segmento.x, segmento.y) < radioColision) {

return true;

}

}

return false;

}

void dibujar() {

noFill();

for (int i = 0; i < historial.size() - 1; i++) {

PVector p1 = historial.get(i);

PVector p2 = historial.get(i + 1);

float progreso = map(i, 0, historial.size() - 1, 0.15, 1.0);

stroke(tono, 85, 95, progreso * 100);

strokeWeight(progreso * 6.5);

line(p1.x, p1.y, p2.x, p2.y);

}

// Cabeza

noStroke();

fill(tono, 30, 100);

circle(x, y, 8);

}

}

void keyPressed() {

iniciarArena();

}

CAZADORES Y PRESAS

int numTotal = 24;

int longitudInicial = 30;

float radioArena = 270;

Serpiente[] participantes;

void setup() {

size(750, 750);

colorMode(HSB, 360, 100, 100, 100);

iniciarArena();

}

void iniciarArena() {

participantes = new Serpiente[numTotal];

float centroX = width / 2.0;

float centroY = height / 2.0;

for (int i = 0; i < numTotal; i++) {

float angulo = map(i, 0, numTotal, 0, TWO_PI);

float x = centroX + cos(angulo) * radioArena;

float y = centroY + sin(angulo) * radioArena;

// Intercalar: pares son Cazadores (true), impares son Presas (false)

boolean esCazador = (i % 2 == 0);

participantes[i] = new Serpiente(i + 1, x, y, esCazador);

}

}

void draw() {

background(0, 0, 10);

dibujarArena();

// 1. Actualizar movimiento de cada serpiente

for (Serpiente s : participantes) {

if (s.vivo) {

s.actualizar(participantes);

}

}

// 2. Comprobar colisiones: solo los Cazadores eliminan a las Presas

for (int i = 0; i < numTotal; i++) {

Serpiente cazador = participantes[i];

if (!cazador.vivo || !cazador.esCazador) continue;

for (int j = 0; j < numTotal; j++) {

Serpiente presa = participantes[j];

if (!presa.vivo || presa.esCazador) continue;

if (cazador.tocaA(presa)) {

presa.vivo = false;

cazador.longitudMax += 12; // El cazador crece al cazar

}

}

}

// 3. Dibujar participantes vivos y contar por equipo

int cazadoresVivos = 0;

int presasVivas = 0;

for (Serpiente s : participantes) {

if (s.vivo) {

s.dibujar();

if (s.esCazador) cazadoresVivos++;

else presasVivas++;

}

}

mostrarHUD(cazadoresVivos, presasVivas);

}

void dibujarArena() {

float cx = width / 2.0;

float cy = height / 2.0;

// Borde de la arena

noFill();

stroke(0, 0, 30);

strokeWeight(2);

circle(cx, cy, (radioArena + 40) * 2);

// Cornucopia central

fill(45, 70, 80, 35);

noStroke();

circle(cx, cy, 45);

}

void mostrarHUD(int cazadores, int presas) {

textAlign(LEFT, TOP);

textSize(16);

fill(0, 85, 95); // Rojo

text("Cazadores: " + cazadores, 20, 20);

fill(190, 85, 95); // Cian

text("Presas vivas: " + presas, 20, 44);

textSize(12);

fill(0, 0, 65);

text("Presiona cualquier tecla para reiniciar", 20, 72);

if (presas == 0) {

textAlign(CENTER, CENTER);

textSize(28);

fill(0, 85, 100);

text("¡VICTORIA DE LOS CAZADORES!", width / 2.0, 50);

}

}

class Serpiente {

int id;

boolean esCazador;

ArrayList<PVector> historial;

float x, y;

float paso = 5.5;

float tono;

int longitudMax;

boolean vivo = true;

// Parámetros de evasión para las presas

float radioDeteccion = 110.0;

float fuerzaHuida = 3.2;

Serpiente(int id, float inicioX, float inicioY, boolean esCazador) {

this.id = id;

this.x = inicioX;

this.y = inicioY;

this.esCazador = esCazador;

this.tono = esCazador ? 0 : 190; // 0 = Rojo (Cazador), 190 = Cian (Presa)

this.longitudMax = longitudInicial;

this.historial = new ArrayList<PVector>();

this.historial.add(new PVector(x, y));

}

void actualizar(Serpiente[] todos) {

// Movimiento browniano base

float dx = randomGaussian() * paso;

float dy = randomGaussian() * paso;

// Si es PRESA, detectar cazadores cercanos y retroceder

if (!esCazador) {

float huidaX = 0;

float huidaY = 0;

int amenazas = 0;

for (Serpiente otro : todos) {

if (otro.vivo && otro.esCazador) {

float d = dist(this.x, this.y, otro.x, otro.y);

if (d < radioDeteccion && d > 0) {

// Vector unitario apuntando en dirección contraria al cazador

float dirX = (this.x - otro.x) / d;

float dirY = (this.y - otro.y) / d;

// Mientras más cerca esté el cazador, mayor es el impulso de retroceso

float intensidad = map(d, 0, radioDeteccion, 1.5, 0.2);

huidaX += dirX * intensidad;

huidaY += dirY * intensidad;

amenazas++;

}

}

}

if (amenazas > 0) {

dx += huidaX * fuerzaHuida;

dy += huidaY * fuerzaHuida;

}

}

x += dx;

y += dy;

// Mantener dentro de la arena circular

float cx = width / 2.0;

float cy = height / 2.0;

float maxR = radioArena + 35;

float d = dist(x, y, cx, cy);

if (d > maxR) {

float angulo = atan2(y - cy, x - cx);

x = cx + cos(angulo) * maxR;

y = cy + sin(angulo) * maxR;

}

historial.add(new PVector(x, y));

while (historial.size() > longitudMax) {

historial.remove(0);

}

}

boolean tocaA(Serpiente otro) {

float radioColision = 9.0;

for (PVector segmento : otro.historial) {

if (dist(this.x, this.y, segmento.x, segmento.y) < radioColision) {

return true;

}

}

return false;

}

void dibujar() {

// Dibujar sutilmente el aura de detección en las presas

if (!esCazador) {

noFill();

stroke(tono, 60, 80, 12);

strokeWeight(1);

circle(x, y, radioDeteccion * 2);

}

noFill();

for (int i = 0; i < historial.size() - 1; i++) {

PVector p1 = historial.get(i);

PVector p2 = historial.get(i + 1);

float progreso = map(i, 0, historial.size() - 1, 0.15, 1.0);

stroke(tono, 85, 95, progreso * 100);

strokeWeight(progreso * (esCazador ? 7.5 : 5.5));

line(p1.x, p1.y, p2.x, p2.y);

}

// Cabeza

noStroke();

fill(tono, 25, 100);

circle(x, y, esCazador ? 9 : 7);

}

}

void keyPressed() {

iniciarArena();

}


r/processing • • 9d ago

Beginner help request What do i need to write to have an interactable window

2 Upvotes

I have an assignment where I want to have like a mini windows computer. I wanna know how I can 'open up new apps', like click on an icon on the 'desktop' and have it open up a new 'tab'. I want to have my main window, open up into a file explorer, and then have different files in the file explorer that open up into different things. but im not sure how to do it. does anyone have any ideas?


r/processing • • 12d ago

Contour Life - Procedurally Generated, Evolving Artificial Life

Thumbnail
youtube.com
8 Upvotes

I short video on how to combine particle life and the marching squares algorithm to create some very cool looking forms. It includes a brief description of an evolutionary version as well.


r/processing • • 15d ago

wild ultra (2026) done in Processing 4 by Steffen Harder

Post image
7 Upvotes

r/processing • • 17d ago

How to maintain a fixed 16:9 aspect ratio in p5.js across different screen sizes?

Post image
3 Upvotes

r/processing • • 19d ago

Help request drawing program

4 Upvotes

i’m creating a drawing program within processing and i’m trying to add a way to change the background/canvas color. within the draw function, i have a color wheel that changes the brush color, as well as a color wheel that changes the canvas color. all is going smoothly, except when i try to put it all together. if i draw the canvas within the void setup, the user is unable to change its color. however, if i draw the canvas within the void draw, it redraws itself between every iteration of the brushstroke, so the brush only ever shows up at its current state and never leaves a mark behind.

i think i worded this oddly but hopefully it makes sense. can anybody help me figure out how to allow the canvas color to change while not “erasing” the brush strokes?


r/processing • • 25d ago

Random images found inside the Processing files

4 Upvotes

Sorry if this is not the things you should post here, but while looking at my gallery i saw i had images way back from 2011-2014 and all of them where either political figures or historic pictures turns out they all came from Processing, are they test pictures, Just curious to know.


r/processing • • 26d ago

Flight - output of dynamical system

Post image
12 Upvotes

r/processing • • 28d ago

Can you guess how these patterns are generated

6 Upvotes

I am sharing a video, because it is 16K png image (100MB+ in size)


r/processing • • Nov 01 '26

randomize location every minute

3 Upvotes

hello! i am trying to create a project where a bee moves between 3 flowers. there are 3 set flower locations, and each minute, the bee will randomly choose one of the 3 flowers to fly to. if anyone could help me figure out how to write the code so that the bee chooses one of 3 coordinate sets every minute and glides to that spot, i would really appreciate it!


r/processing • • Oct 31 '26

Processing slows down by factor x 6 after adding a few lines? Bug?

0 Upvotes

Had a around 16Kb algorithm running at about 6 FPS before.

Added mere 6 lines of mostly not heavy extra Math.

Result? Runs at around 1 FPS only now.

Again, NOT heavy math compared to what I had before it.

May Processing have known bug like this?

Once more - had many lines running overall at 6 FPS. Fell to 1 FPS with handful of NOT heavy lines added to end...


r/processing • • Oct 31 '26

Check out what i made with morva studio

9 Upvotes

r/processing • • Oct 31 '26

Terrain Study II

153 Upvotes

r/processing • • Oct 24 '26

p5js Terrain Study I

202 Upvotes

r/processing • • Oct 23 '26

The Repressilator

31 Upvotes

This is a small model of repressor proteins that I got the idea of doing from this video. The white dots are ribosomes that when passing by unrepressed genes (the circles with two colors) will create an specific repressor protein. The gene shows what protein represses it and what protein it encodes for, and when repressed it looks like a black box. The proteins can randomly degrade either while floating or while blocking a gene.

This little model was enough to make a working oscilator in the first part of the video just like the real repressilator which works in bacteria. In the other half of the video I ran it with 2 proteins in the cycle and they randomly stabilize in one of them instead of forming a cycle. This pattern keeps up between odd and even. A chain of four proteins stabilizes with 2 in a high concentration and 2 at a low one, a chain of 5 makes an oscillator, etc.


r/processing • • Oct 22 '26

Audio visualizer web app

2 Upvotes

Hi all,

Im creating an audio visualizer web app that works on mobile and desktop and would love some honest feedback.

It's still in the works, with fixes and additions added ever few days.

Please give me some honest feedback.

https://geotech.mikeadigital.com/


r/processing • • Oct 20 '26

"Texereuum"

14 Upvotes

A work from 2025, made for uni project. More on my ig: https://www.instagram.com/p.lenarte?obrf=Z2JnYWNhcGlsdGxm


r/processing • • Oct 19 '26

Fragment Collapse - Steam game made with Processing!

Post image
17 Upvotes

r/processing • • Oct 15 '26

Video Some balls avoiding each other

12 Upvotes

r/processing • • Oct 12 '26

Grandad's sweater

54 Upvotes

Made in Processing

IG: www.instagram.com/slipshapes


r/processing • • Oct 11 '26

A video on programming the Marching Squares Algorithm

Thumbnail
youtube.com
13 Upvotes

I thought this video might be of interest to the community. The Marching Squares algorithm is a surprisingly simple algorithm with lots of interesting applications in map development, creative coding, game development, and scientific visualization.


r/processing • • Oct 06 '26

Call for submissions EvoMusArt 2027: International Conference on Artificial Intelligence in Music, Sound, Art and Design

Post image
0 Upvotes

The 16th International Conference on Artificial Intelligence in Music, Sound, Art and Design (EvoMusArt 2027) is accepting paper submissions.

When: 31 March – 2 April 2027
Where: Mainz, Germany
Paper Submission deadline: 1 November 2026

EvoMUSART focuses on AI and computational approaches to creativity, covering a broad range of topics, with a particular emphasis on research exploring how AI systems generate, support, evaluate, interpret, and collaborate in creative processes.

Accepted papers will be presented at the conference and published in a dedicated LNCS volume.

More information/submission details: https://www.evostar.org/2027/evomusart/

If you are working at the intersection of AI and creative practice, this may be relevant to your research. Please share with others who might be interested.


r/processing • • Oct 03 '26

Countour Lines

Thumbnail
gallery
33 Upvotes

Hey, creative people!
Been experimenting with contour lines and ended up with some pretty abstract results.

I like how changing a few parameters can completely change the character of the image. Still exploring this one, curious what you guys think.