久しぶりにProcessingを触ってみたところ、けっこうな自信作ができてしまったので記事にしてしまいます。
解説は記事を分けて複数回に分けて書くことにします。記事の最後にリンクを貼ってあるので、興味のある方はそちらもぜひ見ていってください。
ちなみに元動画はファイルが大きすぎてワードプレスには乗らなかったので、ツイートを載せる形にします。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
Spiral[] spirals; Spiral spiral; int counter; int num = 3; int totalFrames = 240; boolean record = false;//true; void setup() { colorMode(HSB, 360, 100, 100, 100); size(900, 600); background(0, 0, 100); strokeWeight(0.5); smooth(); counter = 0; spiral = new Spiral(); spirals = new Spiral[num]; for (int i=0; i < num; i++) { spirals[i] = new Spiral(); } } void draw() { background(100, 0, 0); float percent = 0; if (record) { percent = float(counter) / totalFrames; } else { percent = float(counter % totalFrames) /totalFrames; } render(percent); counter ++; if (record) { saveFrame("output/gif-"+nf(counter, 3)+".png"); if (counter == totalFrames -1) { exit(); } } } void render(float percent) { float a = percent*TWO_PI; spiral.render(a); for (int i=0; i < num; i++) { spirals[i].render(a); } } class NoiseLoop{ float diameter; float min, max; float cx; float cy; NoiseLoop(float diameter, float min, float max){ this.diameter = diameter; this.min = min; this.max = max; cx = random(1000); cy = random(1000); } float value(float a,float b, float speed){ float xoff = map(cos(a), -1, 1, 0, diameter) + cx; float yoff = map(sin(a), -1, 1, 0, diameter) + cy; float zoff = b*speed; float r = noise(xoff, yoff,zoff); return map(r, 0, 1, min, max); } } class Particle { int centx; int centy; float r; float a; float nx; float ny; float nr; float h; int col; int alpha; Particle(float radius, float ang, float cx, float cy) { centx = width/2 + int(cx); centy = height/2 + int(cy); r = radius; a = ang; } void render() { nx = centx + nr*cos(a); ny = centy + nr*sin(a); //circle(nx, ny, 10); } } class Spiral { float radius = 0; int N = 4; int num = 1500; int range = 150; float startAngle; float speed; float entropy; float cx, cy; Particle[] particles; NoiseLoop Noise; NoiseLoop colNoise; NoiseLoop alphaNoise; Spiral() { startAngle = random(360); particles= new Particle[num]; speed = random(2)*0.3 + 0.5; entropy = random(1)+0.5; cx = random(100)-50; cy = random(100)-50; Noise = new NoiseLoop(speed*0.3, -range*4, range); colNoise = new NoiseLoop(speed, 0, 720); alphaNoise = new NoiseLoop(speed*0.5, -255, 255); for (int i =0; i < particles.length; i++) { float ang = i*N*TWO_PI/particles.length + radians(startAngle); // float thisRadius = radius; particles[i] = new Particle(thisRadius, ang, cx, cy); radius += 0.1; } } void render(float counter) { float t = counter;// * 0.01; for (int i =0; i < particles.length; i++) { float ang = i*N*TWO_PI/particles.length; float noise = Noise.value(t, i*TWO_PI/num*1.5, entropy); float thisNoise = noise *(1+ang/(num*TWO_PI)*50); int col = int(colNoise.value(t, i*TWO_PI/num, entropy)); float alpha = abs(alphaNoise.value(t, i*TWO_PI/num, 0.3))/2; particles[i].nr = particles[i].r + thisNoise; //particles[i].h = (map(noise,-range*4, range,0,510))%255; particles[i].col = col; particles[i].alpha = int(alpha); //int(map(noise, -range*4*(1+ang/(num*TWO_PI)*50), range*(1+ang/(num*TWO_PI)*50), 0, 360)); } for (int i =0; i < particles.length; i++) { particles[i].render(); } for (int i = 1; i < particles.length; i++) { line(particles[i].nx, particles[i].ny, particles[i-1].nx, particles[i-1].ny); if (i == particles.length) { noStroke(); } int alpha = int(particles[i].alpha); stroke(particles[i].col, 100, 100, alpha); strokeWeight(2.5); } } } |
参考文献
リンク
おしまい。
以下は解説記事へのリンクです。
コメント