Skip to content

Instantly share code, notes, and snippets.

@szeryf
Created October 8, 2017 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save szeryf/3c776a32cf3fa3a183340dee315fb120 to your computer and use it in GitHub Desktop.
Save szeryf/3c776a32cf3fa3a183340dee315fb120 to your computer and use it in GitHub Desktop.
Waterfall One, the source of
# Waterfall One
# http://low-sugar-eye-candy.tumblr.com/post/164374908068/waterfall-one
#
# requires jruby_art gem and Processing3 to run
# run with: k9 run --nojruby forest.rb
W = 500
H = 801
def setup
noise_seed 4934
@points = []
end
def draw
sketch_title "frame #{frame_count}, #{frame_rate.to_i} fps"
if frame_count == 1
background color('#36465d')
else
fill color('#36465d'), 20
no_stroke
rect 0, 0, W, H
filter BLUR, 1
end
f = 1 + sin(frame_count / 10.0)
stroke 255
50.step(W - 50, 5) { |x| @points << [x, 0] }
@points.map! do |x, y|
point x, y
nx = noise(x / 100.0, y / 100.0, f) * 2 - 1
ny = noise(y / 100.0, x / 100.0, 5 - f) * 10
[x + nx, y + ny]
end
save_it4 220, TWO_PI * 20
end
def save_it3(min, max)
if frame_count >= min && frame_count <= max
save_frame "#{Dir.pwd}/filename-###.png"
p saved: frame_count
elsif frame_count > max
exit
end
end
def save_it4(start, amount)
save_it3(start, start + amount)
end
def settings
size W, H, JAVA2D
smooth
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment