From 297f761a76f46c4576d17360f2377cb03f6be82c Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Sat, 16 Jul 2022 15:45:42 +0200 Subject: [PATCH] added fxCopyZoom --- effects.pde | 34 ++++++++++++++++++++++++++++++++++ secondapplet.pde | 13 ++++++++----- statics_and_lists.pde | 2 +- 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/effects.pde b/effects.pde index 54f71d7..360e5cb 100644 --- a/effects.pde +++ b/effects.pde @@ -1793,7 +1793,41 @@ class GRAUZONE extends Shader { } } +/* + COPYZOOM + + */ + +class COPYZOOM extends Shader { + int coprx, copry, coprw, coprh; + PImage buffer; + COPYZOOM() { + name = "fxCopyZoom"; + params.add(new Param("w", FLOATVAL, 0, 1, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE})); + params.add(new Param("h", FLOATVAL, 0, 1, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE})); + params.add(new Param("x", FLOATVAL, 0, 1, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE})); + params.add(new Param("y", FLOATVAL, 0, 1, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE})); + buffer = createImage(renderer.width, renderer.height, ARGB); + + coprw = int(random(0, renderer.width)); + coprh = int(random(0, renderer.height)); + coprx = int(random(0, renderer.width-coprw)); + copry = int(random(0, renderer.height-coprh)); + } + void apply() { + if (buffer.width != renderer.width || buffer.height != renderer.height) buffer.resize(renderer.width, renderer.height); + buffer = renderer.get(); + coprw = int(map(params.get(0).value, 0, 1, 1, renderer.width)); + coprh = int(map(params.get(1).value, 0, 1, 1, renderer.height)); + coprx = int(map(params.get(2).value, 0, 1, 0, renderer.width-coprw)); + copry = int(map(params.get(3).value, 0, 1, 0, renderer.height-coprh)); + renderer.beginDraw(); + buffer.copy(coprx, copry, coprw, coprh, 0, 0, renderer.width, renderer.height); + renderer.image(buffer, 0, 0, renderer.width, renderer.height); + renderer.endDraw(); + } +} /* diff --git a/secondapplet.pde b/secondapplet.pde index 2e2c9eb..d229f3d 100644 --- a/secondapplet.pde +++ b/secondapplet.pde @@ -45,10 +45,10 @@ public class SecondApplet extends PApplet { .setSize(15, 15) .plugTo(this, "CP5_pauseAllAction"); pauseAll.getCaptionLabel().getStyle().setMargin(-17, 0, 0, 20); - + Bang nativeReso = cp5.addBang("native reso") - .setPosition(220,height-35) - .setSize(15,15) + .setPosition(220, height-35) + .setSize(15, 15) .plugTo(this, "CP5_nativeResoAction"); //nativeReso.getCaptionLabel().getStyle().setMargin(-17,0,0,20); @@ -102,10 +102,10 @@ public class SecondApplet extends PApplet { totalBrickHeight+= bricks.get(i).h; } popMatrix(); - if(heightOverLimit){ + if (heightOverLimit) { strokeWeight(3); fill(255); - line(width-5,-scrollAmount+4,width-5,height-120+(maxSurfaceHeight-120-totalBrickHeight)-scrollAmount-4); + line(width-5, -scrollAmount+4, width-5, height-120+(maxSurfaceHeight-120-totalBrickHeight)-scrollAmount-4); //-scrollAmount + (-1*(maxSurfaceHeight-120-totalBrickHeight))); } fill(68, 68, 68); @@ -551,6 +551,9 @@ public class SecondApplet extends PApplet { case(15): shaderManager.addShader(new GRAUZONE()); break; + case(16): + shaderManager.addShader(new COPYZOOM()); + break; /* case(4): shaderManager.addShader(new AUECHO()); diff --git a/statics_and_lists.pde b/statics_and_lists.pde index b65b62e..535214b 100644 --- a/statics_and_lists.pde +++ b/statics_and_lists.pde @@ -57,9 +57,9 @@ String availableFx[] = { "fxPosterize", "fxDual", "fxGrauzone", + "fxCopyZoom", "fxMove", - "fxCopyZoom", "fxScanker", "fxPixelSort",