Skip to content

Commit c7ad2ad

Browse files
committed
replace !gsub with gsub
1 parent 877d592 commit c7ad2ad

File tree

7 files changed

+7
-7
lines changed

7 files changed

+7
-7
lines changed

processing_app/topics/lsystems/csplant.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def render
6666
specular(255, 255, 255)
6767
shininess(1.0)
6868
repeat = 1
69-
production.each_char do |ch|
69+
production.scan(/./) do |ch|
7070
case ch
7171
when 'F'
7272
translate(0, len / -2, 0)

processing_app/topics/lsystems/david_tour.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def create_grammar(gen)
5858
def translate_rules(prod)
5959
swap = false
6060
[].tap do |points| # An array to store lines as a flat array of points
61-
prod.scan(/./) do |ch|
61+
prod.scan(/./) do |ch||
6262
case ch
6363
when 'F'
6464
points << xpos << ypos << (@xpos += draw_length * Math.cos(theta)) << (@ypos -= draw_length * Math.sin(theta))

processing_app/topics/lsystems/library/cs_grammar/cs_grammar.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def generate(repeat = 0) # repeat iteration grammar rules
4343

4444
def new_production(prod) # single iteration grammar rules
4545
@idx = -1
46-
prod.gsub!(/./) do |ch|
46+
prod.gsub(/./) do |ch|
4747
get_rule(prod, ch)
4848
end
4949
end

processing_app/topics/lsystems/library/stochastic_grammar/stochastic_grammar.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def add_rule(pre, rule, weight = 1.0) # default weighting 1
4343
end
4444

4545
def new_production(prod) # note the use of gsub!
46-
prod.gsub!(/./) do |ch|
46+
prod.gsub(/./) do |ch|
4747
rule?(ch) ? stochastic_rule(srules[ch]) : ch
4848
end
4949
end

processing_app/topics/lsystems/mpeano.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def generate(gen)
6464

6565
def translate_rules(prod)
6666
[].tap do |points| # An empty array to store line vertices
67-
prod.scan(/./) do |ch|
67+
prod.scan(/./) do |ch||
6868
case ch
6969
when 'F'
7070
points << xpos << ypos << (@xpos -= draw_length * cos(theta)) << (@ypos -= draw_length * sin(theta))

processing_app/topics/lsystems/peano.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def translate_rules(prod)
7070
coss = ->(orig, alpha, len) { orig + len * DegLut.cos(alpha) }
7171
sinn = ->(orig, alpha, len) { orig - len * DegLut.sin(alpha) }
7272
[].tap do |pts| # An array to store line vertices as Vec2D
73-
prod.scan(/./) do |ch|
73+
prod.scan(/./) do |ch||
7474
case ch
7575
when 'F'
7676
pts << vec.copy

processing_app/topics/lsystems/three_d_tree.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def initialize
7575
end
7676

7777
def render
78-
production.each_char do |ch|
78+
production.scan(/./) do |ch
7979
case ch
8080
when 'F'
8181
fill(0, 200, 0)

0 commit comments

Comments
 (0)