From 348fed6606529be1cc8df6b4d8e6246a9e02358d Mon Sep 17 00:00:00 2001 From: Mark Slee Date: Thu, 19 Sep 2013 23:38:15 -0700 Subject: [PATCH] Add a frame blurring effect --- MarkSlee.pde | 41 +++++++++++++++++++++++++++++++++++++++++ SugarCubes.pde | 1 + 2 files changed, 42 insertions(+) diff --git a/MarkSlee.pde b/MarkSlee.pde index 5d08a86..7738419 100644 --- a/MarkSlee.pde +++ b/MarkSlee.pde @@ -811,3 +811,44 @@ class ColorFuckerEffect extends SCEffect { } } } + +class BlurEffect extends SCEffect { + + final LXParameter amount = new BasicParameter("AMT", 0); + final int[] frame; + final LinearEnvelope env = new LinearEnvelope(0, 1, 100); + + BlurEffect(GLucose glucose) { + super(glucose); + addParameter(amount); + addModulator(env); + frame = new int[lx.total]; + for (int i = 0; i < frame.length; ++i) { + frame[i] = #000000; + } + } + + public void onEnable() { + env.setRangeFromHereTo(1, 400).start(); + for (int i = 0; i < frame.length; ++i) { + frame[i] = #000000; + } + } + + public void onDisable() { + env.setRangeFromHereTo(0, 1000).start(); + } + + public void doApply(int[] colors) { + float amt = env.getValuef() * amount.getValuef(); + if (amt > 0) { + amt = (1 - amt); + amt = 1 - (amt*amt*amt); + for (int i = 0; i < colors.length; ++i) { + // frame[i] = colors[i] = blendColor(colors[i], lerpColor(#000000, frame[i], amt, RGB), SCREEN); + frame[i] = colors[i] = lerpColor(colors[i], blendColor(colors[i], frame[i], SCREEN), amt, RGB); + } + } + + } +} diff --git a/SugarCubes.pde b/SugarCubes.pde index 21bd8ac..d589248 100644 --- a/SugarCubes.pde +++ b/SugarCubes.pde @@ -124,6 +124,7 @@ LXEffect[] effects(GLucose glucose) { return new LXEffect[] { new FlashEffect(lx), new BoomEffect(glucose), + new BlurEffect(glucose), new DesaturationEffect(lx), new ColorFuckerEffect(glucose), }; -- 2.34.1