diff options
author | Santo Cariotti <santo@dcariotti.me> | 2021-02-18 21:37:27 +0100 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2021-02-18 21:37:27 +0100 |
commit | 11a9840840fe74574ed259b3546c412a0659ec0d (patch) | |
tree | b4fb0b32ab12894d24fe239bb1b12c09d955f575 /Year_2/IandM/minimum/minimum.pde | |
parent | eb95e7518229b8263e870f6c28a4a4f2a00ec065 (diff) |
i&m: value on keypressed
Diffstat (limited to 'Year_2/IandM/minimum/minimum.pde')
-rw-r--r-- | Year_2/IandM/minimum/minimum.pde | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/Year_2/IandM/minimum/minimum.pde b/Year_2/IandM/minimum/minimum.pde index b960a24..c2057c8 100644 --- a/Year_2/IandM/minimum/minimum.pde +++ b/Year_2/IandM/minimum/minimum.pde @@ -1,11 +1,23 @@ +int k = 1; void setup() { size(512, 256); +} + +void draw() { PImage img = loadImage("lena.png"); img.resize(256, 256); img.filter(GRAY); image(img, 0, 0); - image(minimum(img, 11), 256, 0); + image(minimum(img, k), 256, 0); +} + +void keyPressed() { + if (key == '+') { + k++; + } else if (key == '-') { + k--; + } } PImage minimum(PImage I, int n) { @@ -18,11 +30,11 @@ PImage minimum(PImage I, int n) { PImage t = I.get(x-off, y-off, n, n); float[] tarr = new float[n*n]; t.loadPixels(); - - for(int i = 0; i < t.pixels.length; ++i) { + + for (int i = 0; i < t.pixels.length; ++i) { tarr[i] = red(t.pixels[i]); } - + out.set(x, y, color(min(tarr))); } } |