Skip to content

Instantly share code, notes, and snippets.

@metade
Created February 4, 2010 07:52
Show Gist options
  • Save metade/294434 to your computer and use it in GitHub Desktop.
Save metade/294434 to your computer and use it in GitHub Desktop.
class Point
attr_accessor :x, :y
def initialize(x, y)
@x, @y = x, y
end
end
ENTRY_COUNT = 40
INCREMENT = 0.01
class Entry
attr_accessor :rank, :position
def initialize(rank)
@rank = rank
@size = (width/2)/ENTRY_COUNT
@radius = rank * @size
@position = Point.new(width/2, height/2 - rank)
end
def render(p)
(1..20).to_a.each do |i|
fill 0.8, 0.6
x = (width/2) + @radius * Math.cos(p + (i*INCREMENT*2))
y = (height/2) + @radius * Math.sin(p + (i*INCREMENT*2))
oval(x, y, @size/2, @size/2)
end
end
end
def setup
size 800, 800
color_mode RGB, 1.0
frame_rate 30
smooth
@entries = (1..ENTRY_COUNT).to_a.map { |i| Entry.new(i) }
end
$p = 0
def draw
background 0
$p += INCREMENT
@entries.each do |entry|
entry.render($p)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment