Skip to content

Instantly share code, notes, and snippets.

@szeryf
Last active January 7, 2019 03:09
Show Gist options
  • Save szeryf/64209d1088f5443268ca to your computer and use it in GitHub Desktop.
Save szeryf/64209d1088f5443268ca to your computer and use it in GitHub Desktop.
# requires jruby_art gem and Processing3 to run
# run with: k9 run --nojruby forest.rb
def setup
@images = Dir.glob("resized-*.jpg").map { |file| load_image(file) }
@pixels = @images.map { |i| i.load_pixels; i.pixels }
noise_seed 130
end
def draw
sketch_title "frame #{frame_count}, #{frame_rate.to_i} fps"
image @images[0], 0, 0 if frame_count == 1
load_pixels
sz = @pixels.size
psz = pixels.size
z = 1 + sin(frame_count / 10.0)
0.upto(psz - 1) do |i|
x = (i % 500) / 100.0
y = (i / 500) / 100.0
n = noise(x, y, z)
j = n * sz
pixels[i] = lerp_color(pixels[i], @pixels[(j + frame_count/TWO_PI) % sz][i], 0.3)
end
update_pixels
filter ERODE
if frame_count <= 20 * TWO_PI && frame_count > 10 * TWO_PI
saveFrame "#{Dir.pwd}/filename-###.png"
p saved: frame_count
end
end
def settings
size 500, 334, JAVA2D
end
@szeryf
Copy link
Author

szeryf commented Mar 4, 2016

The effect:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment