int stageWidth_int = 566; int stageHeight_int = 400; int warmNum_int = 20; boolean isInit=false; float setting_v; float setting_raRange; float setting_maxStroke; int setting_colMode; Warm[] warms_ar = new Warm[20]; void setup(){ size(566,400); loop(); setting_v = random(0.1,2); setting_raRange = random(0.1,2); setting_maxStroke = random(2,6); setting_colMode = int(floor(random(0,4))); for(int i=0; i0.5){ strokeCap(SQUARE); }else{ strokeCap(ROUND); } } } class Warm{ float x, y, v; //xpos, ypos, speed float ox, oy; //old xpos, ypos float r, rv, ra; //rotation rotSpeed rotAccel float raRange; float osi; float osiV; int colR, colG, colB; // contains rgb public Warm(float x, float y){ this.x = x; this.y = y; ox = this.x; oy = this.y; v = 0; r = random(0,360); rv = 0; ra = 0; raRange = 0.5; osi = 0; osiV = 0.01; switch(setting_colMode){ case 0: colR = int(random(0,255)); colG = int(random(colR*0.5,colR)); colB = int(random(colG*0.5,colG)); break; case 1: //グレースケール colR = int(random(0,255)); colG = colR; colB = colR; break; case 2: colB = int(random(0,255)); colR = int(random(255-colB,255)); colG = int(random(0,colR*0.5)); break; case 3: colB = int(random(0,255)); colG = int(random(0,colB*0.5)); colR = int(random(255-colG*0.5,255*0.5)); break; default: //グレースケール colR = int(random(50,150)); colG = int(random(colR,255)); colB = int(random(0,colG)); break; } } void step(){ osi += osiV; if(osi > 2 * PI){ osi -= (PI * 2); } ox = x; oy = y; x += cos(r * PI / 180)*v; y += sin(r * PI / 180)*v; if(x<0){ x = width; ox += width; } if(x>width){ x = 0; ox -= width; } if(y<0){ y = height; oy += height; } if(y>height){ y = 0; oy -= height; } ra = ra*0.9 + random(-raRange,raRange); rv = rv * 0.99 + ra; r += rv; stroke(color(colR+cos(osi*4)*40, colG+cos(osi*4)*40, colB+cos(osi*4)*40,200)); strokeWeight(cos(osi*5)*setting_maxStroke+setting_maxStroke); line(x,y, ox, oy); //point(x,y); // draw(); } void setV(float v){ this.v = v; } void setRARange(float rar){ this.raRange = rar; } void setPos(float x, float y){ this.x = x; this.y = y; } void initCol(){ switch(setting_colMode){ case 0: colR = int(random(0,255)); colG = int(random(colR*0.5,colR)); colB = int(random(colG*0.5,colG)); break; case 1: //グレースケール colR = int(random(0,255)); colG = colR; colB = colB; break; case 2: colB = int(random(0,255)); colR = int(random(0,colB)); colG = int(random(255-colR,0)); break; case 3: colB = int(random(0,255)); colR = int(random(255-colB,255)); colG = int(random(colR*0.5,colR)); break; default: //グレースケール colR = int(random(0,255)); colG = colR; colB = colB; break; } } void draw(){ /* for(int xx=-1; xx<1; xx++){ for(int yy=-1; yy<1; yy++){ float d = dist(0,0,xx,yy); if(d!=0){ addPixel(int(x+xx), int(y+yy), color(colR/d, colG/d, colB/d)); } } }*/ addPixel(int(x), int(y), color(colR, colG, colB)); } //additive color method() void addPixel(int x, int y, color col){ if (x<0 || x>width-1) return; if (y<0 || y>height-1) return; color crntCol = get(x, y); int crntr = crntCol>>16 &0xff; int crntg = crntCol>>8 &0xff; int crntb = crntCol &0xff; int newr = col>>16 &0xff; int newg = col>>8 &0xff; int newb = col&0xff; int setr = int(constrain((crntr + newr)*0.8, 0, 255)); int setg = int(constrain((crntb + newb)*0.8, 0, 255)); int setb = int(constrain((crntg + newg)*0.8, 0, 255)); set(x,y, color(setr,setg,setb)); //pixels[5] = color(255,255,255); } }