Sha256: 7d0f9d381605ef239e3d02786b703b583a5dc5d65da6a73ba1b4e3761fc6f9e5
Contents?: true
Size: 1.14 KB
Versions: 3
Compression:
Stored size: 1.14 KB
Contents
# Description: # Flight Patterns is that ol' Euruko 2008 demo. # Since processing 2.0 'ovals' don't look too hot load_libraries 'boids' def setup size(displayWidth, displayHeight, P3D) sphere_detail 12 color_mode RGB, 1.0 no_stroke frame_rate 30 shininess 1.0 specular 0.3, 0.1, 0.1 emissive 0.03, 0.03, 0.1 @click = false @flocks = [] 3.times do |i| flock = Boids.flock 20, 0, 0, width, height flock.goal width/2, height/2, 0 @flocks << flock end end def mouse_pressed @click = !@click end def draw background 0.05 ambient_light 0.01, 0.01, 0.01 light_specular 0.4, 0.2, 0.2 point_light 1.0, 1.0, 1.0, mouse_x, mouse_y, width / 4.0 @flocks.each_with_index do |flock, i| flock.goal mouse_x, mouse_y, 0, @flee flock.update(goal: 185, limit: 13.5) for boid in flock do r = 20 + (boid.z * 0.15) case i when 0 then fill 0.55, 0.35, 0.35 when 1 then fill 0.35, 0.55, 0.35 when 2 then fill 0.35, 0.35, 0.55 end push_matrix translate boid.x-r/2, boid.y-r/2, boid.z-r/2 @click ? sphere(r/2) : oval(0, 0, r, r) pop_matrix end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ruby-processing-2.4.3 | samples/contributed/flight_patterns.rb |
ruby-processing-2.4.2 | samples/contributed/flight_patterns.rb |
ruby-processing-2.4.1 | samples/contributed/flight_patterns.rb |