ruby-processing 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +12 -0
- data/lib/ruby-processing.rb +2 -1
- data/lib/ruby-processing/app.rb +7 -5
- data/lib/ruby-processing/exporters/creator.rb +7 -4
- data/lib/ruby-processing/helpers/numeric.rb +11 -0
- data/lib/ruby-processing/helpers/string.rb +8 -0
- data/lib/ruby-processing/runner.rb +11 -10
- data/lib/ruby-processing/runners/watch.rb +33 -0
- data/samples/bezier_playground.rb +243 -0
- data/samples/flight_patterns.rb +1 -1
- data/samples/learning_processing/chapter_16/01_display_video.rb +1 -1
- data/samples/learning_processing/chapter_16/02_manipulate_video_image.rb +1 -1
- data/samples/processing_app/basics/arrays/array.rb +41 -0
- data/samples/processing_app/basics/arrays/array_2d.rb +38 -0
- data/samples/processing_app/basics/arrays/array_objects.rb +67 -0
- data/samples/processing_app/basics/color/brightness.rb +30 -0
- data/samples/processing_app/basics/color/color_wheel.rb +97 -0
- data/samples/processing_app/basics/color/creating.rb +37 -0
- data/samples/processing_app/basics/color/hue.rb +29 -0
- data/samples/processing_app/basics/color/linear_gradient.rb +47 -0
- data/samples/processing_app/basics/color/radial_gradient.rb +52 -0
- data/samples/processing_app/basics/color/reading/data/cait.jpg +0 -0
- data/samples/processing_app/basics/color/reading/reading.rb +43 -0
- data/samples/processing_app/basics/color/relativity.rb +38 -0
- data/samples/processing_app/basics/color/saturation.rb +35 -0
- data/samples/processing_app/basics/color/wave_gradient.rb +45 -0
- data/samples/processing_app/basics/control/conditionals1.rb +51 -0
- data/samples/processing_app/basics/control/conditionals2.rb +44 -0
- data/samples/processing_app/basics/control/embedded_iteration.rb +42 -0
- data/samples/processing_app/basics/control/iteration.rb +61 -0
- data/samples/processing_app/basics/control/logical_operators.rb +59 -0
- data/samples/processing_app/basics/data/characters_strings/characters_strings.rb +87 -0
- data/samples/processing_app/basics/data/characters_strings/data/Eureka-90.vlw +0 -0
- data/samples/processing_app/basics/data/characters_strings/data/rathausFrog.jpg +0 -0
- data/samples/processing_app/basics/data/datatype_conversion.rb +45 -0
- data/samples/processing_app/basics/data/integers_floats.rb +34 -0
- data/samples/processing_app/basics/data/true_false.rb +37 -0
- data/samples/processing_app/basics/data/variable_scope.rb +80 -0
- data/samples/processing_app/basics/data/variables.rb +40 -0
- data/samples/processing_app/basics/form/bezier.rb +23 -0
- data/samples/processing_app/basics/form/bezier_ellipse.rb +110 -0
- data/samples/processing_app/basics/form/pie_chart.rb +31 -0
- data/samples/processing_app/basics/form/points_lines.rb +37 -0
- data/samples/processing_app/basics/form/shape_primitives.rb +25 -0
- data/samples/processing_app/basics/form/triangle_strip.rb +43 -0
- data/samples/processing_app/basics/form/vertices.rb +51 -0
- data/samples/processing_app/basics/image/alphamask.rb +23 -0
- data/samples/processing_app/basics/image/background_image.rb +30 -0
- data/samples/processing_app/basics/image/create_image.rb +23 -0
- data/samples/processing_app/basics/image/data/construct.jpg +0 -0
- data/samples/processing_app/basics/image/data/eames.jpg +0 -0
- data/samples/processing_app/basics/image/data/jelly.jpg +0 -0
- data/samples/processing_app/basics/image/data/mask.jpg +0 -0
- data/samples/processing_app/basics/image/data/milan_rubbish.jpg +0 -0
- data/samples/processing_app/basics/image/data/teddy.gif +0 -0
- data/samples/processing_app/basics/image/data/test.jpg +0 -0
- data/samples/processing_app/basics/image/data/wash.jpg +0 -0
- data/samples/processing_app/basics/image/load_display_image.rb +25 -0
- data/samples/processing_app/basics/image/pointillism.rb +30 -0
- data/samples/processing_app/basics/image/request_image.rb +71 -0
- data/samples/processing_app/basics/image/sprite.rb +38 -0
- data/samples/processing_app/basics/image/transparency.rb +27 -0
- data/samples/processing_app/basics/input/clock.rb +46 -0
- data/samples/processing_app/basics/input/constrain.rb +39 -0
- data/samples/processing_app/basics/input/easing.rb +33 -0
- data/samples/processing_app/basics/input/keyboard.rb +36 -0
- data/samples/processing_app/basics/input/keyboard_2.rb +45 -0
- data/samples/processing_app/basics/input/keyboard_functions.rb +87 -0
- data/samples/processing_app/basics/input/milliseconds.rb +25 -0
- data/samples/processing_app/basics/input/mouse_1d.rb +34 -0
- data/samples/processing_app/basics/input/mouse_2d.rb +25 -0
- data/samples/processing_app/basics/input/mouse_functions.rb +73 -0
- data/samples/processing_app/basics/input/mouse_press.rb +21 -0
- data/samples/processing_app/basics/input/mouse_signals.rb +45 -0
- data/samples/processing_app/basics/input/storing_input.rb +39 -0
- data/samples/processing_app/basics/math/additive_wave.rb +66 -0
- data/samples/processing_app/basics/math/arctangent.rb +54 -0
- data/samples/processing_app/topics/simulate/chain.rb +82 -0
- data/samples/processing_app/topics/simulate/multiple_particle_systems.rb +166 -0
- data/samples/processing_app/topics/simulate/simple_particle_system.rb +113 -0
- data/samples/processing_app/topics/simulate/spring.rb +85 -0
- data/samples/processing_app/topics/simulate/springs.rb +125 -0
- metadata +93 -2
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'ruby-processing'
|
2
|
+
|
3
|
+
# Move the mouse across the screen to move the circle.
|
4
|
+
# The program constrains the circle to its box.
|
5
|
+
|
6
|
+
class Constrain < Processing::App
|
7
|
+
|
8
|
+
def setup
|
9
|
+
no_stroke
|
10
|
+
smooth
|
11
|
+
ellipse_mode RADIUS
|
12
|
+
|
13
|
+
@mx, @my = 0.0, 0.0
|
14
|
+
@easing = 0.05
|
15
|
+
@ellipse_size = 25.0
|
16
|
+
@box_size = 30
|
17
|
+
@together = @box_size + @ellipse_size
|
18
|
+
end
|
19
|
+
|
20
|
+
def draw
|
21
|
+
background 51
|
22
|
+
|
23
|
+
@mx += (mouse_x - @mx) * @easing if (mouse_x - @mx).abs > 0.1
|
24
|
+
@my += (mouse_y - @my) * @easing if (mouse_y - @my).abs > 0.1
|
25
|
+
|
26
|
+
distance = @ellipse_size * 2
|
27
|
+
@mx = constrain @mx, (@box_size + distance), (width - @box_size - distance)
|
28
|
+
@my = constrain @my, (@box_size + distance), (height - @box_size - distance)
|
29
|
+
|
30
|
+
fill 76
|
31
|
+
rect @together, @together, @box_size * 3, @box_size * 3
|
32
|
+
|
33
|
+
fill 255
|
34
|
+
ellipse @mx, @my, @ellipse_size, @ellipse_size
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
Constrain.new :title => "Constrain", :width => 200, :height => 200
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'ruby-processing'
|
2
|
+
|
3
|
+
# Move the mouse across the screen and the symbol will follow.
|
4
|
+
# Between drawing each frame of the animation, the program
|
5
|
+
# calculates the difference between the position of the
|
6
|
+
# symbol and the cursor. If the distance is larger than
|
7
|
+
# 1 pixel, the symbol moves part of the distance (0.05) from its
|
8
|
+
# current position toward the cursor.
|
9
|
+
|
10
|
+
class Easing < Processing::App
|
11
|
+
|
12
|
+
def setup
|
13
|
+
@x, @y = 0.0, 0.0
|
14
|
+
@easing = 0.05
|
15
|
+
smooth
|
16
|
+
no_stroke
|
17
|
+
end
|
18
|
+
|
19
|
+
def draw
|
20
|
+
background 51
|
21
|
+
|
22
|
+
dx = mouse_x - @x
|
23
|
+
@x += dx * @easing if dx.abs > 1
|
24
|
+
|
25
|
+
dy = mouse_y - @y
|
26
|
+
@y += dy * @easing if dy.abs > 1
|
27
|
+
|
28
|
+
ellipse @x, @y, 33, 33
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
Easing.new :title => "Easing", :width => 200, :height => 200
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'ruby-processing'
|
2
|
+
|
3
|
+
# Click into the window to give it focus and press the letter keys
|
4
|
+
# to create forms in time and space. Each key has a unique identifying
|
5
|
+
# number called it's ASCII value. These numbers can be used to position
|
6
|
+
# shapes in space.
|
7
|
+
|
8
|
+
class Keyboard < Processing::App
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@num_chars = 26
|
12
|
+
@key_scale = 200.0 / @num_chars-1.0
|
13
|
+
@rect_width = width/4
|
14
|
+
|
15
|
+
no_stroke
|
16
|
+
background 0
|
17
|
+
end
|
18
|
+
|
19
|
+
def draw
|
20
|
+
if key_pressed?
|
21
|
+
if key >= ("A"[0]) && key <= ("z"[0])
|
22
|
+
if key <= ("Z"[0])
|
23
|
+
@key_index = key - ("A"[0])
|
24
|
+
else
|
25
|
+
@key_index = key - ("a"[0])
|
26
|
+
end
|
27
|
+
fill millis % 255
|
28
|
+
begin_rect = @rect_width/2 + @key_index * @key_scale - @rect_width/2
|
29
|
+
rect begin_rect, 0, @rect_width, height
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
Keyboard.new :title => "Keyboard", :width => 200, :height => 200
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'ruby-processing'
|
2
|
+
|
3
|
+
# Click into the window to give it focus and press the letter keys
|
4
|
+
# to create forms in time and space. Each key has a unique identifying
|
5
|
+
# number called it's ASCII value. These numbers can be used to position
|
6
|
+
# shapes in space.
|
7
|
+
|
8
|
+
class Keyboard2 < Processing::App
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@num_chars = 26
|
12
|
+
@key_scale = 200.0 / @num_chars-1.0
|
13
|
+
@rect_width = width/4
|
14
|
+
no_stroke
|
15
|
+
background 0
|
16
|
+
end
|
17
|
+
|
18
|
+
def draw
|
19
|
+
if key_pressed?
|
20
|
+
if key.chr && key.chr >= "A" && key.chr <= "z" # added testing 'gainst Nil
|
21
|
+
if key.chr <= "Z"
|
22
|
+
@key_index = key - "A".ord
|
23
|
+
else
|
24
|
+
@key_index = key - "a".ord
|
25
|
+
end
|
26
|
+
fill millis % 255
|
27
|
+
begin_rect = @rect_width/2 + @key_index * @key_scale - @rect_width/2
|
28
|
+
rect begin_rect, 0, @rect_width, height
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
# String.ord is Ruby 1.9, so this is a little fix for R 1.8
|
36
|
+
# to make it forward compatible and readable
|
37
|
+
unless String.method_defined? "ord"
|
38
|
+
class String
|
39
|
+
def ord
|
40
|
+
self[0]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
Keyboard2.new :title => "Keyboard 2", :width => 200, :height => 200
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'ruby-processing'
|
2
|
+
|
3
|
+
# Modified from code by Martin.
|
4
|
+
# Original 'Color Typewriter' concept by John Maeda.
|
5
|
+
#
|
6
|
+
# Click on the window to give it focus and press the letter keys to type colors.
|
7
|
+
# The keyboard function keyPressed() is called whenever
|
8
|
+
# a key is pressed. keyReleased() is another keyboard
|
9
|
+
# function that is called when a key is released.
|
10
|
+
|
11
|
+
class KeyboardFunctions < Processing::App
|
12
|
+
|
13
|
+
def setup
|
14
|
+
@num_chars = 26
|
15
|
+
@letter_width, @letter_height = 10, 10
|
16
|
+
@x = -@letter_width
|
17
|
+
@y = 0
|
18
|
+
|
19
|
+
no_stroke
|
20
|
+
color_mode RGB, @num_chars
|
21
|
+
background @num_chars/2
|
22
|
+
|
23
|
+
# Set a gray value for each key
|
24
|
+
@colors = []
|
25
|
+
@num_chars.times { |i| @colors[i] = color i }
|
26
|
+
end
|
27
|
+
|
28
|
+
def draw
|
29
|
+
if new_letter?
|
30
|
+
if upcase?
|
31
|
+
fill (key - "A".ord).abs % 255
|
32
|
+
rect @x, @y, @letter_width, @letter_height*2
|
33
|
+
else
|
34
|
+
# clear with letter space with background color
|
35
|
+
fill @num_chars/2
|
36
|
+
rect @x, @y, @letter_width, @letter_height
|
37
|
+
|
38
|
+
fill (key - "a".ord).abs % 255
|
39
|
+
rect @x, @y+@letter_height, @letter_width, @letter_height
|
40
|
+
end
|
41
|
+
@new_letter = false
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def new_letter?
|
46
|
+
@new_letter
|
47
|
+
end
|
48
|
+
|
49
|
+
def upcase?
|
50
|
+
@upcase
|
51
|
+
end
|
52
|
+
|
53
|
+
def key_pressed
|
54
|
+
# Try to get a String for int value in "key"
|
55
|
+
key_char = nil
|
56
|
+
key_char = key.chr rescue nil
|
57
|
+
|
58
|
+
# if the key is between 'A'(65) and 'z'(122)
|
59
|
+
if key_char && key_char >= "A" && key_char <= "z"
|
60
|
+
if key_char <= "Z"
|
61
|
+
@upcase = true
|
62
|
+
else
|
63
|
+
@upcase = false
|
64
|
+
end
|
65
|
+
end
|
66
|
+
@new_letter = true
|
67
|
+
|
68
|
+
# Update the "letter" position and
|
69
|
+
# wrap horizontally and vertically
|
70
|
+
@y += (@letter_height*2) if @x + @letter_width >= width
|
71
|
+
@y = @y % height
|
72
|
+
@x += @letter_width
|
73
|
+
@x = @x % width
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
# A fix for Ruby 1.8 that adds String.ord of Ruby 1.9
|
79
|
+
class String
|
80
|
+
unless method_defined? "ord"
|
81
|
+
def ord
|
82
|
+
self[0] # return character code point of first character
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
KeyboardFunctions.new :title => "Keyboard Functions", :width => 200, :height => 200
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'ruby-processing'
|
2
|
+
|
3
|
+
# A millisecond is 1/1000 of a second.
|
4
|
+
# Processing keeps track of the number of milliseconds a program has run.
|
5
|
+
# By modifying this number with the modulo(%) operator,
|
6
|
+
# different patterns in time are created.
|
7
|
+
|
8
|
+
class Milliseconds < Processing::App
|
9
|
+
|
10
|
+
def setup
|
11
|
+
no_stroke
|
12
|
+
@scale = width/10
|
13
|
+
end
|
14
|
+
|
15
|
+
def draw
|
16
|
+
@scale.times do |i|
|
17
|
+
color_mode RGB, (i+1) * @scale * 10
|
18
|
+
fill millis % ((i+1) * @scale * 10)
|
19
|
+
rect i*@scale, 0, @scale, height
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
Milliseconds.new :title => "Milliseconds", :width => 200, :height => 200
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'ruby-processing'
|
2
|
+
|
3
|
+
# Move the mouse left and right to shift the balance.
|
4
|
+
# The "mouseX" variable is used to control both the
|
5
|
+
# size and color of the rectangles.
|
6
|
+
|
7
|
+
class Mouse1d < Processing::App
|
8
|
+
|
9
|
+
def setup
|
10
|
+
color_mode RGB, 1.0
|
11
|
+
rect_mode CENTER
|
12
|
+
no_stroke
|
13
|
+
end
|
14
|
+
|
15
|
+
def draw
|
16
|
+
background 0
|
17
|
+
|
18
|
+
x_dist_blocks = width/2
|
19
|
+
block_size = map mouse_x, 0, width, 10, x_dist_blocks-10
|
20
|
+
|
21
|
+
left_color = -0.002 * mouse_x/2 + 0.06
|
22
|
+
fill 0.0, left_color + 0.4, left_color + 0.6
|
23
|
+
rect width/4, height/2, block_size*2, block_size*2
|
24
|
+
|
25
|
+
block_size = x_dist_blocks - block_size
|
26
|
+
|
27
|
+
right_color = 0.002 * mouse_x/2 + 0.06
|
28
|
+
fill 0.0, right_color + 0.2, right_color + 0.4
|
29
|
+
rect (width/4)*3, height/2, block_size*2, block_size*2
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
Mouse1d.new :title => "Mouse 1d", :width => 200, :height => 200
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'ruby-processing'
|
2
|
+
|
3
|
+
# Moving the mouse changes the position and size of each box.
|
4
|
+
|
5
|
+
class Mouse2d < Processing::App
|
6
|
+
|
7
|
+
def setup
|
8
|
+
no_stroke
|
9
|
+
color_mode RGB, 255, 255, 255, 100
|
10
|
+
rect_mode CENTER
|
11
|
+
end
|
12
|
+
|
13
|
+
def draw
|
14
|
+
background 51
|
15
|
+
fill 255, 80
|
16
|
+
rect mouse_x, height/2, mouse_y/2+10, mouse_y/2+10
|
17
|
+
fill 255, 80
|
18
|
+
inverse_x = width-mouse_x
|
19
|
+
inverse_y = height-mouse_y
|
20
|
+
rect inverse_x, height/2, inverse_y/2+10, inverse_y/2+10
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
Mouse2d.new :title => "Mouse 2d", :width => 200, :height => 200
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'ruby-processing'
|
2
|
+
|
3
|
+
# Click on the box and drag it across the screen.
|
4
|
+
|
5
|
+
class MouseFunctions < Processing::App
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@block = {"x" => width/2.0, "y" => height/2.0}
|
9
|
+
@block_diff = {"x" => 0.0, "y" => 0.0}
|
10
|
+
@locked = false
|
11
|
+
@over_block = false
|
12
|
+
@block_width = 20
|
13
|
+
|
14
|
+
rect_mode RADIUS
|
15
|
+
end
|
16
|
+
|
17
|
+
def draw
|
18
|
+
background 0
|
19
|
+
|
20
|
+
fill 153
|
21
|
+
|
22
|
+
if (mouse_x > @block["x"]-@block_width && # Test if the cursor is over the box
|
23
|
+
mouse_x < @block["x"]+@block_width &&
|
24
|
+
mouse_y > @block["y"]-@block_width &&
|
25
|
+
mouse_y < @block["y"]+@block_width )
|
26
|
+
|
27
|
+
@over_block = true
|
28
|
+
|
29
|
+
stroke 255
|
30
|
+
|
31
|
+
fill 255 if block_locked?
|
32
|
+
else
|
33
|
+
@over_block = false
|
34
|
+
stroke 153
|
35
|
+
end
|
36
|
+
|
37
|
+
# Draw the box
|
38
|
+
rect @block["x"], @block["y"], @block_width, @block_width
|
39
|
+
end
|
40
|
+
|
41
|
+
def block_locked?
|
42
|
+
@block_locked
|
43
|
+
end
|
44
|
+
|
45
|
+
def over_block?
|
46
|
+
@over_block
|
47
|
+
end
|
48
|
+
|
49
|
+
def mouse_pressed
|
50
|
+
if over_block?
|
51
|
+
@block_locked = true
|
52
|
+
fill 255
|
53
|
+
else
|
54
|
+
@block_locked = false
|
55
|
+
end
|
56
|
+
@block_diff["x"] = mouse_x - @block["x"]
|
57
|
+
@block_diff["y"] = mouse_y - @block["y"]
|
58
|
+
end
|
59
|
+
|
60
|
+
def mouse_dragged
|
61
|
+
if block_locked?
|
62
|
+
@block["x"] = mouse_x - @block_diff["x"]
|
63
|
+
@block["y"] = mouse_y - @block_diff["y"]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def mouse_released
|
68
|
+
@block_locked = false
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
MouseFunctions.new :title => "Mouse Functions", :width => 200, :height => 200
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'ruby-processing'
|
2
|
+
|
3
|
+
# Move the mouse to position the shape.
|
4
|
+
# Press the mouse button to invert the color.
|
5
|
+
|
6
|
+
class MousePress < Processing::App
|
7
|
+
|
8
|
+
def setup
|
9
|
+
fill 126
|
10
|
+
background 102
|
11
|
+
end
|
12
|
+
|
13
|
+
def draw
|
14
|
+
mouse_pressed? ? stroke(255) : stroke(0)
|
15
|
+
line mouse_x-66, mouse_y, mouse_x+66, mouse_y
|
16
|
+
line mouse_x, mouse_y-66, mouse_x, mouse_y+66
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
MousePress.new :title => "Mouse Press", :width => 200, :height => 200
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'ruby-processing'
|
2
|
+
|
3
|
+
# Move and click the mouse to generate signals.
|
4
|
+
# The top row is the signal from "mouseX",
|
5
|
+
# the middle row is the signal from "mouseY",
|
6
|
+
# and the bottom row is the signal from "mousePressed".
|
7
|
+
|
8
|
+
class MouseSignals < Processing::App
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@xvals = Array.new width, 0
|
12
|
+
@yvals = Array.new width, 0
|
13
|
+
@bvals = Array.new width, 0
|
14
|
+
end
|
15
|
+
|
16
|
+
def draw
|
17
|
+
background 102
|
18
|
+
|
19
|
+
width.times do |i|
|
20
|
+
@xvals[i] = @xvals[i + 1]
|
21
|
+
@yvals[i] = @yvals[i + 1]
|
22
|
+
@bvals[i] = @bvals[i + 1]
|
23
|
+
end
|
24
|
+
|
25
|
+
@xvals[width-1] = mouse_x
|
26
|
+
@yvals[width-1] = mouse_y
|
27
|
+
@bvals[width-1] = mouse_pressed? ? 0 : 200
|
28
|
+
|
29
|
+
fill 255
|
30
|
+
no_stroke
|
31
|
+
rect 0, height/3, width, height/3+1
|
32
|
+
|
33
|
+
(1...width).each do |i|
|
34
|
+
stroke 255
|
35
|
+
point i, @xvals[i]/3
|
36
|
+
stroke 0
|
37
|
+
point i, height/3+@yvals[i]/3
|
38
|
+
stroke 255
|
39
|
+
line i, 2*height/3+@bvals[i]/3, i, 2*height/3+@bvals[i-1]/3
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
MouseSignals.new :title => "Mouse Signals", :width => 200, :height => 200
|