Skip to content

Commit 392d1e5

Browse files
committed
various fixes
1 parent 0ec191d commit 392d1e5

File tree

6 files changed

+41
-46
lines changed

6 files changed

+41
-46
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
x,y,diameter,name
2-
160,103,43.19838,Happy
3-
372,137,52.42526,Sad
4-
273,235,61.14072,Joyous
5-
121,179,44.758068,Melancholy
2+
160.0,103.0,43.19838,Happy
3+
372.0,137.0,52.42526,Sad
4+
273.0,235.0,61.14072,Joyous
5+
121.0,179.0,44.758068,Melancholy

processing_app/topics/advanced_data/load_save_table.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def load_data
4242
# Load CSV file into an Array of Hash objects
4343
# headers: option indicates the file has a header row
4444
@bubbles = BubbleData.new
45-
CSV.foreach('data/data.csv', headers: true) do |row|
45+
CSV.foreach(data_path('data.csv'), headers: true) do |row|
4646
x = row['x'].to_f
4747
y = row['y'].to_f
4848
d = row['diameter'].to_f
@@ -59,7 +59,7 @@ def mouse_pressed
5959
# Writing the csv data back to the same file, (also specify UTF-8 format)
6060
headers = %w(x y diameter name) # create csv headers
6161
CSV.open(
62-
'data/data.csv',
62+
data_path('data.csv'),
6363
'w:UTF-8',
6464
write_headers: true,
6565
headers: headers

processing_app/topics/advanced_data/word_frequency.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#
1818
load_library 'word'
1919

20-
DRACULA = 'data/dracula.txt'
21-
FRANKENSTEIN = 'data/frankenstein.txt'
20+
DRACULA = 'dracula.txt'
21+
FRANKENSTEIN = 'frankenstein.txt'
2222
DRAC = Regexp.new(DRACULA)
2323
FRANK = Regexp.new(FRANKENSTEIN)
2424

@@ -29,8 +29,8 @@ def setup
2929
# Create the HashMap
3030
@words = {}
3131
# Load two files
32-
load_file(DRACULA)
33-
load_file(FRANKENSTEIN)
32+
load_file(data_path(DRACULA))
33+
load_file(data_path(FRANKENSTEIN))
3434
# Create the font
3535
text_font(create_font('Georgia', 24))
3636
end
@@ -80,4 +80,3 @@ def load_file(filename)
8080
def settings
8181
size(640, 360)
8282
end
83-

processing_app/topics/shaders/reaction_diffusion.rb

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,38 @@ def settings
66

77
def setup
88
@pass = 0
9-
@shader_grayscott = load_shader(sketch_path('grayscott2.frag'))
10-
@shader_render = load_shader(sketch_path('render2.frag'))
11-
@pg_src = create_texture(width, height)
9+
@shader_render = load_shader(data_path('render2.frag'))
1210
@pg_dst = create_texture(width, height)
13-
# init
14-
pg_src.begin_draw
15-
pg_src.background(color(0xFFFF0000))
16-
pg_src.fill(color(0x0000FFFF))
17-
pg_src.no_stroke
18-
pg_src.rect_mode(CENTER)
19-
pg_src.rect(width / 2, height / 2, 20, 20)
20-
pg_src.end_draw
21-
frame_rate(1000)
11+
@pg_src = create_texture(width, height).tap do |src|
12+
src.begin_draw
13+
src.background(color(0xFFFF0000))
14+
src.fill(color(0x0000FFFF))
15+
src.no_stroke
16+
src.rect_mode(CENTER)
17+
src.rect(width / 2, height / 2, 20, 20)
18+
src.end_draw
19+
end
20+
@shader_grayscott = load_shader(data_path('grayscott2.frag'))
21+
shader_grayscott.set('dA', 1.0)
22+
shader_grayscott.set('dB', 0.5)
23+
shader_grayscott.set('feed', 0.055)
24+
shader_grayscott.set('kill', 0.062)
25+
shader_grayscott.set('dt', 1.0)
26+
shader_grayscott.set('wh_rcp', 1.0 / width, 1.0 / height)
27+
shader_grayscott.set('tex', pg_src)
28+
frame_rate(1_000)
2229
end
2330

2431
def create_texture(w, h)
25-
pg = create_graphics(w, h, P2D)
26-
pg.smooth(0)
27-
pg.begin_draw
28-
pg.texture_sampling(2)
29-
pg.blend_mode(REPLACE)
30-
pg.clear
31-
pg.no_stroke
32-
pg.end_draw
33-
pg
32+
create_graphics(w, h, P2D).tap do |pg|
33+
pg.smooth(0)
34+
pg.begin_draw
35+
pg.texture_sampling(2)
36+
pg.blend_mode(REPLACE)
37+
pg.clear
38+
pg.no_stroke
39+
pg.end_draw
40+
end
3441
end
3542

3643
def swap
@@ -39,13 +46,6 @@ def swap
3946

4047
def reaction_diffusion_pass
4148
pg_dst.begin_draw
42-
shader_grayscott.set('dA' , 1.0)
43-
shader_grayscott.set('dB' , 0.5)
44-
shader_grayscott.set('feed' , 0.055)
45-
shader_grayscott.set('kill' , 0.062)
46-
shader_grayscott.set('dt', 1.0 )
47-
shader_grayscott.set('wh_rcp', 1.0 / width, 1.0 / height)
48-
shader_grayscott.set('tex', pg_src)
4949
pg_dst.shader(shader_grayscott)
5050
pg_dst.rect_mode(CORNER)
5151
pg_dst.rect(0, 0, width, height)
@@ -56,7 +56,7 @@ def reaction_diffusion_pass
5656

5757
def draw
5858
# multipass rendering, ping-pong
59-
100.times { reaction_diffusion_pass }
59+
20.times { reaction_diffusion_pass }
6060
# display result
6161
shader_render.set('wh_rcp', 1.0 / width, 1.0 / height)
6262
shader_render.set('tex', pg_src)

processing_app/topics/shaders/video_filtering/black_white_capture.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
def setup
66
sketch_title 'Black White Capture'
7-
@my_shader = load_shader(data_path('bwfrag.glsl')) # since jruby_art-1.1
8-
# @my_shader = load_shader('bwfrag.glsl') # requires --nojruby flag
9-
# @my_shader = load_shader(File.absolute_path('data/bwfrag.glsl')) # full path
7+
@my_shader = load_shader(data_path('bwfrag.glsl'))
108
start_capture(width, height)
119
end
1210

processing_app/topics/shaders/video_filtering/steinberg.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77

88
def setup
99
sketch_title 'Steinberg'
10-
@my_shader = load_shader(data_path('steinberg.glsl')) # data_path wrapper since jruby_art-1.1
11-
# @my_shader = load_shader(File.absolute_path('data/steinberg.glsl')) # provide absolute data path
12-
# @my_shader = load_shader('steinberg.glsl') # requires --nojruby flag
10+
@my_shader = load_shader(data_path('steinberg.glsl'))
1311
my_shader.set('sketchSize', width.to_java(Java::float), height.to_java(Java::float))
1412
start_capture(width, height)
1513
end

0 commit comments

Comments
 (0)