mu chance or much chance ?

日々の戯れ言

ProcessingのPythonモード 勉強2

以下の本を読みながら,
ProcessingのPythonモードを勉強しています.
第2章です.

  • list2_1.pyde
size(800, 600)
colorMode(HSB, 360, 100, 100, 100)

background(0)
noStroke()

hue = 200
saturation = 100
brightness = 20
alpha = 90
diameter = width / 2
col = color(hue, saturation, brightness, alpha)
fill(col)
ellipse(width / 8, height / 2, diameter, diameter)

brightness += 20
col = color(hue, saturation, brightness, alpha)
fill(col)
ellipse(width / 8 * 3, height / 2, diameter, diameter)

brightness += 20
col = color(hue, saturation, brightness, alpha)
fill(col)
ellipse(width / 8 * 5, height / 2, diameter, diameter)

brightness += 20
col = color(hue, saturation, brightness, alpha)
fill(col)
ellipse(width / 8 * 7, height / 2, diameter, diameter)
  • 出力結果

f:id:muchance:20180630221139p:plain

  • list2_2.pyde
size(800, 600)
colorMode(HSB, 360, 100, 100, 100)
background(0)
noStroke()

num = 12
hue = 200
saturation = 100
brightness = 20
alpha = 90
diameter = width / num * 2

for i in range(num):
    col = color(hue, saturation, brightness, alpha);
    fill(col)
    x = width / num * i + diameter / 4
    ellipse(x, height / 2, diameter, diameter)
    brightness += 100 / num;
  • 出力結果

f:id:muchance:20180630221241p:plain

  • list2_3.pyde
size(800, 600)
background(0)
noStroke()

num = 10000

for i in range(num):
    x = random(0, width)
    y = random(0, height)
    d = dist(x, y, width / 2, height / 2)
    if d < height / 2:
        noStroke()
        fill(63, 127, 255)
    else:
        noFill()
        stroke(31, 127, 255)
    ellipse(x, y, 10, 10)
  • 出力結果

f:id:muchance:20180630221902p:plain