IAT 806 · Intro to Computing · Fall 2026
mouseX and mouseYrandom()let makes a new variable.= puts a value into it.circle(x, y, size) reads the three values.let line. Press ▶ run edits.draw() stays the same. The circle changes.=, then the new value.let the second time. let makes a variable. You only make it once.size is 80.size becomes 160.mouseX and mouseYmouseX is the mouse’s horizontal position.mouseY is the vertical position.let x = mouseX copies the current value into x.x gets mouseY. y gets mouseX.x means nothing to the computer. Only the value inside it counts.x and add 1.x.x was 10, it is now 11.draw()draw() runs about 60 times a second.x grows by 2.2 to 5. Change it to -1.let mattersOutside draw(), let runs once. x keeps its value between frames. Inside draw(), let runs every frame. x starts at 0 every time.
x never stops growing.x still grows to 1000, 5000, and on.x and decide. That is a conditional.if( ) is the condition.true or false.true, the code inside { } runs.false, that code is skipped.| Code | True when |
|---|---|
a > b |
a is greater than b |
a < b |
a is less than b |
a >= b |
a is greater than or equal to b |
a <= b |
a is less than or equal to b |
a == b |
a is equal to b |
a != b |
a is not equal to b |
One = sets a value. Two == compare two values.
if and elsetrue. The fill is orange.false. The else part runs. The fill is blue.else iftrue runs. The rest are skipped.else runs only if none of them were true.x grows by 3.if checks whether x is past the right edge.x goes back to 0.&&&& joins two conditions.true only if both sides are true.&& mouseY > 60 && mouseY < 200 to check the whole box.|||| also joins two conditions.true if either side is true.&& and || side by sidea |
b |
a && b |
a || b |
|---|---|---|---|
true |
true |
true |
true |
true |
false |
false |
true |
false |
true |
false |
true |
false |
false |
false |
false |
&& needs both. || needs one.
random()random() gives a number between 0 and 1.random(10) gives a number between 0 and 10.random(-3, 3) gives a number between -3 and 3.x changes by a random amount between -3 and 3.y.3 to 10. Remove background().random() with ifrandom() is above 0.5 about half the time.0.5 to 0.9. Orange becomes rare.IAT 806 · Intro to Computing · Fall 2026