class Flake { float _tx, _ty, _tz, _tspeed; float _x,_y,_z,_rotationX, _rotationY,_ry,_rx,_scale; color _color; PImage _mask; PImage _image; //PImage _finalimage; float _width,_height; int npixels; PGraphics g2; PImage b_img; float _xf,_yf,_zf,_sf,_speed; int count; int half; int _currentframe; int DELAY = 5; int delay_count = 0; AnimFlake _frames_vect; public Flake(int $id){ _currentframe = 0; int t = millis(); //print("new flakes: "+$id); _color = color(round(random(255)),round(random(255)),round(random(255))); _frames_vect = (AnimFlake) anim_vect.get($id); _image = _frames_vect._frames[_currentframe]; half = (int) (_image.width*.5f); _x = _tx = random(width); _y = _ty = random(height); _z = _tz = random(height); _ry=random(PI); _rotationX = random(PI); _rotationY = random(PI); _scale = random(.2,1); //println("millis spent: "+(millis()-t)); _speed = random(.005,.02); } void retargetMe(){ count = (int) random(50,200); _xf=random(-half,width+half); _yf=random(-half,height+half); _ry = random(.01,.05); _rx = random(.01,.05); //_zf=random(-half,height+half); _sf = random(.2,1); _tspeed = random(.01,.1); } void updateMe(){ count--; if(count<=0) retargetMe(); _tx += (_xf-_tx)*_tspeed; _ty += (_yf-_ty)*_tspeed; //_tz += (_zf-_tz)*_tspeed; _x += (_tx-_x)*_speed; _y += (_ty-_y)*_speed; //_z += (_tz-_z)*_speed; _scale += (_sf-_scale)*_speed; _rotationX += _rx; _rotationY += _ry; } void drawMe(){ _image = _frames_vect._frames[_currentframe]; pushMatrix(); translate(_x,_y); scale(_scale); rotateY(_rotationY); rotateX(_rotationX); //_finalimage.mask(_mask); image(_image,-half,-half); //blend(_image, 0, 0, -half, -half, ADD); popMatrix(); delay_count++; if(delay_count>=DELAY){ delay_count = 0; _currentframe++; if(_currentframe >= _frames_vect._frames.length) _currentframe=0; } } }