-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwave.rb
More file actions
45 lines (33 loc) · 829 Bytes
/
wave.rb
File metadata and controls
45 lines (33 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require 'ruby-processing'
# Wave Gradient
# by Ira Greenberg.
#
# Generate a gradient along a sin() wave.
class Wave < Processing::App
def setup
background 200
angle = 0.0
px, py = 0.0, 0.0
amplitude = 30.0
frequency = 0.0
fill_gap = 2.5
(height + 150).times do |i|
i -= 75
angle = 0.0
frequency += 0.006
(width + 75).times do |j|
py = i + sin( angle.radians ) * amplitude
angle += frequency
c = color((py-i).abs * 255/amplitude,
255 - (py-i).abs * 255/amplitude,
j * (255.0/(width+50)))
fill_gap.ceil.times do |filler|
set j-filler, py.to_i-filler, c
set j, py.to_i, c
set j+filler, py.to_i+filler, c
end
end
end
end
end
Wave.new :width => 200, :height => 200