mikegerard
YaBB Newbies
Offline
Posts: 2
using rotate and not using rotate
Nov 9th , 2006, 6:07pm
I love Processing. This is my first program in Processing and it is really a great language to program in. I have a simple program below that rotates an image and slows down the rotation and then stops it. When I stop the image I want to put some text in the bottom left corner of the screen. Right now the text shows up in the center rotated (because of my rotation and translation). How do I un-rotate and translate the text only? Thanks, Mike PImage img; PImage arrow; PFont font; float t; float decelerate; float angle; float stop; int a; void setup() { size(640,740); img = loadImage("boys-circle-spin.png"); arrow = loadImage("arrow.jpg"); // Load the images into the program t=random(1); decelerate=-0.6; angle=0.1; font = loadFont("ComicSansMS-48.vlw"); textFont(font); } void draw(){ background(0); image(arrow, 280, 640, arrow.width/6, arrow.height/6);//load arrow angle=angle + exp (decelerate*t); // decay. translate(320,320); //rotate the picture of the boys around the center rotate(angle); image(img, -img.width/2, -img.height/2); t=t+0.1; if (t >=10){ // stuff to determine where the wheel stopped stop=angle/6.28; int a = floor(stop); stop = stop - a; println(angle); println(stop); println(t) ; noLoop(); if((stop > .3) && (stop < .6)) { text("Daniel", 0, 0); //this text shows up rotated fill(0, 102, 153); }else if ((stop > .6) && (stop < .95)){ text("Joey", 0, 0); //this text shows up rotated }else {text("David", 0, 0); //this text shows up rotated } } } void mousePressed(){ decelerate = -1; //speed up the deceleration if the mouse is pressed }