Created
February 16, 2017 13:55
-
-
Save JoshCheek/ff9635dfcb290fa483ce887141d26056 to your computer and use it in GitHub Desktop.
Coffee Skimmer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "graphics" | |
class CoffeeSkimmer < Graphics::Simulation | |
CLEAR_COLOR = [36, 30, 10] | |
def initialize | |
super 800, 450, 24 | |
color.default_proc = -> h, k { k } | |
@points = 500.times.map { [rand(3*w)-1*w, rand(3*h)-1*h] } | |
@points.concat @points.take(200) | |
200.times do | |
@points = @points.each_cons(2).map do |(x1, y1), (x2, y2)| | |
[x1+(x2-x1)*0.5, y1+(y2-y1)*0.5] | |
end | |
end | |
end | |
def draw(ticks) | |
clear | |
@points.rotate!.take(10).each_cons(2) do |(x1, y1), (x2, y2)| | |
line x1, y1, x2, y2, :white | |
end | |
end | |
end | |
CoffeeSkimmer.new.run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment