Recently Jorg Kantel has taken an interest in py5 see his recent blog entry here. Previously I have had some fun translating his python sketches to ruby, here is the py5 Sine Wave sketch translated to JRubyArt:-
R1 = 100 # Radius large circle
R2 = 5 # Radius smaller circles
attr_reader :t, :circle_list
def settings
size(600, 600)
end
def setup
sketch_title 'Sine Wave Generator'
@t = 0
@circle_list = Array.new(199, 0)
end
def draw
background(132, 144, 163)
translate(width / 4, height / 2) # center sketch
no_fill # Don't fill larger circle
stroke(0) # Outline: black
circle(0, 0, 2 * R1)
fill(250, 0, 0, 150) # semi transparent smaller circles
y = R1 * sin(t) # coordinates large circle
x = R1 * cos(t)
circle(x, y, 2 * R2)
# Insert one point at beginning of circle_list
circle_list.unshift y
circle_list.pop
no_stroke
fill(0, 255, 0, 150) # semi transparent light green
# create ribbon trail from list
circle_list.each_with_index do |hgt, idx|
circle(200 + idx, hgt, R2)
end
stroke(0, 250, 0) # Green for connecting line …
line(x, y, 200, y)
fill(0, 250, 0, 150) # and small end point
stroke(0)
circle(200, y, 2 * R2)
@t += 0.05
end