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
Ruby2D for real-time, SVG + ChunkyPNG for static art. 3. Setting Up Install Ruby (≥ 3.0), then install gems: ruby sketch
show
@x = 0 @square = Square.new(x: 0, y: 200, size: 50, color: 'red') update do particles
svg.rect(x: 0, y: 0, width: '100%', height: '100%', fill: '#111') p.y * 0.005