puppyd
YaBB Newbies
Offline
Posts: 7
page turn/flip
Feb 6th , 2010, 3:35pm
Hello! Newbie here . I am trying to alter the "letter K" example to create a flash like page turn ---any help would be appreciated. Thanks here is where I am so far/** * Letter K * by Peter Cho. * * Move the mouse across the screen to fold the "K". */ color backgroundColor; color foregroundColor; color foregroundColor2; float px, py; float pfx, pfy; float pv2, pvx, pvy; float pa2, pax, pay; float pMass, pDrag; void setup() { size(640, 480, P3D); noStroke(); backgroundColor = color(134, 144, 154); foregroundColor = color(235, 235, 30); foregroundColor2 = color(240, 130, 20); initParticle(0.6, 0.9, width/2, height/2); } void draw() { background(backgroundColor); pushMatrix(); iterateParticle(0.15*(-px+mouseX), 0.15*(-py+(height-mouseY))); translate(width/2, height/2, 0); fill(foregroundColor); drawK(); pushMatrix(); translate(0, 0, 1); translate(0.75 * (px-width/2), -0.75 * (py-height/2), 0); translate(0.75 * (px-width/2), -0.75 * (py-height/2), 0); rotateZ(atan2(-(py-height/2), (px-width/2)) + PI/2); rotateX(PI); rotateZ(-(atan2(-(py-height/2), (px-width/2)) + PI/2)); fill(foregroundColor2); drawKa(); popMatrix(); translate(0.75 * (px-width/2), -0.75 * (py-height/2), 2); rotateZ(atan2(-(py-height/2), (px-width/2)) + PI/2); fill(backgroundColor); beginShape(QUADS); vertex(-640, 0); vertex( 640, 0); vertex( 640, -360); vertex(-640, -360); endShape(); popMatrix(); } void initParticle(float _mass, float _drag, float ox, float oy) { px = ox; py = oy; pv2 = 0.0; pvx = 0.0; pvy = 0.0; pa2 = 0.0; pax = 0.0; pay = 0.0; pMass = _mass; pDrag = _drag; } void iterateParticle(float fkx, float fky) { // iterate for a single force acting on the particle pfx = fkx; pfy = fky; pa2 = pfx*pfx + pfy*pfy; if (pa2 < 0.0000001) { return; } pax = pfx/pMass; pay = pfy/pMass; pvx += pax; pvy += pay; pv2 = pvx*pvx + pvy*pvy; if (pv2 < 0.0000001) { return; } pvx *= (1.0 - pDrag); pvy *= (1.0 - pDrag); px += pvx; py += pvy; } void drawK() { pushMatrix(); translate(10, 10); PImage a= loadImage("jelly.jpg"); textureMode(NORMALIZED); beginShape(QUADS); texture (a); vertex(0, 0, 0,0); vertex(200, 0, 0,1); vertex(200, 200, 1,1); vertex(0, 200, 0,1); endShape(); //translate(10, 10); popMatrix(); } void drawKa() { pushMatrix(); translate(10, 10); PImage a= loadImage("eames.jpg"); beginShape(QUADS); texture(a); vertex(0, 0, 0,0); vertex(200, 0, 200,0); vertex(200, 200, 200,200); vertex(0, 200, 0,200); endShape(); //translate(10, 10); popMatrix(); }