Skip to content

Commit ee8814f

Browse files
committed
Bump up to JRubyArt-1.4.9, processing-3.3.7 and jruby-9.1.17.0
1 parent 1eb21b3 commit ee8814f

File tree

10 files changed

+36
-33
lines changed

10 files changed

+36
-33
lines changed

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.9.3-p392
1+
2.3.3

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ simple live coding
22
===============
33

44
This is a proof of concept for a live drawing app in Ruby with
5-
the [Ruby-Processing Gem (based on processing-2.0.1, and jruby-1.7.4)](https://github.com/monkstone/ruby-processing)
5+
the [JRubyArt Gem (based on processing-3.3.7, and jruby-9.1.17.0)](https://github.com/ruby-processing/JRubyArt)
66

77
Get inspired by [Bret Victor](http://worrydream.com/#!/LearnableProgramming) or join the project with your own idea..
88

@@ -16,7 +16,7 @@ With "ellipse 50, 50, 80, 80" or "rect/line/fill" you can draw and with mouse dr
1616
Notice
1717
===============
1818

19-
Start Ruby-Processing with "rp5 watch simple_live_coding.rb". This reloads "simple_live_coding.rb" after safing and you can implement your ideas in this file
19+
Start JRubyArt with `k9 -w simple_live_coding.rb`. This reloads `simple_live_coding.rb` after saving and you can implement your ideas in this file
2020
without need to restart. After implementation of the new feature just copy your code in a seperate file in the "main" directory and do "require_relative" for the file.
2121

22-
This is live coding a live coding app...
22+
This is a live coding app...

main/canvas.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,4 @@ def send_if_runnable(methode, args)
3838
puts "#{ e } (#{ e.class })!"
3939
end
4040
end
41-
42-
end
41+
end

main/cursor.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ class Cursor
33

44
def initialize(line)
55
@line = line
6-
@x = $app.start_of_editor_text
7-
@y = $app.editor_top_margin
6+
@x = Processing.app.start_of_editor_text
7+
@y = Processing.app.editor_top_margin
88
end
99

1010
def set_position(x,y) #on mouse down
@@ -30,11 +30,11 @@ def draw_line
3030
end
3131

3232
def go_to_new_line #after tap enter button
33-
@y += $app.line_height+$app.line_space
33+
@y += Processing.app.line_height+Processing.app.line_space
3434
end
3535

3636
def go_to_previous_line
37-
@y -= $app.line_height+$app.line_space
37+
@y -= Processing.app.line_height+Processing.app.line_space
3838
end
3939

4040
private

main/editor.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ def draw_content
1616
def draw_text
1717
@lines.elements.each do |str_obj|
1818
eval("text '#{str_obj.content}',
19-
#{$app.width/2},
19+
#{Processing.app.width/2},
2020
#{str_obj.get_position.to_a.last}")
2121
end
2222
end
2323

2424
def draw_explanation
2525
return eval("text '#{@description.explanation}',
26-
#{$app.width-@description.explanation_length-$app.editor_right_margin},
27-
#{@description.position+$app.editor_top_margin}")
26+
#{Processing.app.width-@description.explanation_length-Processing.app.editor_right_margin},
27+
#{@description.position+Processing.app.editor_top_margin}")
2828

2929
end
3030
end

main/lines.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ class Lines
22

33
def initialize
44
@elements = []
5-
@line_height = $app.line_height
6-
@line_space = $app.line_space
5+
@line_height = Processing.app.line_height
6+
@line_space = Processing.app.line_space
77
@positiontable = generate_hashtable
88
initialize_positiontable
99
end
@@ -21,7 +21,7 @@ def position(x,y)
2121
#get the linge and extract x, y param
2222
line_range = @positiontable[y].get_position
2323
y = line_range.to_a.last
24-
[$app.start_of_editor_text, y]
24+
[Processing.app.start_of_editor_text, y]
2525
end
2626

2727
def make_new_line(cursor)

main/string_object.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ def methode
2222

2323
def update_param(x_mouse, y_mouse)
2424
#Try to find beginn of param and set this as the char_position to prevent unintendet param change!!!
25-
char_position = find_char($app.pressed[0])
25+
char_position = find_char(Processing.app.pressed[0])
2626
found_number = find_number(char_position) unless char_position.nil?
2727
if found_number and found_number != [0..0]
28-
new_param_value = -$app.width/2+x_mouse-length($app.initial_param[:string])+$app.initial_param[:value]
28+
new_param_value = -Processing.app.width/2+x_mouse-length(Processing.app.initial_param[:string])+Processing.app.initial_param[:value]
2929
begin_of_param = found_number[0].first
3030
current_param_length = @content[found_number[0]].to_s.length
3131
@content[begin_of_param, current_param_length] = new_param_value.to_s
@@ -34,7 +34,7 @@ def update_param(x_mouse, y_mouse)
3434

3535
def get_param_values
3636
#get the rigth param of x position and give the value back
37-
char_position = find_char($app.pressed[0])
37+
char_position = find_char(Processing.app.pressed[0])
3838
if char_position
3939
found_number = find_number(char_position)[0]
4040
unless found_number == [0..0]
@@ -63,7 +63,7 @@ def length(s)
6363
end
6464

6565
def update_char_position
66-
start_position = $app.width/2
66+
start_position = Processing.app.width/2
6767
char_length_new = 0
6868
@char_position = Hash.new {|this_hash,missing_key| #set always a new hash to keep track of growing numbers
6969
found_key = this_hash.keys.find {|this_key| this_key.class == Range && this_key.include?(missing_key) }

main/watch.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def initialize(lines, description, cursor)
66
end
77

88
def check_line(x, y)
9-
if x > ($app.width/2) + $app.editor_left_margin
9+
if x > (Processing.app.width/2) + Processing.app.editor_left_margin
1010
if @lines.positiontable(y) == :undefined
1111
@description.position = [-50] # set it outside the view field
1212
else
@@ -19,7 +19,7 @@ def check_line(x, y)
1919
def check_param(x,y)
2020
y_position = @cursor.y_position
2121
string_object = @lines.positiontable(y_position)
22-
if (string_object.position[0]).include?($app.pressed[1])
22+
if (string_object.position[0]).include?(Processing.app.pressed[1])
2323
string_object.update_param(x,y) unless string_object == :undefined
2424
end
2525
end

simple_live_coding.rb

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'ruby-processing'
1+
require 'jruby_art'
22

33
class RubyDraw < Processing::App
44

@@ -13,8 +13,12 @@ class RubyDraw < Processing::App
1313

1414
attr_reader :editor_left_margin, :editor_right_margin, :editor_top_margin, :start_of_editor_text, :line_height, :line_space, :pressed, :initial_param
1515

16+
def settings
17+
size 700, 600 # access with Processing.app.width
18+
end
19+
1620
def setup
17-
size 700, 600 # access with $app.width
21+
sketch_title 'Simple Live Coding'
1822
@editor_left_margin = 10
1923
@editor_right_margin = 15
2024
@editor_top_margin = 15
@@ -37,32 +41,32 @@ def setup
3741
#initial drawing for testing:
3842
"rect 20, 30, 30, 40".chars.each{ |c| @parser.update_line(c, 0) }
3943
end
40-
44+
4145
def draw
4246
background 55
4347
@canvas.draw_canvas
4448
fill color 304, 353, 300
45-
rect ($app.width/2)-10,0,($app.width/2)+10,height
49+
rect (Processing.app.width/2)-10,0,(Processing.app.width/2)+10,height
4650
fill color 104, 153, 0
4751
@editor.draw_content
4852

49-
text mouse_x.to_s, $app.width/2, $app.height-60
50-
text "this is a DEMO app", $app.width/2, $app.height-40
51-
text "write 'rect 20, 20, 200, 200' and drag the values...", $app.width/2, $app.height-20
53+
text mouse_x.to_s, Processing.app.width/2, Processing.app.height-60
54+
text "this is a DEMO app", Processing.app.width/2, Processing.app.height-40
55+
text "write 'rect 20, 20, 200, 200' and drag the values...", Processing.app.width/2, Processing.app.height-20
5256

5357
fill color 14, 13, 0
5458
@cursor.draw_line #we need a line marking the text position
5559
fill color 104, 153, 0
5660

5761
if mouse_pressed?
58-
sleep(0.12) #needed because of unintented param change line selection
62+
sleep(0.12) #needed because of unintented param change line selection
5963
loop
6064
@watcher.check_param(mouse_x, mouse_y)
6165
else
6266
@pressed = false
6367
no_loop
6468
end
65-
69+
6670
end
6771

6872
def key_pressed
@@ -84,4 +88,4 @@ def mouse_pressed
8488

8589
end
8690

87-
RubyDraw.new :title => "simple_live_coding"
91+
RubyDraw.new

spec/simple_live_coding_spec.rb

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

66
describe "app" do
77
it "should open window" do
8-
$app.width.should == 700
8+
Processing.app.width.should == 700
99
end
1010
end
1111

0 commit comments

Comments
 (0)