Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added blur/2025-5-17-20-29-12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added blur/2025-5-17-20-30-33.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added blur/2025-5-17-20-31-12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added blur/2025-5-17-20-32-30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added blur/2025-5-17-20-33-14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added blur/2025-5-17-20-35-33.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added blur/2025-5-17-20-36-16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added blur/2025-5-17-23-19-47.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added blur/2025-5-17-23-27-28.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added blur/2025-5-17-23-36-50.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added blur/2025-5-18-0-19-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added blur/2025-5-18-0-7-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added blur/2025-5-18-10-12-24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added blur/2025-5-18-10-53-36.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added blur/2025-5-18-9-47-17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
115 changes: 115 additions & 0 deletions blur/blur.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// === CONFIGURATION ===
final int WIDTH = 800;
final int HEIGHT = 800;
final color BACKGROUND_COLOR = color(220, 220, 240); // Gris clair - changez ici !

// Animation parameters
final float SHAPE_SIZE = 60;
final float SPEED = 2.0;
final float OSCILLATION_AMPLITUDE = 200;
final float OSCILLATION_SPEED = 0.02;
final float HUE_SPEED = 1.5;

// === VARIABLES ===
PGraphics canvas;
PShader blurShader;
float yPos = 0;
int frameCounter = 0;
long seed;
boolean firstFrame = true;

void settings() {
size(WIDTH, HEIGHT, P2D);
}

void setup() {
colorMode(HSB, 360, 100, 100);

// Generate seed
seed = System.currentTimeMillis();
randomSeed(seed);
noiseSeed(seed);

// Create canvas
canvas = createGraphics(WIDTH, HEIGHT, P2D);
canvas.colorMode(HSB, 360, 100, 100);

// Load blur shader
blurShader = loadShader("blur.glsl");
blurShader.set("resolution", float(WIDTH), float(HEIGHT));

// Set background color in shader (convert to RGB 0-1)
float r = red(BACKGROUND_COLOR) / 255.0;
float g = green(BACKGROUND_COLOR) / 255.0;
float b = blue(BACKGROUND_COLOR) / 255.0;
blurShader.set("bgColor", r, g, b);

println("Seed: " + seed);
}

void draw() {
// Update position
yPos += SPEED;
frameCounter++;

// Calculate shape position
float oscillation = sin(frameCounter * OSCILLATION_SPEED);
float xPos = WIDTH/2 + oscillation * OSCILLATION_AMPLITUDE;

// Calculate color (rainbow cycle)
float hue = (frameCounter * HUE_SPEED) % 360;

// Draw on canvas
canvas.beginDraw();
canvas.colorMode(HSB, 360, 100, 100);

// Only clear background on first frame
if (firstFrame) {
canvas.background(BACKGROUND_COLOR);
firstFrame = false;
}

// Draw the shape
canvas.noStroke();
canvas.fill(hue, 80, 95);
canvas.ellipse(xPos, yPos, SHAPE_SIZE, SHAPE_SIZE);

canvas.endDraw();

// Apply blur to entire canvas AFTER drawing
canvas.filter(blurShader);

// Display result
image(canvas, 0, 0);

// Display info
fill(0);
text("Frame: " + frameCounter, 10, 20);
text("Seed: " + seed, 10, 40);

// Reset when shape goes off screen
if (yPos > HEIGHT + SHAPE_SIZE) {
resetAnimation();
}
}

void resetAnimation() {
yPos = -SHAPE_SIZE;
frameCounter = 0;
firstFrame = true;

// Generate new seed
seed = System.currentTimeMillis();
randomSeed(seed);
noiseSeed(seed);
println("New seed: " + seed);
}

void keyPressed() {
if (key == 'r' || key == 'R') {
resetAnimation();
} else if (key == 's' || key == 'S') {
saveFrame("motion_blur_####.png");
println("Frame saved!");
}
}
44 changes: 44 additions & 0 deletions blur/data/blur.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif

uniform sampler2D texture;
uniform vec2 resolution;
uniform vec3 bgColor;

void main() {
vec2 uv = gl_FragCoord.xy / resolution.xy;

// Taille du flou très subtile pour éviter la "disparition"
float blurSize = 0.8 / resolution.x;

vec4 sum = vec4(0.0);
float totalWeight = 0.0;

// Kernel de flou 3x3 avec préservation de luminosité
float weights[9];
weights[0] = 0.05; weights[1] = 0.09; weights[2] = 0.05;
weights[3] = 0.09; weights[4] = 0.46; weights[5] = 0.09; // Centre plus fort
weights[6] = 0.05; weights[7] = 0.09; weights[8] = 0.05;

vec2 offsets[9];
offsets[0] = vec2(-blurSize, -blurSize); offsets[1] = vec2(0.0, -blurSize); offsets[2] = vec2(blurSize, -blurSize);
offsets[3] = vec2(-blurSize, 0.0); offsets[4] = vec2(0.0, 0.0); offsets[5] = vec2(blurSize, 0.0);
offsets[6] = vec2(-blurSize, blurSize); offsets[7] = vec2(0.0, blurSize); offsets[8] = vec2(blurSize, blurSize);

for (int i = 0; i < 9; i++) {
vec4 sample = texture(texture, uv + offsets[i]);

// Si l'échantillon est très sombre/proche du noir, utiliser la couleur de fond
float luminance = dot(sample.rgb, vec3(0.299, 0.587, 0.114));
if (luminance < 0.02) {
sample = vec4(bgColor, 1.0);
}

sum += sample * weights[i];
totalWeight += weights[i];
}

gl_FragColor = sum / totalWeight;
}
Binary file added blur/final_frame_temp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added blur/motion_blur_0190.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added blur/motion_blur_0305.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 5 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ A repository of my Processing-based generative art projects.

To create a new project:

1. Copy the `template/` folder
2. Rename it to your project name
3. Open the .pde file in Processing
4. Modify and experiment!
1. Run the `create_new_project.py` script. This will create a branch & copy the template project into a new folder.
- The script will ask for a name for the new project. This will be used as the branch name and folder name.
- Use it like this: `python .\create_new_project.py {project_name}`
2. Open the .pde file in Processing
3. Modify and experiment!

## Gallery

Expand Down