Fun with the sine curve will not fade away.
A translunary flower with sine curve.
It's an animation work that was made with the 'Processing'.
When I was playing around the sine curve, I found a funny shape. That shape seems to appear when I drew lines previous (x, y) to current (y, x). The x and y are both calculated with the sin() function.
I adjusted line count, with, alpha value, etc, and made this eternally looping animation.
This creative coding code does not display any images on the screen but generates image files for animation. You can make an animation with these files.
The 'Processing' example code.
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.
// Fading Like a Flower. // @author @deconbatch // @version 0.1 // Processing 3.2.1 // 2019.01.05 void setup() { size(720, 720); colorMode(HSB, 360, 100, 100, 100); rectMode(CENTER); smooth(); noStroke(); noFill(); noLoop(); } void draw() { int frameCntMax = 24 * 6; int waveCntMax = 500; float baseWidth = width * 0.22 / waveCntMax; float baseHeight = width * 0.22; float baseHue = random(360); float baseDiv = random(0.4, 0.8); float waveDiv = random(0.00, 0.05); // must be smaller than baseDiv float prevX = 0.0; float prevY = 0.0; translate(width / 2, height / 2); for (int frameCnt = 0; frameCnt < frameCntMax; ++frameCnt) { pushMatrix(); rotate(PI * 0.25); // just an adjustment for fancy angle background(baseHue, 100.0, 20.0, 100.0); for (int waveCnt = 0; waveCnt < waveCntMax; ++waveCnt) { // shift start frame of easing with each line float frameRatio = map(frameCnt, 0, frameCntMax, 0.0, 1.0); float easingRatio = easeInOutCosine((frameRatio + waveCnt * 1.0 / waveCntMax) % 1.0); float waveRadian = waveCnt * TWO_PI / waveCntMax; float waveAmplitude = constrain(sin(waveCnt * PI / (waveCntMax - 1)), 0.0, 1.0); float cRadianDiv = PI * (baseDiv - waveAmplitude * waveDiv); for (float cRadian = 0.0; cRadian < TWO_PI; cRadian += cRadianDiv) { float cPers = constrain((1.0 + sin(cRadian + TWO_PI * easingRatio + waveRadian)) * 0.5, 0.0, 1.0); float cSiz = cPers * (waveAmplitude + 1.0) * 30.0; float cHue = baseHue + sin(TWO_PI * (easingRatio + waveCnt * 1.0 / waveCntMax)) * 30.0 + 360.0; float cSat = map(cPers, 0.0, 1.0, 100.0, 30.0); float cBri = map(cPers, 0.0, 1.0, 60.0, 100.0); float cAlp = map(cPers, 0.0, 1.0, 0.0, 40.0); float cX = sin(cRadian) * baseWidth + (waveCnt - (waveCntMax - 1) / 2.0) * baseWidth * 4.0; float cY = sin(cRadian + TWO_PI * frameRatio + waveRadian) * baseHeight; // to avoid straight line if (cRadian == 0.0) { prevX = cY; prevY = cX; } strokeWeight(cSiz); stroke(cHue % 360.0, cSat, cBri, cAlp); line(prevY, prevX, cX, cY); prevX = cX; prevY = cY; } } popMatrix(); casing(baseHue); saveFrame("frames/" + String.format("%04d", frameCnt) + ".png"); } exit(); } /** * easeInOutCubic easing function. * @param t 0.0 - 1.0 : linear value. * @return float 0.0 - 1.0 : eased value. */ private float easeInOutCosine(float t) { return 0.5 - cos(PI * t) * 0.5; } /** * casing : draw fancy casing * @param hueBase : casing color. */ private void casing(float baseHue) { fill(0.0, 0.0, 0.0, 0.0); strokeWeight(40.0); stroke(baseHue, 100.0, 10.0, 100.0); rect(0.0, 0.0, width, height); strokeWeight(30.0); stroke(0.0, 0.0, 90.0, 100.0); rect(0.0, 0.0, width, height); noStroke(); } /* Copyright (C) 2019- 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/> */