A Processing sketch running in Java mode draws a rectangular equipment panel using this code:


Java
void setup() {
  size(400, 240);
  noStroke();
  rectMode(CENTER);
  rect(160, 100, 80, 40);
}


There are no coordinate transformations. What are the screen coordinates (x,y)(x,y) of the rectangle's upper-left corner, in pixels?


A blank Processing canvas has its origin at the upper-left corner with x increasing rightward and y increasing downward.


Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

A Processing sketch in Java mode already has a running draw() function. Its counter must increase once when a mouse button is pressed, before the button is released, even if it remains held through many frames.


Complete the name of the Processing event function you should implement: . Enter only the function name, without parentheses.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

A Processing Java-mode sketch displays a displacement sensor reading on a vertical scale. The display uses a linear calibration: 0.0 mm0.0\ \text{mm} corresponds to screen coordinate y=300 pxy=300\ \text{px}, and 12.0 mm12.0\ \text{mm} corresponds to y=60 pxy=60\ \text{px}. No coordinate transformations are applied.


For a sensor reading of 7.4 mm7.4\ \text{mm}, the sketch calculates:


Java
float displacement = 7.4f;  // millimetres
float yScreen = map(displacement, 0, 12, 300, 60);


What is yScreen? Answer in pixels, to one decimal place.


The calibration endpoints pair a displacement of twelve millimetres with screen y sixty pixels and zero millimetres with screen y three hundred pixels.


Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

Extra Practice