Skip to content

Commit 87dacf5

Browse files
committed
more data_path
1 parent 8922ed5 commit 87dacf5

40 files changed

+216
-222
lines changed

processing_app/basics/image/alphamask.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
# Loads a "mask" for an image to specify the transparency
1+
# Loads a "mask" for an image to specify the transparency
22
# in different parts of the image. The two images are blended
3-
# together using the mask() method of PImage.
4-
3+
# together using the mask() method of PImage.
54

65
def setup
76
sketch_title 'Alpha Mask'
8-
@image = load_image 'test.jpg'
9-
@image_mask = load_image 'mask.jpg'
7+
@image = load_image(data_path('test.jpg'))
8+
@image_mask = load_image(data_path('mask.jpg'))
109
@image.mask @image_mask
1110
end
1211

processing_app/basics/image/background_image.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ def setup
77
frame_rate 30
88
@a = 0
99
# is 200 x 200 pixels.
10-
@background_image = load_image 'milan_rubbish.jpg'
10+
@background_image = load_image(data_path('milan_rubbish.jpg'))
1111
end
1212

1313
def draw
1414
background @background_image
15-
@a = (@a + 1) % (width+32)
15+
@a = (@a + 1) % (width + 32)
1616
stroke 266, 204, 0
1717
line 0, @a, width, @a-26
1818
line 0, @a-6, width, @a-32

processing_app/basics/image/colored_extrusion.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def setup
1313
@nmy = 0.0
1414
@sval = 1.0
1515
@res = 5
16-
@img = load_image 'ystone08.jpg'
16+
@img = load_image(data_path('ystone08.jpg'))
1717
@img_pixels = []
1818
(0...@img.height).each do |y|
1919
@img_pixels << []

processing_app/basics/image/load_display_image.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ def setup
33
sketch_title 'Load Image'
44
# The file "jelly.jpg" must be in the data folder
55
# of the current sketch to load successfully
6-
@a = load_image 'jelly.jpg'
6+
@a = load_image(data_path('jelly.jpg'))
77
no_loop # Makes draw only run once
88
end
99

1010
def draw
1111
image @a, 0, 0
12-
image @a, @a.width, 0, @a.width/2, @a.height/2
12+
image @a, @a.width, 0, @a.width / 2, @a.height / 2
1313
end
1414

1515
def settings

processing_app/basics/image/pointillism.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# Pointillism
2-
# by Daniel Shiffman.
3-
#
2+
# by Daniel Shiffman.
3+
#
44
# Creates a simple pointillist effect using ellipses colored
5-
# according to pixels in an image.
5+
# according to pixels in an image.
66

77
def setup
88
sketch_title 'Pointillism'
9-
@a = load_image 'eames.jpg'
9+
@a = load_image(data_path('eames.jpg'))
1010
no_stroke
1111
background 255
1212
smooth
1313
end
1414

1515
def draw
16-
pointillize = map(mouse_x, 0, width, 2, 18)
16+
pointillize = map1d(mouse_x, 0..width, 2..18)
1717
x, y = rand(@a.width), rand(@a.height)
1818
pixel = @a.get(x, y)
1919
fill pixel, 126

processing_app/basics/image/request_image.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414

1515
def setup
1616
sketch_title 'Request Image'
17-
@imgs = []
1817
# Load images asynchronously, kind of pointless with this few small images
19-
10.times do |i|
20-
imgs << request_image(format('PT_anim%s.gif', i.to_s.rjust(4, '0')))
21-
end
18+
@imgs = (0...10).map do |i|
19+
request_image(
20+
data_path(format('PT_anim%s.gif', i.to_s.rjust(4, '0'))
21+
)
22+
)
23+
end
2224
end
2325

2426
def draw

processing_app/basics/image/sprite.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
def setup
77
sketch_title 'Sprite'
8-
@teddy = load_image "teddy.gif"
8+
@teddy = load_image(data_path('teddy.gif'))
99
@xpos, @ypos = width / 2, height / 2
1010
@drag = 30.0
1111
frame_rate 60

processing_app/basics/image/transparency.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
def setup
66
sketch_title 'Transparency'
7-
@a = load_image 'construct.jpg'
8-
@b = load_image 'wash.jpg'
7+
@a = load_image(data_path('construct.jpg'))
8+
@b = load_image(data_path('wash.jpg'))
99
@offset = 0.0
1010
end
1111

processing_app/basics/shape/Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ end
2222

2323
def run_sample(sample_name)
2424
puts "Running #{sample_name}...quit to run next sample"
25-
open("|k9 --nojruby run #{sample_name}", "r") do |io|
25+
open("|k9 run #{sample_name}", "r") do |io|
2626
while l = io.gets
2727
puts(l.chop)
2828
end

processing_app/basics/shape/disable_style.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Ignore Styles.
2-
# Illustration by George Brower.
3-
#
1+
# Ignore Styles.
2+
# Illustration by George Brower.
3+
#
44
# Shapes are loaded with style information that tells them how
5-
# to draw (the color, stroke weight, etc.) The disableStyle
5+
# to draw (the color, stroke weight, etc.) The disableStyle
66
# method of PShape turns off this information. The enableStyle
77
# method turns it back on.
88
#
@@ -12,11 +12,11 @@ def setup
1212
sketch_title 'Disable Style'
1313
# The file 'bot1.svg' must be in the data folder
1414
# of the current sketch to load successfully
15-
@bot = load_shape('bot1.svg')
15+
@bot = load_shape(data_path('bot1.svg'))
1616
end
1717

1818
def draw
19-
background(102)
19+
background(102)
2020
# Draw left bot
2121
bot.disable_style # Ignore the colors in the SVG
2222
fill(0, 102, 153) # Set the SVG fill to blue

0 commit comments

Comments
 (0)