As computing becomes more ubiquitous in our objects, designers need to be more aware of how to design meaningful interactions into electronically enhanced objects. At the University of Washington, a class of junior Interaction Design majors is exploring this question. These pages chronicle their efforts.

Thursday, April 5, 2012

Bridget Weis_Letter K Revised

/**
 *My Name
 * by Bridget Weis
 *Based on Processing Example
 *
 *Letter K
 * by Peter Cho.
 *
 * Move the mouse across the screen to fold the "K".
 */

color backgroundColor;
color foregroundColor;
color foregroundColor2;


PFont didot;

float px, py;
float pfx, pfy;
float pv2, pvx, pvy;
float pa2, pax, pay;
float pMass, pDrag;

void setup() {
  size(800, 400, P3D);
  didot = loadFont("DidotTwo.vlw");
  noStroke();
  backgroundColor = color(255, 255, 255);
  foregroundColor = color(39, 139, 148);
  foregroundColor2 = color(13, 67, 72, 175);
  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);
  drawtext();

  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);
  drawtext();
  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();
  vertex(-800, 0);
  vertex( 800, 0);
  vertex( 800, -400);
  vertex(-800, -400);
  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 drawtext() {
  pushMatrix();
  scale(1);
  translate(-350, 30);
  textFont(didot, 200);
  text("Bridget", 10, 50);

  //translate(63, -71);
  popMatrix();
 

 
}

No comments:

Post a Comment