diff --git a/blur/2025-5-17-20-29-12.png b/blur/2025-5-17-20-29-12.png new file mode 100644 index 0000000..d5496f1 Binary files /dev/null and b/blur/2025-5-17-20-29-12.png differ diff --git a/blur/2025-5-17-20-30-33.png b/blur/2025-5-17-20-30-33.png new file mode 100644 index 0000000..1493a29 Binary files /dev/null and b/blur/2025-5-17-20-30-33.png differ diff --git a/blur/2025-5-17-20-31-12.png b/blur/2025-5-17-20-31-12.png new file mode 100644 index 0000000..d6ddd63 Binary files /dev/null and b/blur/2025-5-17-20-31-12.png differ diff --git a/blur/2025-5-17-20-32-30.png b/blur/2025-5-17-20-32-30.png new file mode 100644 index 0000000..c21561a Binary files /dev/null and b/blur/2025-5-17-20-32-30.png differ diff --git a/blur/2025-5-17-20-33-14.png b/blur/2025-5-17-20-33-14.png new file mode 100644 index 0000000..49dc260 Binary files /dev/null and b/blur/2025-5-17-20-33-14.png differ diff --git a/blur/2025-5-17-20-35-33.png b/blur/2025-5-17-20-35-33.png new file mode 100644 index 0000000..673ca0b Binary files /dev/null and b/blur/2025-5-17-20-35-33.png differ diff --git a/blur/2025-5-17-20-36-16.png b/blur/2025-5-17-20-36-16.png new file mode 100644 index 0000000..7f025e2 Binary files /dev/null and b/blur/2025-5-17-20-36-16.png differ diff --git a/blur/2025-5-17-23-19-47.png b/blur/2025-5-17-23-19-47.png new file mode 100644 index 0000000..b41d31e Binary files /dev/null and b/blur/2025-5-17-23-19-47.png differ diff --git a/blur/2025-5-17-23-27-28.png b/blur/2025-5-17-23-27-28.png new file mode 100644 index 0000000..dd46813 Binary files /dev/null and b/blur/2025-5-17-23-27-28.png differ diff --git a/blur/2025-5-17-23-36-50.png b/blur/2025-5-17-23-36-50.png new file mode 100644 index 0000000..bd8cd95 Binary files /dev/null and b/blur/2025-5-17-23-36-50.png differ diff --git a/blur/2025-5-18-0-19-5.png b/blur/2025-5-18-0-19-5.png new file mode 100644 index 0000000..8ec5ff8 Binary files /dev/null and b/blur/2025-5-18-0-19-5.png differ diff --git a/blur/2025-5-18-0-7-3.png b/blur/2025-5-18-0-7-3.png new file mode 100644 index 0000000..ad522d0 Binary files /dev/null and b/blur/2025-5-18-0-7-3.png differ diff --git a/blur/2025-5-18-10-12-24.png b/blur/2025-5-18-10-12-24.png new file mode 100644 index 0000000..1fcdc97 Binary files /dev/null and b/blur/2025-5-18-10-12-24.png differ diff --git a/blur/2025-5-18-10-53-36.png b/blur/2025-5-18-10-53-36.png new file mode 100644 index 0000000..a18f34f Binary files /dev/null and b/blur/2025-5-18-10-53-36.png differ diff --git a/blur/2025-5-18-9-47-17.png b/blur/2025-5-18-9-47-17.png new file mode 100644 index 0000000..4b76eb9 Binary files /dev/null and b/blur/2025-5-18-9-47-17.png differ diff --git a/blur/blur.pde b/blur/blur.pde new file mode 100644 index 0000000..5071ba7 --- /dev/null +++ b/blur/blur.pde @@ -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!"); + } +} \ No newline at end of file diff --git a/blur/data/blur.glsl b/blur/data/blur.glsl new file mode 100644 index 0000000..3933413 --- /dev/null +++ b/blur/data/blur.glsl @@ -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; +} \ No newline at end of file diff --git a/blur/final_frame_temp.png b/blur/final_frame_temp.png new file mode 100644 index 0000000..6f3852f Binary files /dev/null and b/blur/final_frame_temp.png differ diff --git a/blur/motion_blur_0190.png b/blur/motion_blur_0190.png new file mode 100644 index 0000000..7fae4c4 Binary files /dev/null and b/blur/motion_blur_0190.png differ diff --git a/blur/motion_blur_0305.png b/blur/motion_blur_0305.png new file mode 100644 index 0000000..17edce0 Binary files /dev/null and b/blur/motion_blur_0305.png differ diff --git a/readme.md b/readme.md index 37fb2c5..d028740 100644 --- a/readme.md +++ b/readme.md @@ -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