Skip to content

Commit 58cc704

Browse files
committed
many more samples
1 parent b014909 commit 58cc704

File tree

137 files changed

+4988
-37
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+4988
-37
lines changed

contributed/library/particles/lib/attractor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def calc_grav_force(p)
3232

3333
# Method to display
3434
def render
35-
ellipse_mode(PConstants::CENTER)
35+
ellipse_mode(CENTER)
3636
stroke(0)
3737
fill(175, 200)
3838
ellipse(loc.x, loc.y, mass * 2, mass * 2)

contributed/library/particles/lib/particle.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ def apply_force(force)
5555

5656
# Method to display
5757
def render
58-
ellipse_mode(PConstants::CENTER)
58+
ellipse_mode(CENTER)
5959
stroke(255)
6060
fill(100)
6161
ellipse(loc.x, loc.y, radius, radius)
62-
each { |pt| point(pt[PConstants::X], pt[PConstants::Y], 0) }
62+
each { |pt| point(pt[X], pt[Y], 0) }
6363
end
6464
end

external_library/gem/pbox2d/library/particles/lib/boundary.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def display
2727
fill(0)
2828
stroke(0)
2929
stroke_weight(1)
30-
rect_mode(PConstants::CENTER)
30+
rect_mode(CENTER)
3131
a = b.get_angle
3232
push_matrix
3333
translate(pos.x, pos.y)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# frozen_string_literal: true
2+
require_relative 'lib/blanket'
3+
require_relative 'lib/connection'
4+
require_relative 'lib/particle'

external_library/gem/toxiclibs/soft_body/library/lib/blanket.rb renamed to external_library/gem/toxiclibs/soft_body/library/blanket/lib/blanket.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# frozen_string_literal: true
12
# The Nature of Code
23
# Daniel Shiffman
34
# http://natureofcode.com

external_library/gem/toxiclibs/soft_body/library/lib/connection.rb renamed to external_library/gem/toxiclibs/soft_body/library/blanket/lib/connection.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# frozen_string_literal: true
12
# The Nature of Code
23
# Daniel Shiffman
34
# http://natureofcode.com

external_library/gem/toxiclibs/soft_body/library/lib/particle.rb renamed to external_library/gem/toxiclibs/soft_body/library/blanket/lib/particle.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# frozen_string_literal: true
12
# The Nature of Code
23
# Daniel Shiffman
34
# http://natureofcode.com

external_library/gem/toxiclibs/soft_body/soft_body_square_adapted.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#!/usr/bin/env jruby
2+
# frozen_string_literal: true
23
require 'propane'
34
require 'toxiclibs'
45
require 'forwardable'
5-
require_relative 'blanket'
6-
require_relative 'connection'
7-
require_relative 'particle'
6+
87
# The Nature of Code
98
# Daniel Shiffman
109
# http://natureofcode.com
@@ -37,6 +36,7 @@
3736
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
3837
#
3938
class SoftBodySquare < Propane::App
39+
load_library :blanket
4040
attr_reader :b, :physics
4141

4242
def settings

nature-of-code/flocking.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def flock(boids)
3737

3838
def seek(target)
3939
desired = target - location
40-
return if desired.mag < PConstants::EPSILON
40+
return if desired.mag < EPSILON
4141
desired.normalize!
4242
desired *= @maxspeed
4343
steer = desired - velocity
@@ -52,7 +52,7 @@ def separate(vehicles)
5252
vehicles.each do |other|
5353
next if other.equal? self
5454
d = location.dist(other.location)
55-
next unless (PConstants::EPSILON..desired_separation).cover? d
55+
next unless (EPSILON..desired_separation).cover? d
5656
diff = (location - other.location).normalize
5757
diff /= d
5858
sum += diff
@@ -75,7 +75,7 @@ def align(boids)
7575
count = 0
7676
boids.each do |other|
7777
d = location.dist(other.location)
78-
next unless (PConstants::EPSILON..neighbordist).cover? d
78+
next unless (EPSILON..neighbordist).cover? d
7979
sum += other.velocity
8080
count += 1
8181
end
@@ -95,7 +95,7 @@ def cohesion(boids)
9595
boids.each do |other|
9696
next if other.equal? self
9797
d = location.dist(other.location)
98-
if (PConstants::EPSILON..neighbordist).cover? d
98+
if (EPSILON..neighbordist).cover? d
9999
sum += other.location
100100
count += 1
101101
end
@@ -119,7 +119,7 @@ def render
119119
push_matrix
120120
translate(location.x, location.y)
121121
rotate(theta)
122-
begin_shape(PConstants::TRIANGLES)
122+
begin_shape(TRIANGLES)
123123
vertex(0, -@r * 2)
124124
vertex(-@r, @r * 2)
125125
vertex(@r, @r * 2)

nature-of-code/xor/landscape.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def render
3939
# (clean this part up)
4040
no_stroke
4141
push_matrix
42-
begin_shape(PConstants::QUADS)
42+
begin_shape(QUADS)
4343
translate(x * scl - w * 0.5, y * scl - h * 0.5, 0)
4444
fill(z[x][y] + 127, 220)
4545
vertex(0, 0, z[x][y])

0 commit comments

Comments
 (0)