Due: Wednesday 10/09 10:00am

Submission name: w13_thermometer

Write A Processing Program:

Over the next few days, we will be making a processing program to display thermometers, showing temperatures in Fahrenheit and Celsius. This is but phase 0. This program should display a single thermometer made of:

  • A large rectangle to contain the entire thermometer.
  • A smaller interior rectangle to contain the temperature reading.
  • A smaller rectangle containing the actual temperature reading (red part).
  • Hashmarks along the side for numbers.

Improve on Yesterday’s Work

Make the following modifications to yesterday’s work.

  • Add these global constants to the top of your program to allow us to switch between temperature scales:
    int CELSIUS = 0;
    int FAHRENHEIT = 1;
    
  • Modify drawThermometer
    • Add a float temperature parameter to provide a temperature amount.
    • Add an int scale parameter which will set the correct scale.
    • When calling drawReading, make the reading area 40% of the width of the thermometer and 90% of the height.
    • Display the temperature on top of the reading area.
  • Modify drawReading
    • Include float temperature and int scale parameters.
    • In addition to the rectangle that represents the entire reading area, add a red rectangle that should represent the value of temperature.
  • Modify drawScale
    • Include int scale as a parameter.
    • The scale should go from freezing to boiling in the appropriate range (32-212 or 0-100)
    • Only draw hash marks on multiples of 5.
  • Add a new function float fToC(float fahrenheit)
    • It will return the Celsius value of fahrenheit.
    • Conversion: c = \((f-32)\dfrac{5}{9}\)
  • Use the following setup and draw when done (when working, you should just call drawThermometer in setup and omit draw until you get everything working):
    void setup() {
      size(300, 600);
      textAlign(CENTER, CENTER);
      frameRate(30);
    }//setup
    
    void draw() {
      background(150);
    
      if (frameCount % 30 == 1) {
        ft = random(32, 212);
      }
      drawThermometer(50, 50, 100, 500, ft, FAHRENHEIT);
      drawThermometer(150, 50, 100, 500, fToC(ft), CELSIUS);
    }//draw
    

Reference Image:

a13_thermometer

The reference image includes numbers, you do not need to add them.