Note for Class

  1. Booleans & Logic Operators

Booleans represent binary truth values: true(真 / 開 / 有)與 false(假 / 關 / 無)

Comparison Operators •= Assignment 賦值: 把右邊的值存進左邊的變數(e.g., x = 10).

•== Equivalent 比較是否相等 (e.g., 10 == 20 →false).

•!= Not Equivalent比較是否不相等l (e.g., 10 != 20 → true).

•> / < Greater Than / Less Than

截圖 2026-09-23 凌晨2.21.02.png

  1. Smooth Movement & Interpolation (lerp)

lerp(start, stop, amt) stands for Linear Interpolation(線性插值), 計算兩點之間的漸變值

eg: x= lerp (x, mouseX, 0.01) 每次只走「當前位置」與「目標位置(mouseX)」剩餘距離的 1%(0.01)。這會讓物體移動產生延遲流暢的跟送效果

*Note: lerpColor() can also be used to calculate smooth transitions between two colors.

3. Transformations & Matrix Operations

•translate(x, y)移動原點 $(0, 0)$ 到指定座標:

•rotate(angle)以當前原點為中心旋轉:

•scale(s)縮放整體畫布大小: e.g., scale(0.2) reduces size to 20%

• push() and pop(): 作用:防止某元件的 translate() 或 fill() 影響後面的其他繪圖元素

push():儲存當前的畫布狀態(顏色、線條粗細、原點位置等)

pop():還原到上一次 push() 儲存的狀態

截圖 2026-09-16 下午1.25.31.png

  1. Perlin Noise vs. Random (noise)

截圖 2026-09-23 凌晨2.23.10.png

Boolean: True(真/ 開/ 有), False(假/ 關/ 無)

(x==y)→ false

x! = y for boolean→true

Video Note:

4.1: while and for Loops

var x = 0;

while(x < = width){ fill(__, __, __); ellipse(x, __, __, __); x= x + 50;}

or

for (var x = 0; x < = width; x + = width; x + = 50){fill(__, __, __); ellipse(x, __, __, __);}