Ladle
Junior Member
Offline
Posts: 91
Re: for() loop?
Reply #2 - Oct 16th , 2009, 6:03am
I've tried moving the row variable to the setup() section, which seems to work, at least I end up with the same image if I add row = row++ at the end. but I think I am doing somethign wrong in trying to add a mouse event to control 'row'. When I use the mousepressed function (highlighted) I only see the first 'frame', and cant make it add 1 to 'row' on click...? Make any sense!? PImage blueImage; Table dataTable; int rowCount; PFont textfont; int row; void setup(){ size (400, 200); textfont = loadFont("Serif-48.vlw"); textFont(textfont, 32); // blueImage = loadImage("blueImage.png"); dataTable = new Table("testnums2.txt"); rowCount = dataTable.getRowCount(); //frameRate(1); } void draw() { background(0); // image(blueImage, 0, 0); smooth(); fill(192,0,0); noStroke(); fill(0, 100, 0); text("Mins", 1, (height/2)-5); //text lables. fill(100, 0, 0); text("Hours", 1, (height/2)+45); for(int row = 1; row < rowCount;) { String timedata = dataTable.getString(row, 0); // column 1. String fulltime = (timedata.substring(1,5)); String daytime = dataTable.getString(row, 1); // column 2. String kind = dataTable.getString(row, 2);//column3. String hourx = (timedata.substring(1,3));//from character 2-3. String minx = (timedata.substring(3,5));//characters 4-5. int n = int(hourx); float m = map(n, 0, 24, 10, width-10); stroke(100,0,0); line(m, (height/2)+50, m, (height/2)+60); // HOUR LINES ARE RED. int nn = int(minx); float mm = map(nn, 0, 59, 10, width-10);// min lines are green. stroke(0,100,0); line( mm, (height/2), mm, (height/2)+10); stroke(0,0,100); noFill(); ellipse(width/2, (height/5), m/5, m/5); // ellipse. int h = hour(); float hourmark = map(h, 0, 24, 10, width-10); noStroke(); fill(255, 215, 0, 50); smooth(); ellipse(hourmark, (height/2)+55, 10, 10); //hour counter. int mint = minute(); float minmark = map(mint, 0, 60, 10, width-10); noStroke(); fill(255, 215, 0, 50); smooth(); ellipse(minmark, ((height/2)+5), 5, 5); // min counter. int sec = second(); float secmark = map(sec, 0, 60, 10, width-10); noStroke(); fill(255, 215, 0, 50); smooth(); ellipse(secmark, (height-10), 5, 5); // second counter. void mousePressed() { row++; } println(row); println(timedata); } }