zooto68
YaBB Newbies
Offline
Posts: 37
England
Re: What is wrong... ?
Reply #1 - Oct 27th , 2008, 10:36pm
Part 2.........
Code: // Draw the degree lines line(228, 53, 228, boxHeight+50); line(408, 53, 408, boxHeight+50); for (float i=0; i<=boxHeight; i=i+(boxHeight/diff) ) { stroke(0, 0, 80); line(48, i+50, 588, i+50); fill (255, 255, 255); textFont(font, 11); text (tempMax + "°C", 595, i+55); text("Clear", 12,60); text("Cloudy", 12, boxHeight+50); tempMax--; } textFont(font, 16); fill(255, 255, 255); text ("Nighttime Cloud Sensor Location: Orpington, England", 48, 40); textFont(font, 14); fill(200, 0, 0); text ("Ground Sensor = " + sensor2 + "°C", 48, boxHeight+65); fill(0, 0, 200); text ("Sky Sensor = " + sensor1 + "°C", 220, boxHeight+65); fill(0, 200, 0); text ("Clear/Cloudy", 400, boxHeight+65); textFont(font, 12); text("Cloudy", 48, boxHeight+105); text("Clear", 540, boxHeight+105); strokeWeight(2); // Draw the trace for the 2 external temp sensors for (int sensorNum = 0; sensorNum < 2; sensorNum++) { int arrayPointer = counter+1; beginShape(); for (int graphX = 180; graphX >=0; graphX--) { if (arrayPointer == 180) { arrayPointer = 0; } switch (sensorNum) { case 0: stroke(0, 0, 255); break; case 1: stroke(255, 0, 0, 190); break; } float sensorPoint = (boxHeight/(diff/(lastTemp[sensorNum][arrayPointer]-MinVal))); noFill(); curveVertex(588 - (graphX * 3), (boxHeight+50)-sensorPoint); arrayPointer++; } endShape(); } // Draw the trace for the clear/cloudy line int arrayPointer = counter+1; beginShape(); stroke (0, 200, 0, 150); for (int graphX = 180; graphX >=0; graphX--) { if (arrayPointer == 180) { arrayPointer = 0; } float sensorPoint = (boxHeight*lastTemp[4][arrayPointer]); noFill(); curveVertex(588 - (graphX * 3), (boxHeight-((lastTemp[4][arrayPointer]*(boxHeight)-48)))); arrayPointer++; } endShape(); stroke(0,0,0); noFill(); strokeWeight(2); rect(48,50,540,boxHeight); } void initialiseArray(float value) { for (int j=0; j <4; j++) { for (int i=0; i < 180; i++) { lastTemp[j][i] = value; } } } // Function for working out the max and min temperatures in the array void findMinMax(float Temp) { if (Temp > MaxVal) {MaxVal = ceil(Temp);} if (Temp < MinVal) {MinVal = floor(Temp);} diff = truncate(MaxVal - MinVal); } float truncate(float x){ if ( x > 0 ) return float(floor(x * 100))/100; else return float(ceil(x * 100))/100; } void drawIndicator() { float i = 255; for (int j=48; j<=588; j++) { stroke (int (i), int (i), int (i) ); line(j, boxHeight+80, j, boxHeight+90); i=i - 0.45; } stroke (255,255,0); fill(255,255,0); int TempPos = int(48+(TempDiff*(540/10))); print (TempDiff + " +); triangle(TempPos, boxHeight+75, TempPos-2, boxHeight+72, TempPos+2, boxHeight+72); }