A Processing Java-mode sketch animates a marker using the following complete code:
float x = 24; void setup() { size(320, 160); noStroke(); ellipseMode(CENTER); } void draw() { background(255); ellipse(x, 80, 10, 10); x += 3; }
Count the first execution of draw() as call 1. Immediately after call 8 returns, before call 9 begins, what is the horizontal screen coordinate of the marker's centre in the displayed image?
24 px24\ \text{px}24 px
48 px48\ \text{px}48 px
42 px42\ \text{px}42 px
45 px45\ \text{px}45 px
Unlock full course notes by signing up
Restoring colour without losing position
A Processing Java-mode sketch should draw an orange equipment block with its upper-left corner at (180,80) px(180,80)\ \text{px}(180,80) px and a blue circular indicator centred at (60,50) px(60,50)\ \text{px}(60,50) px. It uses this code:
The indicator appears orange. Which single edit produces both intended colours and both intended positions? A matrix pair means pushMatrix() with its matching popMatrix(); a style pair means pushStyle() with its matching popStyle().
Tracing nested coordinate frames
A Processing Java-mode sketch uses nested coordinate transformations to place two joint markers:
Using Processing's default 2D screen coordinates, what are the screen coordinates of the centres of markers A and B? All coordinates below are in pixels.
Comparing consecutive-temperature alarm conditions
An equipment monitor records one temperature per second. The following Processing sketch in Java mode processes the stored temperatures, in °C, once from beginning to end:
Determine the final alarmCount and meanTrigger for this original sketch. Then determine both quantities for a modified sketch in which only if (run == 3) becomes if (run >= 3).
Treat the original and modified sketches as independent runs with all variables initialized as shown. Enter both alarm counts as exact integers and both mean trigger temperatures in °C, to one decimal place.