Skip to content

Commit 58de516

Browse files
committed
many fixes
1 parent d5716fc commit 58de516

5 files changed

Lines changed: 10 additions & 13 deletions

File tree

processing_app/topics/advanced_data/load_save_XML.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def draw
4545

4646
def load_data
4747
# Load XML file
48-
@xml = loadXML('data.xml')
48+
@xml = loadXML(data_path('data.xml'))
4949
# Get all the child nodes named 'bubble'
5050
children = xml.get_children('bubble')
5151
sketch_title 'Load & Save Xml'
@@ -90,7 +90,7 @@ def mouse_pressed
9090
# If the XML file has more than 10 bubble elements
9191
xml.remove_child(children[0]) if children.length > 10
9292
# Save a new XML file
93-
saveXML(xml, 'data/data.xml')
93+
saveXML(xml, data_path('data.xml'))
9494
# reload the new data
9595
load_data
9696
end

processing_app/topics/advanced_data/threads_two.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def setup
2525
def load_image_thread
2626
thread do # supply a block in JRubyArt rather than use reflection
2727
FRAMES.times do |i|
28-
frames << load_image(format(IMG_F, i.to_s.rjust(3, '0')))
28+
frames << load_image(data_path(format(IMG_F, i.to_s.rjust(3, '0'))))
2929
@curr = i
3030
delay(75) # slows down this thread, the main draw cycle is unaffected
3131
end

processing_app/topics/create_shapes/group_pshape.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,18 @@ def setup
4444
# Make a primitive (Rectangle) PShape
4545
rectangle = create_shape(RECT,-10,-10,20,20)
4646
rectangle.set_fill(false)
47-
rectangle.set_stroke(255)
47+
rectangle.set_stroke(color(255))
4848

4949
# Add them all to the group
5050
group.add_child(star)
5151
group.add_child(path)
52-
group.add_child(rectangle) # Rectangle is missing???
53-
52+
group.add_child(rectangle)
5453
end
5554

5655
def draw
5756

5857
# We can access them individually via the group PShape
59-
@rectangle = group.get_child(2)
58+
rectangle = group.get_child(2)
6059
# Shapes can be rotated
6160
rectangle.rotate(0.1)
6261

processing_app/topics/create_shapes/particle_system_pshape.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
def setup
1313
sketch_title 'Particle System Pshape'
1414
# Load the image
15-
sprite = loadImage('sprite.png')
15+
sprite = load_image(data_path('sprite.png'))
1616
# A new particle system with 10,000 particles
1717
@ps = ParticleSystem.new(width, height, sprite, 10_000)
1818
# Writing to the depth buffer is disabled to avoid rendering
@@ -27,13 +27,11 @@ def draw
2727
ps.update
2828
ps.display
2929
# Set the particle system's emitter location to the mouse
30-
ps.set_emitter(mouse_x, mouse_y)
31-
30+
ps.set_emitter(mouse_x, mouse_y)
3231
# Display frame rate
3332
fill(255, 0, 255)
3433
text_size(16)
35-
text("Frame rate: #{format('%0.2f', frame_rate)}", 10, 20)
36-
34+
text("Frame rate: #{format('%0.2f', frame_rate)}", 10, 20)
3735
end
3836

3937

processing_app/topics/create_shapes/primitive_pshape.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def draw
2020
# We can dynamically set the stroke and fill of the shape
2121
circle.set_stroke(color(255))
2222
circle.set_stroke_weight(4)
23-
circle.set_fill(color(map(mouseX, 0, width, 0, 255)))
23+
circle.set_fill(color(map1d(mouseX, 0..width, 0..255)))
2424
# We can use translate to move the PShape
2525
translate(mouse_x, mouse_y)
2626
# Drawing the PShape

0 commit comments

Comments
 (0)