// ========================================================================= // Markus Lerner // http://www.markuslerner.com // 2003-10-28 // // Gesture // ========================================================================= BImage bgImage; int num = 100; Vec2D mousePast[]; int pastNum = 40; int waitCount = 0; float radAngleY = 0; float maxRotSpeed = 0.02; float gCenterX, gCenterY; PLine p[]; // button vars int buttonNum; int state = 0; Button[] buttons; BFont univers; // setup =================================================================== void setup() { size(600, 300); gCenterX = width/2; gCenterY = height/2; background(0,0,0); // smooth(); noSmooth(); framerate(30); ellipseMode(CENTER_DIAMETER); bgImage = loadImage("bg_ge.jpg"); image(bgImage, 0, 0); mousePast = new Vec2D[pastNum]; for(int i=0; i0; i--) mousePast[i].set(mousePast[i-1]); mousePast[0].set(mouseX, mouseY); waitCount = 0; } //fill(255,0,0); //rect(0, 0, 100, 100); translate(gCenterX, gCenterY, 0); //radAngleY += 0.01; //rotateY(radAngleY); //rect(0, 0, 100, 100); //draw past for(int i=0; i= buttonNum) { state = 0; } } } // PLine class ============================================================= class PLine { float rotSpeedX, rotSpeedY, rotSpeedZ, size; float PangleX = 0; float PangleY = 0; float PangleZ = 0; int id; color c; PLine(float _rotSpeedX, float _rotSpeedY, float _rotSpeedZ, float _size, color _c, int _id) { rotSpeedX = _rotSpeedX; rotSpeedY = _rotSpeedY; rotSpeedZ = _rotSpeedZ; size = _size; id = _id; c = _c; } void loop(){ PangleX += rotSpeedX; PangleY += rotSpeedY; PangleZ += rotSpeedZ; drawPast(); } void drawPast() { for(int i=0; i=x && mx<=x+w && my>=y && my<=my+h) state = id; } } // General vector class for 2D vectors ===================================== class Vec2D { float x,y; // Constructor with no parameters Vec2D() { x=0; y=0; } Vec2D(float _x,float _y) { x=_x; y=_y; } Vec2D(Vec2D v) { x=v.x; y=v.y; } void set(float _x,float _y) { x=_x; y=_y; } void set(Vec2D v) { x=v.x; y=v.y; } void add(float _x,float _y) { x+=_x; y+=_y; } void add(Vec2D v) { x+=v.x; y+=v.y; } void sub(float _x,float _y) { x-=_x; y-=_y; } void sub(Vec2D v) { x-=v.x; y-=v.y; } void mult(float m) { x*=m; y*=m; } void div(float m) { x/=m; y/=m; } float length() { return sqrt(x*x+y*y); } float angle() { return atan2(y,x); } void normalise() { float l=length(); if(l!=0) { x/=l; y/=l; } } Vec2D tangent() { return new Vec2D(-y,x); } void rotate(float val) { // Due to float not being precise enough, double is used for the calculations double cosval=Math.cos(val); double sinval=Math.sin(val); double tmpx=x*cosval - y*sinval; double tmpy=x*sinval + y*cosval; x=(float)tmpx; y=(float)tmpy; } }