A creative coding animation example making something with sine.
Description of this creative coding animation.
Creative coding animation that was made with Processing.
It's the sine curve with wide space between plots.
I wanted to make something with a sine.
I tried several patterns and finally, I found this way. Not use any curve line just dots. And I draw lines with vertex() not a node garden.
This code does not display any images on the screen but generates image files in frames directory.
You can make an animation with these files.
The 'Processing' code example.
Please feel free to use this example code under the terms of the GPL.
To see other works based on my code is my pleasure. And my honor.
// Connect the Dots. // @author @deconbatch // @version 1.0 // Processing 3.2.1 // 2018.08.22 /* Main ---------- */ void setup() { size(720, 720); colorMode(HSB, 360, 100, 100, 100); smooth(); rectMode(CENTER); noLoop(); } void draw() { int frameCntMax = ceil(15 * 6); // 15fps x 6s int waveCntMax = 6; int dotCntMax = 10; int lineInterval = floor(random(dotCntMax / 2.0 + 1, dotCntMax)); float hueBase = random(360.0); ArrayList<wavecalculator> wcArray = waveCalculatorInit(waveCntMax); translate(width / 2.0, height / 2.0); for (int frameCnt = 0; frameCnt < frameCntMax; ++frameCnt) { float time = easeInOutQuadratic(map(frameCnt, 0, frameCntMax, 0.0, 1.0)); float noisePrm = sin(PI * time) * 0.5; int lineFactor = 0; background((hueBase + 60.0) % 360.0, 5.0, 90.0, 100.0); beginShape(TRIANGLE_STRIP); for (WaveCalculator wc : wcArray) { wc.setTime(time); lineFactor += lineInterval; drawContents(wc, dotCntMax, lineFactor, hueBase, noisePrm); } endShape(); casing(); saveFrame("frames/" + String.format("%04d", frameCnt) + ".png"); } exit(); } ArrayList<wavecalculator> waveCalculatorInit(int waveCntMax) { ArrayList<wavecalculator> wcArray = new ArrayList<wavecalculator>(); float freqMin = 0.1; float freqDiv = freqMin; float freq = freqMin; for (int i = 0; i < waveCntMax; ++i) { float freqLast = freq; freq += freqDiv; freqDiv = freqLast; } float freqMax = freq; freqDiv = freqMin; freq = freqMin; for (int i = 0; i < waveCntMax; ++i) { float freqLast = freq; float freqRate = map(i, 0, waveCntMax, 0.0, 1.0); float phaseInit = random(1.0); float ampBase = min(width, height) * (0.05 + freqRate * 0.2); // freq : Fibonacci numbers wcArray.add(new WaveCalculator(freq, freqRate, phaseInit, ampBase)); freq += freqDiv; freqDiv = freqLast; } return wcArray; } float easeInOutQuadratic(float t) { t *= 2.0; if (t < 1.0) { return pow(t, 2) / 2.0; } t -= 1.0; return -(t * (t - 2) - 1.0) / 2.0; } void drawContents(WaveCalculator wc, int dotCntMax, int lineFactor, float hueBase, float noisePrm) { float direction = 1.0; float lineDisplayLimit = 0.2; for (int dotCnt = 0; dotCnt <= dotCntMax; ++dotCnt) { float xRate = dotCnt * 1.0 / dotCntMax; float posX = direction * map(xRate, 0.0, 1.0, -width * 0.4, width * 0.4); float posY = direction * wc.getY(xRate); float pSize = wc.getSize(xRate); float pHue = (wc.getHue(xRate) + hueBase) % 360.0; float pSat = wc.getSaturation(xRate); float pBri = wc.getBrightness(xRate); // dot noStroke(); fill(pHue, pSat, pBri, 100.0); ellipse(posX, posY, pSize, pSize); ellipse(posY, -posX, pSize, pSize); // rotate HALF_PI // line float noiseVal = noise(noisePrm); if (dotCnt == (lineFactor % dotCntMax) && noiseVal > lineDisplayLimit) { noFill(); strokeWeight(1.0); stroke(pHue, pSat, pBri, map(noiseVal, lineDisplayLimit, 1.0, 0.0, 100.0)); vertex(posX, posY); vertex(posY, -posX); } direction *= -1; // rotate PI noisePrm += 2.0; } } void casing() { fill(0.0, 0.0, 100.0, 0.0); strokeWeight(60); stroke(0.0, 0.0, 30.0, 100.0); rect(0.0, 0.0, width, height); strokeWeight(50.0); stroke(0.0, 0.0, 100.0, 100.0); rect(0.0, 0.0, width, height); noStroke(); } /* WaveCalculator ---------- */ public class WaveCalculator { private float freq; private float freqRate; private float phaseInit; private float phase; private float ampBase; private float pxRateDiv; private float ampMultDiv; WaveCalculator(float freq, float freqRate, float phaseInit, float ampBase) { this.freq = freq; this.freqRate = freqRate; this.phaseInit = phaseInit; this.phase = phaseInit; this.ampBase = ampBase; } public void setTime(float time) { phase = phaseInit + time; } public float getY(float xRate) { float y = ampBase * sin(TWO_PI * (freq * xRate + phase)); return y; } public float getSize(float xRate) { float pSize = 20.0 * sin(PI * (freq * xRate + phase)) ; return pSize; } public float getHue(float xRate) { float pHue = 30.0 * sin(TWO_PI * (freq * xRate)) ; return pHue; } public float getSaturation(float xRate) { float pSat = 0.0 + map(sin(TWO_PI * (freq * xRate + phase * 2.0)), -1.0, 1.0, 20.0, 60.0) ; return pSat; } public float getBrightness(float xRate) { float pBri = 1.0 * map(freqRate, 0.0, 1.0, 60.0, 100.0) * sin(HALF_PI * map(xRate, 0.0, 1.0, 0.5, 1.0)) ; return pBri; } } /* Copyright (C) 2018- deconbatch This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/> */
Yet another example image.