I want to electrocute you with my creative coding!
The electric discharging animation with Perlin noise.
It's a creative coding work made with Perlin noise. It's derived version of Don't Count the Waves.
I added an over-voltage electric discharge. It was not bad. But I felt something is missing. So, I tried to add some background, add some effects like lightning. But it not worked. Too complex and was in a mess. Finally, I added some gas. I wonder it was right or wrong...
'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.
// Live Wire. // Processing 3.2.1 // 2017.12.03 /* ---------------------------------------------------------------------- */ class Wires { int cntWidthMax; int divRotate; int cntRotateMax; float baseWireSize, initWireSize; float baseColor; float petalBaseFrom, petalBaseTo, petalDivFrom, petalDivTo; Wires() { divRotate = 40; // divide 360 degree with this cntRotateMax = 3 * 360 * divRotate; // draw while rotating cntWidthMax = 8; // repeat same shape with different ellipse size (=line width) initWireSize = 300; // initial shape size baseWireSize = initWireSize; // shape size baseColor =random(360); } void drawWires() { for (int cntWidth = 1; cntWidth <= cntWidthMax; ++cntWidth) { float noiseHue = noiseHueStart + cntWidth / (cntWidthMax * 100); float noiseSat = noiseSatStart; float noiseBri = noiseBriStart; float noiseAlp = noiseAlpStart; float noiseShp = noiseShpStart;; float prmSat = map(cntWidth, 1, cntWidthMax, 0.3, 1.0); // parameter of saturation float prmSiz = cntWidth * cntWidth; // parameter of ellipse size float sumRotation = 0; for (int cntRotate = 0; cntRotate < cntRotateMax; ++cntRotate) { // rotate fixed degree and calculate the plot point float rotation = 1.0 / divRotate; canvasRotation(rotation); sumRotation += rotation * map(noise(noiseShp), 0.0, 1.0, -0.6, 1.0); float posDot = baseWireSize * (sin(radians(sumRotation)) + map(noise(noiseShp / 2.0), 0.0, 1.0, -0.2, 0.8)); float brushHue = (baseColor + 360 + map(noise(noiseHue), 0.0, 1.0, -45.0, 45.0)) % 360; float brushSat = map(noise(noiseSat), 0.0, 1.0, 30.0, 90.0) * prmSat; float brushBri = map(noise(noiseBri), 0.0, 1.0, 0.0, 100.0) / prmSiz; float brushAlp = map(noise(noiseAlp), 0.0, 1.0, 10.0, 100.0); float brushSiz = map(noise(noiseBri), 0.0, 1.0, 0.0, 1.0 * prmSiz); // main line drawLine(posDot, brushHue, brushSat, brushBri, brushAlp, brushSiz); drawLine(-posDot * 0.4, brushHue, brushSat, brushBri, brushAlp, brushSiz); // mirror image // electric discharge if (cntWidth == 1 || cntWidth == cntWidthMax) { if (noise(noiseBri) > 0.4) { float distDot = map(noise(noiseSat * 2.0), 0.0, 1.0, 1.0, -1.0); float multDot = map(noise(noiseAlp * 5.0), 0.0, 1.0, 0.0, 0.5); float distBri = map(abs(distDot * multDot), 0.0, 0.5, 0.0, posDot * 2.0) / baseWireSize; if (cntWidth == 1) { drawLine( posDot * (1.0 + distDot * multDot), brushHue, brushSat * 3.0, brushBri * distBri * 4.0, brushAlp, brushSiz * distBri * 2.5 ); } if (cntWidth == cntWidthMax) { drawLine( posDot * (1.0 + distDot * multDot), brushHue, brushSat * 2.0, brushBri * distBri * 1.8, brushAlp * 1.0, brushSiz * distBri * 1.5 ); } } } // Gas if (cntWidth == cntWidthMax) { float distDot = map(random(1.0), 0.0, 1.0, 0.0, 3.0); drawLine(posDot * distDot, brushHue, brushSat * 2.0, brushBri * posDot * distDot / baseWireSize, brushAlp * 1.0, brushSiz * 1.0 ); } noiseHue += 0.0002; noiseSat += 0.0008; noiseBri -= 0.0010; noiseAlp -= 0.0012; noiseShp += 0.0006; } canvasRotation(-cntRotateMax); } } void drawLine(float brushPosition, float brushHue, float brushSat, float brushBri, float brushAlp, float brushSiz) { pushMatrix(); translate(0.0, brushPosition); fill(brushHue, brushSat, brushBri, brushAlp); ellipse(0.0, 0.0, brushSiz, brushSiz); popMatrix(); } void canvasRotation(float degrees) { rotate(radians(degrees)); } void zooming(float zoomRate) { baseWireSize = initWireSize * zoomRate; } } /* ---------------------------------------------------------------------- */ Wires pt; float noiseShpStart; float noiseHueStart; float noiseBriStart; float noiseAlpStart; float noiseSatStart; float initRotation; void setup() { size(720, 720); colorMode(HSB, 360, 100, 100, 100); blendMode(SCREEN); smooth(); noStroke(); // noLoop(); // frameRate(1); noiseShpStart = random(100.0); noiseHueStart = random(100.0); noiseBriStart = random(100.0); noiseAlpStart = random(100.0); noiseSatStart = random(100.0); initRotation = random(360); pt = new Wires(); } void draw() { int frameCountMax = 300; // draw image number background(0, 0, 0); translate(width / 2, height / 2); pt.canvasRotation(initRotation); pt.canvasRotation(-frameCount / 4.0); pt.zooming(map(frameCount, 1, frameCountMax, 1.0, 0.8)); pt.drawWires(); noiseHueStart += 0.015; noiseSatStart += 0.070; noiseBriStart -= 0.090; noiseAlpStart -= 0.080; noiseShpStart += 0.015; saveFrame("frames/lv####.png"); if (frameCount >= frameCountMax) { exit(); } } /* Copyright (C) 2017- 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/> */