Skip to content

Commit 03f822d

Browse files
committed
samll
1 parent 19089d1 commit 03f822d

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

processing_app/library/video/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
###README
1+
### README
22

33
You will need to install the video library from processing.org (since it is no longer included in the vanilla processing distro), this is easiest done from the processing ide, see the [Dan Shiffman video][] on video capture.
44
[Dan Shiffman video]:http://vimeo.com/115436609
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#
2+
# Loading doc Data
3+
# by Daniel Shiffman.
4+
#
5+
# This example demonstrates how to use loaddoc
6+
# to retrieve data from an doc file and make objects
7+
# from that data.
8+
#
9+
# Here is what the doc looks like:
10+
#
11+
# <?doc version='1.0'?>
12+
# <bubbles>
13+
# <bubble>
14+
# <position x='160' y='103'/>
15+
# <diameter>43.19838</diameter>
16+
# <label>Happy</label>
17+
# </bubble>
18+
# <bubble>
19+
# <position x='372' y='137'/>
20+
# <diameter>52.42526</diameter>
21+
# <label>Sad</label>
22+
# </bubble>
23+
# </bubbles>
24+
#
25+
require 'nokogiri'
26+
load_library 'bubble'
27+
28+
attr_reader :bubbles
29+
30+
def setup
31+
sketch_title 'Load save Nokogiri'
32+
load_data
33+
end
34+
35+
def draw
36+
background(255)
37+
# Display all bubbles
38+
bubbles.each do |b|
39+
b.display
40+
b.rollover(mouse_x, mouse_y)
41+
end
42+
text_align(LEFT)
43+
fill(0)
44+
text('Click to add bubbles.', 10, height - 10)
45+
end
46+
47+
def load_data
48+
# Load doc file
49+
file = File.open(data_path('data.xml'), 'r')
50+
doc = Nokogiri.XML(file)
51+
sketch_title 'Load & Save doc'
52+
# total doc elements named 'bubble'
53+
@bubbles = []
54+
doc.xpath("*[//bubble]").each do |b|
55+
diameter = b.at_xpath("//diameter").content.to_f
56+
label = b.at_xpath("//label").content
57+
position = b.at_xpath("//position")
58+
x = position['x'].value.to_f
59+
y = position['y'].value.to_f
60+
# Make a Bubble object out of the data read
61+
bubbles << Bubble.new(x, y, diameter, label)
62+
end
63+
file.close
64+
end
65+
66+
def settings
67+
size(640, 360)
68+
end

0 commit comments

Comments
 (0)