Processing の examples その3 (Basics-Color-Brightness)
コードこれ
/** * Brightness * by Rusty Robison. * * Brightness is the relative lightness or darkness of a color. * Move the cursor vertically over each bar to alter its brightness. */ int barWidth = 5; int[] brightness; void setup() { size(200, 200); colorMode(HSB, 360, height, height); brightness = new int[width/barWidth]; } void draw() { int j = 0; for (int i = 0; i <= (width-barWidth); i += barWidth) { noStroke(); if ((mouseX > i) && (mouseX < i+barWidth)) { brightness[j] = mouseY; } fill(i, height, brightness[j]); rect(i, 0, barWidth, height); j++; } }
こんなん出ました。
これはよーするにcolorMode()の理解かな、と。
横にbarWidth毎にHueが設定されていて、マウスのY座標に応じて明るさ(HSVのV, Value)でrect()が埋められると。
以上。