show require 'ruby2d' set title: "Interactive Sketch"
100.times do Circle.new( x: rand(800), y: rand(600), radius: rand(5..30), color: ['red', 'green', 'blue', 'yellow', 'purple'].sample, opacity: rand(0.3..0.8) ) end
show require 'ruby2d' set width: 800, height: 600
update do particles.each do |p| angle = noise[p.x * 0.005, p.y * 0.005, Time.now.to_f * 0.1] * Math::PI * 2 p.x += Math.cos(angle) * 2 p.y += Math.sin(angle) * 2 p.x = 0 if p.x > 800 p.x = 800 if p.x < 0 p.y = 0 if p.y > 600 p.y = 600 if p.y < 0 Rectangle.new(x: p.x, y: p.y, width: 2, height: 2, color: 'white') end end
Recent Comments