Skip to content

Commit da395c7

Browse files
committed
Nokogiri never worked FX2D is crap with text
1 parent 01f4557 commit da395c7

File tree

16 files changed

+158
-184
lines changed

16 files changed

+158
-184
lines changed

processing_app/topics/advanced_data/Rakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Simple demo Rakefile to autorun samples in current directory
2-
# adjust path to rp5 executable, and or opts as required
2+
# adjust path to k9 executable, and or opts as required
33

44
SAMPLES_DIR = './'
55

@@ -22,7 +22,7 @@ end
2222

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

processing_app/topics/advanced_data/counting_words.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,5 @@ def draw
7171
end
7272

7373
def settings
74-
size 640, 360, FX2D
74+
size 640, 360
7575
end

processing_app/topics/advanced_data/data/data.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ emotions:
2020
- 179
2121
diameter: 44.758068
2222
label: Melancholy
23+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
emotions:
3+
- !ruby/struct:BubbleStruct
4+
xpos: 160
5+
ypos: 103
6+
diameter: 43.19838
7+
label: Happy
8+
- !ruby/struct:BubbleStruct
9+
xpos: 372
10+
ypos: 137
11+
diameter: 52.42526
12+
label: Sad
13+
- !ruby/struct:BubbleStruct
14+
xpos: 273
15+
ypos: 235
16+
diameter: 61.14072
17+
label: Joyous
18+
- !ruby/struct:BubbleStruct
19+
xpos: 121
20+
ypos: 179
21+
diameter: 44.758068
22+
label: Melancholy

processing_app/topics/advanced_data/data/struct_data.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
require_relative 'lib/bubble_reader.rb'
2+
require_relative 'lib/bubble_writer.rb'
3+
require_relative 'lib/bubble.rb'
4+
require_relative 'lib/bubble_struct.rb'
5+
require_relative 'lib/bubble_data.rb'
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# The Bubble class
2+
class Bubble
3+
include Processing::Proxy
4+
attr_reader :struct, :over
5+
6+
def initialize(struct)
7+
@struct = struct
8+
@over = false
9+
end
10+
11+
def rollover(px, py)
12+
distance = dist px, py, struct.xpos, struct.ypos
13+
@over = (distance < struct.diameter / 2.0)
14+
end
15+
16+
def display
17+
display_bubble(struct.xpos, struct.ypos)
18+
return unless over
19+
display_label(struct.xpos, struct.ypos)
20+
end
21+
22+
def display_bubble(xpos, ypos)
23+
stroke 0
24+
stroke_weight 2
25+
no_fill
26+
ellipse xpos, ypos, struct.diameter, struct.diameter
27+
end
28+
29+
def display_label(xpos, ypos)
30+
fill 0
31+
text_align CENTER
32+
text(struct.label, xpos, ypos + struct.diameter / 2.0 + 20)
33+
end
34+
end
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
MAX_BUBBLE = 10
2+
3+
# Bubble data holder
4+
class BubbleData
5+
attr_reader :bubbles
6+
def initialize(bubbles)
7+
@bubbles = bubbles
8+
end
9+
10+
def add_bubble(bubble)
11+
bubbles << bubble
12+
bubbles.shift if bubbles.size > MAX_BUBBLE
13+
end
14+
15+
def to_struct
16+
bubbles.map(&:struct)
17+
end
18+
end
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
require 'yaml'
2+
3+
# yaml bubble reader
4+
class BubbleReader
5+
attr_reader :hash
6+
7+
def read(path)
8+
@hash = YAML.load_file(path)
9+
end
10+
end
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Holder of bubble data for saving as yaml file
2+
BubbleStruct = Struct.new(:xpos, :ypos, :diameter, :label)

0 commit comments

Comments
 (0)