Skip to content

Commit 7438428

Browse files
committed
revise toxiclibs noise example
1 parent 75155ce commit 7438428

File tree

3 files changed

+14
-26
lines changed

3 files changed

+14
-26
lines changed

external_library/gem/ruby_wordcram/render_to_pdf.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
WEB = %w[#000000 #0000dd #ff0000].freeze
1010

1111
def settings
12-
size(700, 700, PDF, 'usconst.pdf')
12+
size(700, 700, PDF, data_path('usconst.pdf'))
1313
end
1414

1515
def setup

external_library/gem/toxiclibs/noise/simplex_noise_3_d.rb

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,27 @@
33
#
44
# Using 3D noise to create simple animated texture.
55
# Here, the third dimension ('z') is treated as time.
6-
7-
8-
attr_reader :increment, :z_increment
6+
DELTA = 0.01
7+
DELTA_TIME = 0.02
8+
attr_reader :zoff
99

1010
def setup
11-
sketch_title 'Simplex Noise 3D'
11+
sketch_title 'Noise 3D'
1212
frame_rate 30
13-
@increment = 0.01
1413
@zoff = 0.0
15-
@z_increment = 0.02
1614
end
1715

1816
def draw
1917
background 0
2018
load_pixels
21-
xoff = 0.0
22-
(0...width).each do |x|
23-
xoff += increment
24-
yoff = 0.0
25-
(0...height).each do |y|
26-
yoff += increment
27-
bright = Toxi::SimplexNoise.noise(xoff, yoff, @zoff) * 255
28-
pixels[x + y * width] = color(bright, bright, bright)
29-
end
19+
grid(width, height) do |x, y|
20+
bright = (Toxi::SimplexNoise.noise(x * DELTA, y * DELTA, zoff) + 1) * 128
21+
# perlin = Toxi::PerlinNoise.new
22+
# bright = perlin.noise(x * DELTA, y * DELTA, zoff) * 255
23+
pixels[x + y * width] = color(bright, bright, bright)
3024
end
3125
update_pixels
32-
@zoff += z_increment
26+
@zoff += DELTA_TIME
3327
end
3428

3529
def settings

processing_app/basics/math/noise_3_d.rb

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,9 @@ def setup
1717
def draw
1818
background 0
1919
load_pixels
20-
xoff = 0.0
21-
(0...width).each do |x|
22-
xoff += DELTA
23-
yoff = 0.0
24-
(0...height).each do |y|
25-
yoff += DELTA
26-
bright = (noise(xoff, yoff, zoff) + 1) * 128
27-
pixels[x + y * width] = color(bright, bright, bright)
28-
end
20+
grid(width, height) do |x, y|
21+
bright = (noise(x * DELTA, y * DELTA, zoff) + 1) * 128
22+
pixels[x + y * width] = color(bright, bright, bright)
2923
end
3024
update_pixels
3125
@zoff += DELTA_TIME

0 commit comments

Comments
 (0)