ruby-processing 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +8 -0
- data/lib/patches/JRubyApplet.diff +0 -0
- data/lib/patches/PATCHES.txt +0 -0
- data/lib/patches/PApplet.diff +0 -0
- data/lib/ruby-processing.rb +1 -1
- data/lib/ruby-processing/app.rb +20 -1
- data/lib/ruby-processing/exporters/base_exporter.rb +1 -1
- data/lib/ruby-processing/exporters/creator.rb +1 -2
- data/lib/ruby-processing/runner.rb +4 -3
- data/lib/ruby-processing/runners/watch.rb +2 -2
- data/lib/templates/applet/index.html.erb +1 -1
- metadata +2 -145
- data/samples/learning_processing/ABOUT +0 -11
- data/samples/learning_processing/chapter_01/1_stroke_and_fill.rb +0 -18
- data/samples/learning_processing/chapter_01/2_nofill.rb +0 -20
- data/samples/learning_processing/chapter_01/3_rgb_color.rb +0 -19
- data/samples/learning_processing/chapter_01/4_alpha_transparency.rb +0 -42
- data/samples/learning_processing/chapter_01/5_zoog.rb +0 -24
- data/samples/learning_processing/chapter_02/1_zoog_again.rb +0 -41
- data/samples/learning_processing/chapter_03/1_zoog_as_dynamic_sketch.rb +0 -44
- data/samples/learning_processing/chapter_03/2_mouse_x_and_mouse_y.rb +0 -26
- data/samples/learning_processing/chapter_03/3_zoog_as_dynamic_sketch_with_variation.rb +0 -41
- data/samples/learning_processing/chapter_03/4_drawing_a_continuous_line.rb +0 -18
- data/samples/learning_processing/chapter_03/5_mouse_pressed_and_key_pressed.rb +0 -29
- data/samples/learning_processing/chapter_03/6_interactive_zoog.rb +0 -42
- data/samples/learning_processing/chapter_04/1_variable_declaration.rb +0 -24
- data/samples/learning_processing/chapter_04/2_using_variables.rb +0 -27
- data/samples/learning_processing/chapter_04/3_varying_variables.rb +0 -27
- data/samples/learning_processing/chapter_04/4_many_variables.rb +0 -38
- data/samples/learning_processing/chapter_04/5_using_system_variables.rb +0 -28
- data/samples/learning_processing/chapter_04/6_ellipse_with_variables.rb +0 -24
- data/samples/learning_processing/chapter_04/7_filling_variables_with_random_values.rb +0 -27
- data/samples/learning_processing/chapter_04/8_variable_zoog.rb +0 -50
- data/samples/learning_processing/chapter_05/01_conditionals.rb +0 -31
- data/samples/learning_processing/chapter_05/02_more_conditionals.rb +0 -38
- data/samples/learning_processing/chapter_05/03_rollovers.rb +0 -34
- data/samples/learning_processing/chapter_05/04_hold_down_the_button.rb +0 -33
- data/samples/learning_processing/chapter_05/05_button_as_switch.rb +0 -39
- data/samples/learning_processing/chapter_05/06_bouncing_ball.rb +0 -33
- data/samples/learning_processing/chapter_05/07_bouncing_color.rb +0 -37
- data/samples/learning_processing/chapter_05/08_square_following_edge.rb +0 -59
- data/samples/learning_processing/chapter_05/09_simple_gravity.rb +0 -43
- data/samples/learning_processing/chapter_05/10_zoog_and_conditionals.rb +0 -53
- data/samples/learning_processing/chapter_06/01_many_lines.rb +0 -29
- data/samples/learning_processing/chapter_06/02_many_lines_with_variables.rb +0 -53
- data/samples/learning_processing/chapter_06/03_while_loop.rb +0 -30
- data/samples/learning_processing/chapter_06/04_infinite_loop.rb +0 -25
- data/samples/learning_processing/chapter_06/05_another_infinite_loop.rb +0 -33
- data/samples/learning_processing/chapter_06/06_legs_with_a_for_loop.rb +0 -41
- data/samples/learning_processing/chapter_06/07_local_variables.rb +0 -39
- data/samples/learning_processing/chapter_06/08_lines_one_at_a_time.rb +0 -30
- data/samples/learning_processing/chapter_06/09_simple_while_loop_with_interactivity.rb +0 -41
- data/samples/learning_processing/chapter_06/10_zoog_with_arms.rb +0 -56
- data/samples/learning_processing/chapter_06/11_multiple_zoogs.rb +0 -46
- data/samples/learning_processing/chapter_07/01_defining_a_function.rb +0 -22
- data/samples/learning_processing/chapter_07/02_calling_a_function.rb +0 -22
- data/samples/learning_processing/chapter_07/03_bouncing_ball_with_functions.rb +0 -49
- data/samples/learning_processing/chapter_07/04_function_returns_distance.rb +0 -48
- data/samples/learning_processing/chapter_07/05_zoog_with_functions.rb +0 -71
- data/samples/learning_processing/chapter_08/01_car_class_and_car_variable.rb +0 -45
- data/samples/learning_processing/chapter_08/02_two_car_objects.rb +0 -60
- data/samples/learning_processing/chapter_08/03_object_oriented_zoog.rb +0 -81
- data/samples/learning_processing/chapter_10/01_catcher.rb +0 -35
- data/samples/learning_processing/chapter_10/02_bouncing_ball.rb +0 -44
- data/samples/learning_processing/chapter_10/03_bouncing_balls_with_intersection.rb +0 -69
- data/samples/learning_processing/chapter_10/04_a_timer.rb +0 -24
- data/samples/learning_processing/chapter_10/05_object_oriented_timer.rb +0 -42
- data/samples/learning_processing/chapter_10/06_simple_raindrop.rb +0 -23
- data/samples/learning_processing/chapter_10/07_drops_one_at_a_time.rb +0 -63
- data/samples/learning_processing/chapter_13/02_random_number_distribution.rb +0 -24
- data/samples/learning_processing/chapter_13/03_probabilities.rb +0 -33
- data/samples/learning_processing/chapter_13/04_perlin_noise.rb +0 -22
- data/samples/learning_processing/chapter_13/06_oscillation.rb +0 -29
- data/samples/learning_processing/chapter_13/07_wave.rb +0 -31
- data/samples/learning_processing/chapter_13/08_recursion.rb +0 -30
- data/samples/learning_processing/chapter_13/09_two_dimensional_array.rb +0 -21
- data/samples/learning_processing/chapter_13/10_two_dimensional_array_with_objects.rb +0 -54
- data/samples/learning_processing/chapter_14/01_growing_rectangle.rb +0 -26
- data/samples/learning_processing/chapter_14/02_multiple_translations.rb +0 -37
- data/samples/learning_processing/chapter_14/03_depth_rectangle.rb +0 -29
- data/samples/learning_processing/chapter_14/04_pyramid_using_beingshape.rb +0 -55
- data/samples/learning_processing/chapter_14/05_rotate_rectangle_around_center.rb +0 -28
- data/samples/learning_processing/chapter_14/06_rotate_z.rb +0 -24
- data/samples/learning_processing/chapter_14/07_rotate_x.rb +0 -24
- data/samples/learning_processing/chapter_14/08_rotate_y.rb +0 -24
- data/samples/learning_processing/chapter_14/09_rotate_all.rb +0 -24
- data/samples/learning_processing/chapter_14/10_draw_pyramid.rb +0 -59
- data/samples/learning_processing/chapter_14/12_rotating_one_square.rb +0 -25
- data/samples/learning_processing/chapter_14/13_rotating_another_square.rb +0 -25
- data/samples/learning_processing/chapter_14/14_rotating_both_squares.rb +0 -43
- data/samples/learning_processing/chapter_14/15_rotating_many_things.rb +0 -56
- data/samples/learning_processing/chapter_14/16_simple_solar_system.rb +0 -53
- data/samples/learning_processing/chapter_14/17_nested_push_and_pop.rb +0 -50
- data/samples/learning_processing/chapter_14/18_object_oriented_solar_system.rb +0 -69
- data/samples/learning_processing/chapter_15/01_hello_world_image.rb +0 -20
- data/samples/learning_processing/chapter_15/02_image_sprite.rb +0 -29
- data/samples/learning_processing/chapter_15/03_swapping_images.rb +0 -25
- data/samples/learning_processing/chapter_15/04_image_sequence.rb +0 -22
- data/samples/learning_processing/chapter_15/05_setting_pixels.rb +0 -19
- data/samples/learning_processing/chapter_15/06_pixels_2d.rb +0 -29
- data/samples/learning_processing/chapter_15/07_image_pixels.rb +0 -40
- data/samples/learning_processing/chapter_15/08_image_brightness.rb +0 -29
- data/samples/learning_processing/chapter_15/09_flashlight_effect.rb +0 -42
- data/samples/learning_processing/chapter_15/10_brightness_threshold.rb +0 -33
- data/samples/learning_processing/chapter_15/11_brightness_threshold_with_filter.rb +0 -20
- data/samples/learning_processing/chapter_15/12_pixel_neighbour_differences.rb +0 -43
- data/samples/learning_processing/chapter_15/14_pointillism.rb +0 -34
- data/samples/learning_processing/chapter_15/15_2d_image_mapped_to_3d.rb +0 -43
- data/samples/learning_processing/chapter_15/data/animal0.jpg +0 -0
- data/samples/learning_processing/chapter_15/data/animal1.jpg +0 -0
- data/samples/learning_processing/chapter_15/data/animal2.jpg +0 -0
- data/samples/learning_processing/chapter_15/data/animal3.jpg +0 -0
- data/samples/learning_processing/chapter_15/data/animal4.jpg +0 -0
- data/samples/learning_processing/chapter_15/data/animal5.jpg +0 -0
- data/samples/learning_processing/chapter_15/data/animal6.jpg +0 -0
- data/samples/learning_processing/chapter_15/data/face.jpg +0 -0
- data/samples/learning_processing/chapter_15/data/mysummervacation.jpg +0 -0
- data/samples/learning_processing/chapter_15/data/sunflower.jpg +0 -0
- data/samples/learning_processing/chapter_16/01_display_video.rb +0 -25
- data/samples/learning_processing/chapter_16/02_manipulate_video_image.rb +0 -24
- data/samples/learning_processing/chapter_16/03_adjust_video_brightness.rb +0 -49
- data/samples/learning_processing/chapter_17/01_simple_displaying_text.rb +0 -14
- data/samples/learning_processing/chapter_17/02_text_align.rb +0 -21
- data/samples/learning_processing/chapter_17/03_scrolling_headlines.rb +0 -35
- data/samples/learning_processing/chapter_17/04_text_mirror.rb +0 -68
- data/samples/learning_processing/chapter_17/05_rotating_text.rb +0 -22
- data/samples/learning_processing/chapter_17/06_text_breaking_up.rb +0 -73
- data/samples/learning_processing/chapter_17/07_boxes_along_a_curve.rb +0 -49
- data/samples/learning_processing/chapter_17/08_characters_along_a_curve.rb +0 -51
- data/samples/learning_processing/chapter_17/data/ArialMT-16.vlw +0 -0
- data/samples/learning_processing/chapter_17/data/Courier-Bold-20.vlw +0 -0
- data/samples/learning_processing/chapter_18/01_user_input.rb +0 -39
- data/samples/learning_processing/chapter_18/02_graphing_comma_separated_numbers_from_a_text_file.rb +0 -28
- data/samples/learning_processing/chapter_18/03_creating_object_from_a_text_file.rb +0 -64
- data/samples/learning_processing/chapter_18/data/data-1.txt +0 -1
- data/samples/learning_processing/chapter_18/data/data-2.txt +0 -10
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'ruby-processing'
|
2
|
-
|
3
|
-
class GrowingRectangleSketch < Processing::App
|
4
|
-
|
5
|
-
def setup
|
6
|
-
rect_mode CENTER
|
7
|
-
@r = 8
|
8
|
-
end
|
9
|
-
|
10
|
-
def draw
|
11
|
-
background 255
|
12
|
-
# Display a rectangle in the middle of the screen
|
13
|
-
stroke 0
|
14
|
-
fill 175
|
15
|
-
rect width/2, height/2, @r, @r
|
16
|
-
|
17
|
-
# Increase the rectangle size
|
18
|
-
@r += 1
|
19
|
-
|
20
|
-
# Start rectangle over
|
21
|
-
@r = 0 if @r > width
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
GrowingRectangleSketch.new :title => "Growing Rectangle", :width => 200, :height => 200
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'ruby-processing'
|
2
|
-
|
3
|
-
class MultipleTranslationsSketch < Processing::App
|
4
|
-
|
5
|
-
def setup
|
6
|
-
smooth
|
7
|
-
end
|
8
|
-
|
9
|
-
def draw
|
10
|
-
background 255
|
11
|
-
stroke 0
|
12
|
-
fill 175
|
13
|
-
|
14
|
-
# Grab mouse coordinates, constrained to window
|
15
|
-
mx = constrain(mouse_x, 0, width)
|
16
|
-
my = constrain(mouse_y, 0, height)
|
17
|
-
|
18
|
-
# Translate to the mouse location
|
19
|
-
translate mx, my
|
20
|
-
ellipse 0, 0, 8, 8
|
21
|
-
|
22
|
-
# Translate 100 pixels to the right
|
23
|
-
translate 100, 0
|
24
|
-
ellipse 0, 0, 8, 8
|
25
|
-
|
26
|
-
# Translate 100 pixels down
|
27
|
-
translate 0, 100
|
28
|
-
ellipse 0, 0, 8, 8
|
29
|
-
|
30
|
-
# Translate 100 pixels left
|
31
|
-
translate -100, 0
|
32
|
-
ellipse 0, 0, 8, 8
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
MultipleTranslationsSketch.new :title => "Multiple Translations", :width => 200, :height => 200
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'ruby-processing'
|
2
|
-
|
3
|
-
class DepthRectangleSketch < Processing::App
|
4
|
-
|
5
|
-
def setup
|
6
|
-
@z = 0 # A variable for the z (depth) coordinate
|
7
|
-
rect_mode CENTER
|
8
|
-
render_mode P3D
|
9
|
-
end
|
10
|
-
|
11
|
-
def draw
|
12
|
-
background 255
|
13
|
-
stroke 0
|
14
|
-
fill 175
|
15
|
-
|
16
|
-
# Translate to a point before displaying a shape there
|
17
|
-
translate width/2, height/2, @z
|
18
|
-
rect 0, 0, 8, 8
|
19
|
-
|
20
|
-
# Increment z (i.e. move the shape toward the viewer)
|
21
|
-
@z += 1
|
22
|
-
|
23
|
-
# Start rectangle over
|
24
|
-
@z = 0 if @z > 200
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
DepthRectangleSketch.new :title => "Depth Rectangle", :width => 200, :height => 200
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'ruby-processing'
|
2
|
-
|
3
|
-
class PyramidUsingBeginshape < Processing::App
|
4
|
-
|
5
|
-
def setup
|
6
|
-
render_mode P3D
|
7
|
-
end
|
8
|
-
|
9
|
-
def draw
|
10
|
-
background 255
|
11
|
-
stroke 0
|
12
|
-
|
13
|
-
# The pyramid's vertices are drawn relative to a centerpoint.
|
14
|
-
# Therefore, we call translate to place the pyramid properly in the window.
|
15
|
-
# A slightly better option might be to include the translate in the draw_pyramid function and pass in x,y,z as arguments
|
16
|
-
translate 100, 100, 0
|
17
|
-
draw_pyramid 150
|
18
|
-
end
|
19
|
-
|
20
|
-
|
21
|
-
# The function sets the vertices for the pyramid around the centerpoint at a flexible distance,
|
22
|
-
# depending on the number passed in as an argument.
|
23
|
-
def draw_pyramid(t)
|
24
|
-
# this pyramid has 4 sides, each drawn as a separate triangle
|
25
|
-
# each side has 3 vertices, making up a triangle shape
|
26
|
-
# the parameter " t " determines the size of the pyramid
|
27
|
-
begin_shape TRIANGLES
|
28
|
-
|
29
|
-
fill 255, 150 # Note that each polygon can have its own color.
|
30
|
-
vertex -t,-t,-t
|
31
|
-
vertex t,-t,-t
|
32
|
-
vertex 0, 0, t
|
33
|
-
|
34
|
-
fill 150, 150
|
35
|
-
vertex t,-t,-t
|
36
|
-
vertex t, t,-t
|
37
|
-
vertex 0, 0, t
|
38
|
-
|
39
|
-
fill 255, 150
|
40
|
-
vertex t, t,-t
|
41
|
-
vertex -t, t,-t
|
42
|
-
vertex 0, 0, t
|
43
|
-
|
44
|
-
fill 150, 150
|
45
|
-
vertex -t, t,-t
|
46
|
-
vertex -t,-t,-t
|
47
|
-
vertex 0, 0, t
|
48
|
-
|
49
|
-
end_shape
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
PyramidUsingBeginshape.new :title => "Draw Pyramid Using BeginShape", :width => 200, :height => 200
|
55
|
-
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'ruby-processing'
|
2
|
-
|
3
|
-
class RotateRectangleAroundCenterSketch < Processing::App
|
4
|
-
|
5
|
-
def setup
|
6
|
-
render_mode P3D
|
7
|
-
rect_mode CENTER
|
8
|
-
end
|
9
|
-
|
10
|
-
def draw
|
11
|
-
background 255
|
12
|
-
stroke 0
|
13
|
-
fill 175
|
14
|
-
|
15
|
-
# translate to center
|
16
|
-
translate width/2, height/2
|
17
|
-
# The greek letter "theta" is often used as the name of a variable to store an angle
|
18
|
-
# The angle ranges from 0 to PI, based on the ratio of mouse_x location to the sketch's width.
|
19
|
-
theta = PI * mouse_x / width
|
20
|
-
|
21
|
-
rotate theta
|
22
|
-
rect 0, 0, 100, 100
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
RotateRectangleAroundCenterSketch.new :title => "Rotate Rectangle Around Center", :width => 200, :height => 200
|
28
|
-
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'ruby-processing'
|
2
|
-
|
3
|
-
class RotateZSketch < Processing::App
|
4
|
-
|
5
|
-
def setup
|
6
|
-
rect_mode CENTER
|
7
|
-
render_mode P3D
|
8
|
-
@theta = 0
|
9
|
-
end
|
10
|
-
|
11
|
-
def draw
|
12
|
-
background 255
|
13
|
-
stroke 0
|
14
|
-
fill 175
|
15
|
-
|
16
|
-
translate width/2, height/2
|
17
|
-
rotate_z @theta
|
18
|
-
rect 0, 0, 100, 100
|
19
|
-
@theta += 0.02
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
RotateZSketch.new :title => "Rotate Z", :width => 200, :height => 200
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'ruby-processing'
|
2
|
-
|
3
|
-
class RotateXSketch < Processing::App
|
4
|
-
|
5
|
-
def setup
|
6
|
-
render_mode P3D
|
7
|
-
rect_mode CENTER
|
8
|
-
@theta = 0
|
9
|
-
end
|
10
|
-
|
11
|
-
def draw
|
12
|
-
background 255
|
13
|
-
stroke 0
|
14
|
-
fill 175
|
15
|
-
|
16
|
-
translate width/2, height/2
|
17
|
-
rotate_x @theta
|
18
|
-
rect 0, 0, 100, 100
|
19
|
-
@theta += 0.02
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
RotateXSketch.new :title => "Rotate X", :width => 200, :height => 200
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'ruby-processing'
|
2
|
-
|
3
|
-
class RotateYSketch < Processing::App
|
4
|
-
|
5
|
-
def setup
|
6
|
-
render_mode P3D
|
7
|
-
rect_mode CENTER
|
8
|
-
@theta = 0
|
9
|
-
end
|
10
|
-
|
11
|
-
def draw
|
12
|
-
background 255
|
13
|
-
stroke 0
|
14
|
-
fill 175
|
15
|
-
|
16
|
-
translate width/2, height/2
|
17
|
-
rotate_y @theta
|
18
|
-
rect 0, 0, 100, 100
|
19
|
-
@theta += 0.02
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
RotateYSketch.new :title => "Rotate Y", :width => 200, :height => 200
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'ruby-processing'
|
2
|
-
|
3
|
-
class RotateAllSketch < Processing::App
|
4
|
-
|
5
|
-
def setup
|
6
|
-
render_mode P3D
|
7
|
-
rect_mode CENTER
|
8
|
-
end
|
9
|
-
|
10
|
-
def draw
|
11
|
-
background 255
|
12
|
-
stroke 0
|
13
|
-
fill 175
|
14
|
-
|
15
|
-
translate width/2, height/2
|
16
|
-
rotate_x PI * mouse_x / height
|
17
|
-
rotate_y PI * mouse_x / height
|
18
|
-
rect 0, 0, 100, 100
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
RotateAllSketch.new :title => "Rotate All", :width => 200, :height => 200
|
24
|
-
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require 'ruby-processing'
|
2
|
-
|
3
|
-
class DrawPyramidSketch < Processing::App
|
4
|
-
|
5
|
-
def setup
|
6
|
-
render_mode P3D
|
7
|
-
@theta = 0.0
|
8
|
-
end
|
9
|
-
|
10
|
-
def draw
|
11
|
-
background 255
|
12
|
-
@theta += 0.01
|
13
|
-
|
14
|
-
translate 100, 100, 0
|
15
|
-
rotate_x @theta
|
16
|
-
rotate_y @theta
|
17
|
-
draw_pyramid 50
|
18
|
-
|
19
|
-
# translate the scene again
|
20
|
-
translate 50, 50, 20
|
21
|
-
# call the pyramid drawing function
|
22
|
-
draw_pyramid 10
|
23
|
-
end
|
24
|
-
|
25
|
-
def draw_pyramid(t)
|
26
|
-
stroke 0
|
27
|
-
|
28
|
-
# this pyramid has 4 sides, each drawn as a separate triangle
|
29
|
-
# each side has 3 vertices, making up a triangle shape
|
30
|
-
# the parameter "t" determines the size of the pyramid
|
31
|
-
begin_shape TRIANGLES
|
32
|
-
|
33
|
-
fill 150, 0, 0, 127
|
34
|
-
vertex -t, -t, -t
|
35
|
-
vertex t, -t, -t
|
36
|
-
vertex 0, 0, t
|
37
|
-
|
38
|
-
fill 0, 150, 0, 127
|
39
|
-
vertex t, -t, -t
|
40
|
-
vertex t, t, -t
|
41
|
-
vertex 0, 0, t
|
42
|
-
|
43
|
-
fill 0, 0, 150, 127
|
44
|
-
vertex t, t, -t
|
45
|
-
vertex -t, t, -t
|
46
|
-
vertex 0, 0, t
|
47
|
-
|
48
|
-
fill 150, 0, 150, 127
|
49
|
-
vertex -t, t, -t
|
50
|
-
vertex -t, -t, -t
|
51
|
-
vertex 0, 0, t
|
52
|
-
|
53
|
-
end_shape
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
|
59
|
-
DrawPyramidSketch.new :title => "Draw Pyramid", :width => 200, :height => 200
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'ruby-processing'
|
2
|
-
|
3
|
-
class RotatingOneSquareSketch < Processing::App
|
4
|
-
|
5
|
-
def setup
|
6
|
-
render_mode P3D
|
7
|
-
rect_mode CENTER
|
8
|
-
@theta1 = 0
|
9
|
-
end
|
10
|
-
|
11
|
-
def draw
|
12
|
-
background 255
|
13
|
-
stroke 0
|
14
|
-
fill 175
|
15
|
-
|
16
|
-
translate 50, 50
|
17
|
-
rotate_z @theta1
|
18
|
-
rect 0, 0, 60, 60
|
19
|
-
@theta1 += 0.02
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
RotatingOneSquareSketch.new :title => "Rotating One Square", :width => 200, :height => 200
|
25
|
-
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'ruby-processing'
|
2
|
-
|
3
|
-
class RotatingAnotherSquareSketch < Processing::App
|
4
|
-
|
5
|
-
def setup
|
6
|
-
render_mode P3D
|
7
|
-
rect_mode CENTER
|
8
|
-
@theta2 = 0
|
9
|
-
end
|
10
|
-
|
11
|
-
def draw
|
12
|
-
background 255
|
13
|
-
stroke 0
|
14
|
-
fill 175
|
15
|
-
|
16
|
-
translate 150, 150
|
17
|
-
rotate_y @theta2
|
18
|
-
rect 0, 0, 60, 60
|
19
|
-
@theta2 += 0.02
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
RotatingAnotherSquareSketch.new :title => "Rotating Another Square", :width => 200, :height => 200
|
25
|
-
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'ruby-processing'
|
2
|
-
|
3
|
-
class RotatingBothSquaresSketch < Processing::App
|
4
|
-
|
5
|
-
def setup
|
6
|
-
render_mode P3D
|
7
|
-
rect_mode CENTER
|
8
|
-
@theta1 = @theta2 = 0
|
9
|
-
end
|
10
|
-
|
11
|
-
def draw
|
12
|
-
background 255
|
13
|
-
stroke 0
|
14
|
-
fill 175
|
15
|
-
|
16
|
-
# Save the current transformation matrix.
|
17
|
-
# This is where we started, with (0,0) in the top left corner of the window and no rotation.
|
18
|
-
push_matrix
|
19
|
-
|
20
|
-
# Translate and rotate the first rectangle.
|
21
|
-
translate 50, 50
|
22
|
-
rotate_z @theta1
|
23
|
-
# Display the first rectangle.
|
24
|
-
rect 0, 0, 60, 60
|
25
|
-
# Restore matrix from Step 1 so that it isn't affected by Steps 2 and 3!
|
26
|
-
pop_matrix
|
27
|
-
|
28
|
-
push_matrix
|
29
|
-
# Translate and rotate the second rectangle.
|
30
|
-
translate 150, 150
|
31
|
-
rotate_y @theta2
|
32
|
-
# Display the second rectangle.
|
33
|
-
rect 0, 0, 60, 60
|
34
|
-
pop_matrix
|
35
|
-
|
36
|
-
@theta1 += 0.02
|
37
|
-
@theta2 += 0.02
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
RotatingBothSquaresSketch.new :title => "Rotating Both Squares", :width => 200, :height => 200
|
43
|
-
|