ruby-processing 1.0.9 → 1.0.10.1
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 +13 -1
- data/bin/rp5 +8 -2
- data/lib/core/core.jar +0 -0
- data/lib/core/jruby-complete.jar +0 -0
- data/lib/ruby-processing.rb +2 -2
- data/lib/ruby-processing/app.rb +108 -338
- data/lib/ruby-processing/config.rb +6 -0
- data/lib/ruby-processing/helper_methods.rb +120 -0
- data/lib/ruby-processing/library_loader.rb +140 -0
- data/lib/ruby-processing/runner.rb +34 -4
- data/lib/ruby-processing/runners/base.rb +10 -11
- data/lib/ruby-processing/runners/live.rb +1 -1
- data/lib/ruby-processing/runners/run.rb +1 -1
- data/lib/ruby-processing/runners/watch.rb +18 -76
- data/lib/templates/applet/index.html.erb +8 -9
- data/library/control_panel/control_panel.rb +1 -1
- data/library/dxf/library/dxf.jar +0 -0
- data/library/dxf/library/export.txt +1 -0
- data/library/javascript/library/export.txt +3 -1
- data/library/minim/library/export.txt +1 -0
- data/library/minim/library/jl1.0.jar +0 -0
- data/library/minim/library/jsminim.jar +0 -0
- data/library/minim/library/minim-spi.jar +0 -0
- data/library/minim/library/minim.jar +0 -0
- data/library/minim/library/mp3spi1.9.4.jar +0 -0
- data/library/minim/library/tritonus_aos.jar +0 -0
- data/library/minim/library/tritonus_share.jar +0 -0
- data/library/net/library/export.txt +1 -0
- data/library/net/library/net.jar +0 -0
- data/library/opengl/library/export.txt +7 -10
- data/library/opengl/library/gluegen-rt.jar +0 -0
- data/library/opengl/library/jogl.jar +0 -0
- data/library/opengl/library/{libgluegen-rt.so → linux32/libgluegen-rt.so} +0 -0
- data/library/opengl/library/{libjogl.so → linux32/libjogl.so} +0 -0
- data/library/opengl/library/{libjogl_awt.so → linux32/libjogl_awt.so} +0 -0
- data/library/opengl/library/{libjogl_cg.so → linux32/libjogl_cg.so} +0 -0
- data/library/opengl/library/linux64/libgluegen-rt.so +0 -0
- data/library/opengl/library/linux64/libjogl.so +0 -0
- data/library/opengl/library/linux64/libjogl_awt.so +0 -0
- data/library/opengl/library/linux64/libjogl_cg.so +0 -0
- data/library/opengl/library/{libgluegen-rt.jnilib → macosx/libgluegen-rt.jnilib} +0 -0
- data/library/opengl/library/{libjogl.jnilib → macosx/libjogl.jnilib} +0 -0
- data/library/opengl/library/{libjogl_awt.jnilib → macosx/libjogl_awt.jnilib} +0 -0
- data/library/opengl/library/{libjogl_cg.jnilib → macosx/libjogl_cg.jnilib} +0 -0
- data/library/opengl/library/opengl.jar +0 -0
- data/library/opengl/library/{gluegen-rt.dll → windows32/gluegen-rt.dll} +0 -0
- data/library/opengl/library/{jogl.dll → windows32/jogl.dll} +0 -0
- data/library/opengl/library/{jogl_awt.dll → windows32/jogl_awt.dll} +0 -0
- data/library/opengl/library/{jogl_cg.dll → windows32/jogl_cg.dll} +0 -0
- data/library/opengl/library/windows64/gluegen-rt.dll +0 -0
- data/library/opengl/library/windows64/jogl.dll +0 -0
- data/library/opengl/library/windows64/jogl_awt.dll +0 -0
- data/library/opengl/library/windows64/jogl_cg.dll +0 -0
- data/library/pdf/library/export.txt +1 -0
- data/library/pdf/library/itext.jar +0 -0
- data/library/pdf/library/pdf.jar +0 -0
- data/library/serial/library/RXTXcomm.jar +0 -0
- data/library/serial/library/export.txt +1 -3
- data/library/serial/library/linux32/librxtxSerial.so +0 -0
- data/library/serial/library/linux64/librxtxSerial.so +0 -0
- data/library/serial/library/macosx/librxtxSerial.jnilib +0 -0
- data/library/serial/library/serial.jar +0 -0
- data/library/serial/library/windows32/rxtxSerial.dll +0 -0
- data/library/serial/library/windows64/rxtxSerial.dll +0 -0
- data/library/video/library/export.txt +1 -0
- data/library/video/library/video.jar +0 -0
- data/samples/{animator.rb → contributed/animator.rb} +0 -0
- data/samples/{bezier_playground.rb → contributed/bezier_playground.rb} +0 -0
- data/samples/{circle_collision.rb → contributed/circle_collision.rb} +0 -0
- data/samples/contributed/drawolver.rb +182 -0
- data/samples/{empathy.rb → contributed/empathy.rb} +7 -7
- data/samples/{fern.rb → contributed/fern.rb} +0 -0
- data/samples/{flight_patterns.rb → contributed/flight_patterns.rb} +0 -0
- data/samples/{full_screen.rb → contributed/full_screen.rb} +0 -0
- data/samples/{getting_started.rb → contributed/getting_started.rb} +0 -0
- data/samples/{gravity.rb → contributed/gravity.rb} +0 -0
- data/samples/{jwishy.rb → contributed/jwishy.rb} +0 -0
- data/samples/{orbit.rb → contributed/orbit.rb} +0 -0
- data/samples/{pong.rb → contributed/pong.rb} +0 -0
- data/samples/{reflection.rb → contributed/reflection.rb} +0 -0
- data/samples/{simple_buffer.rb → contributed/simple_buffer.rb} +0 -0
- data/samples/{tree.rb → contributed/tree.rb} +0 -0
- data/samples/peasy_cam/library/hilbert/hilbert.rb +11 -10
- data/samples/processing_app/3D/camera/move_eye.rb +29 -0
- data/samples/processing_app/3D/form/brick_tower.rb +11 -11
- data/samples/processing_app/3D/form/cubic_grid.rb +51 -0
- data/samples/processing_app/3D/form/icosahedra/icosahedra.rb +76 -0
- data/samples/processing_app/3D/form/icosahedra/icosahedron.rb +116 -0
- data/samples/processing_app/3D/form/icosahedra/shape_3D.rb +25 -0
- data/samples/processing_app/3D/form/primitives.rb +42 -0
- data/samples/processing_app/3D/form/rgb_cube.rb +88 -0
- data/samples/processing_app/3D/form/shape_transform.rb +94 -0
- data/samples/processing_app/3D/form/toroid.rb +130 -0
- data/samples/processing_app/3D/form/vertices.rb +81 -0
- data/samples/processing_app/3D/image/data/eames.jpg +0 -0
- data/samples/processing_app/3D/image/data/ystone08.jpg +0 -0
- data/samples/processing_app/3D/image/explode.rb +56 -0
- data/samples/processing_app/3D/image/extrusion.rb +49 -0
- data/samples/processing_app/3D/image/zoom.rb +83 -0
- data/samples/processing_app/3D/lights/directional.rb +41 -0
- data/samples/processing_app/3D/lights/lights1.rb +39 -0
- data/samples/processing_app/3D/lights/lights2.rb +42 -0
- data/samples/processing_app/3D/lights/reflection.rb +38 -0
- data/samples/processing_app/3D/lights/spot.rb +39 -0
- data/samples/processing_app/3D/textures/data/berlin-1.jpg +0 -0
- data/samples/processing_app/3D/textures/texture1.rb +41 -0
- data/samples/processing_app/3D/textures/texture2.rb +38 -0
- data/samples/processing_app/3D/textures/texture3.rb +68 -0
- data/samples/processing_app/3D/textures/texture_cube.rb +106 -0
- data/samples/processing_app/3D/transform/bird.rb +61 -0
- data/samples/processing_app/3D/transform/birds/bird.rb +87 -0
- data/samples/processing_app/3D/transform/birds/birds.rb +48 -0
- data/samples/processing_app/3D/transform/cubes_in_cube/cube.rb +57 -0
- data/samples/processing_app/3D/transform/cubes_in_cube/cubes_in_cube.rb +102 -0
- data/samples/processing_app/3D/transform/push_pop_cubes.rb +152 -0
- data/samples/processing_app/3D/transform/rotate1.rb +43 -0
- data/samples/processing_app/3D/transform/rotate2.rb +45 -0
- data/samples/processing_app/3D/typography/data/Univers45.vlw +0 -0
- data/samples/processing_app/3D/typography/letter_k.rb +136 -0
- data/samples/processing_app/3D/typography/typing.rb +77 -0
- data/samples/processing_app/basics/form/triangle_strip.rb +19 -19
- data/samples/processing_app/basics/math/distance1.rb +59 -0
- data/samples/processing_app/basics/math/distance2.rb +38 -0
- data/samples/processing_app/basics/math/double_random.rb +38 -0
- data/samples/processing_app/basics/math/graphing_2_d_equation.rb +53 -0
- data/samples/processing_app/basics/math/increment_decrement.rb +59 -0
- data/samples/processing_app/basics/math/modulo.rb +43 -0
- data/samples/processing_app/basics/math/noise_1_d.rb +37 -0
- data/samples/processing_app/basics/math/noise_2_d.rb +47 -0
- data/samples/processing_app/basics/math/noise_3_d.rb +50 -0
- data/samples/processing_app/basics/math/noise_wave.rb +61 -0
- data/samples/processing_app/basics/math/operator_precedence.rb +70 -0
- data/samples/processing_app/basics/math/polar_to_cartesian.rb +44 -0
- data/samples/processing_app/basics/math/random.rb +35 -0
- data/samples/processing_app/basics/math/sine.rb +49 -0
- data/samples/processing_app/basics/math/sine_cosine.rb +60 -0
- data/samples/processing_app/basics/math/sine_wave.rb +62 -0
- data/samples/processing_app/basics/objects/composite_objects.rb +139 -0
- data/samples/processing_app/basics/objects/inheritance.rb +104 -0
- data/samples/processing_app/basics/objects/multiple_constructors.rb +66 -0
- data/samples/processing_app/basics/objects/objects.rb +72 -0
- data/samples/processing_app/basics/shape/data/bot1.svg +160 -0
- data/samples/processing_app/basics/shape/data/usa-wikipedia.svg +452 -0
- data/samples/processing_app/basics/shape/disable_style.rb +36 -0
- data/samples/processing_app/basics/shape/get_child.rb +43 -0
- data/samples/processing_app/basics/shape/load_display_shape.rb +33 -0
- data/samples/processing_app/basics/shape/scale_shape.rb +33 -0
- data/samples/processing_app/basics/structure/coordinates.rb +55 -0
- data/samples/processing_app/basics/structure/create_graphics.rb +39 -0
- data/samples/processing_app/basics/structure/functions.rb +41 -0
- data/samples/processing_app/basics/structure/loop.rb +39 -0
- data/samples/processing_app/basics/structure/noloop.rb +33 -0
- data/samples/processing_app/basics/structure/recursion1.rb +42 -0
- data/samples/processing_app/basics/structure/recursion2.rb +39 -0
- data/samples/processing_app/basics/structure/redraw.rb +36 -0
- data/samples/processing_app/basics/structure/setup_draw.rb +30 -0
- data/samples/processing_app/basics/structure/statements_comments.rb +32 -0
- data/samples/processing_app/basics/structure/width_height.rb +29 -0
- data/samples/processing_app/basics/transform/arm.rb +47 -0
- data/samples/processing_app/basics/transform/rotate.rb +43 -0
- data/samples/processing_app/basics/transform/scale.rb +45 -0
- data/samples/processing_app/basics/transform/translate.rb +41 -0
- data/samples/processing_app/basics/transform/triangle_flower.rb +69 -0
- data/samples/processing_app/basics/typography/data/CourierNew36.vlw +0 -0
- data/samples/processing_app/basics/typography/data/Ziggurat-HTF-Black-32.vlw +0 -0
- data/samples/processing_app/basics/typography/letters.rb +52 -0
- data/samples/processing_app/basics/typography/words.rb +37 -0
- data/samples/processing_app/basics/web/embedded_links.rb +58 -0
- data/samples/processing_app/basics/web/loading_images.rb +25 -0
- metadata +181 -86
- data/lib/patches/JRubyApplet.diff +0 -24
- data/lib/patches/PATCHES.txt +0 -3
- data/lib/patches/PApplet.diff +0 -27
- data/library/minim/license.txt +0 -339
- data/library/minim/version.txt +0 -1
- data/library/opengl/library/gluegen-rt-natives-linux-amd64.jar +0 -0
- data/library/opengl/library/gluegen-rt-natives-linux-i586.jar +0 -0
- data/library/opengl/library/gluegen-rt-natives-macosx-ppc.jar +0 -0
- data/library/opengl/library/gluegen-rt-natives-macosx-universal.jar +0 -0
- data/library/opengl/library/gluegen-rt-natives-windows-amd64.jar +0 -0
- data/library/opengl/library/gluegen-rt-natives-windows-i586.jar +0 -0
- data/library/opengl/library/gluegen-rt.jar.pack.gz +0 -0
- data/library/opengl/library/jogl-natives-linux-amd64.jar +0 -0
- data/library/opengl/library/jogl-natives-linux-i586.jar +0 -0
- data/library/opengl/library/jogl-natives-macosx-ppc.jar +0 -0
- data/library/opengl/library/jogl-natives-macosx-universal.jar +0 -0
- data/library/opengl/library/jogl-natives-windows-amd64.jar +0 -0
- data/library/opengl/library/jogl-natives-windows-i586.jar +0 -0
- data/library/opengl/library/jogl.jar.pack.gz +0 -0
- data/library/pdf/notes.txt +0 -8
- data/library/serial/library/librxtxSerial.jnilib +0 -0
- data/library/serial/library/librxtxSerial.so +0 -0
- data/library/serial/library/rxtxSerial.dll +0 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# RGB Cube.
|
|
2
|
+
#
|
|
3
|
+
# The three primary colors of the additive color model are red, green, and blue.
|
|
4
|
+
# This RGB color cube displays smooth transitions between these colors.
|
|
5
|
+
|
|
6
|
+
class RgbCube < Processing::App
|
|
7
|
+
|
|
8
|
+
def setup
|
|
9
|
+
size 640, 360, P3D
|
|
10
|
+
|
|
11
|
+
no_stroke
|
|
12
|
+
color_mode RGB, 2
|
|
13
|
+
|
|
14
|
+
@xmag = 0
|
|
15
|
+
@ymag = 0
|
|
16
|
+
@new_xmag = 0
|
|
17
|
+
@new_ymag = 0
|
|
18
|
+
|
|
19
|
+
# since each point is used three times
|
|
20
|
+
@box_points = {
|
|
21
|
+
:top_front_left => [-1, 1, 1],
|
|
22
|
+
:top_front_right => [ 1, 1, 1],
|
|
23
|
+
:top_back_right => [ 1, 1, -1],
|
|
24
|
+
:top_back_left => [-1, 1, -1],
|
|
25
|
+
:bottom_front_left => [-1, -1, 1],
|
|
26
|
+
:bottom_front_right => [ 1, -1, 1],
|
|
27
|
+
:bottom_back_right => [ 1, -1, -1],
|
|
28
|
+
:bottom_back_left => [-1, -1, -1]
|
|
29
|
+
}
|
|
30
|
+
# a box from defined points
|
|
31
|
+
@box = {
|
|
32
|
+
:top => [@box_points[:top_front_left], @box_points[:top_front_right], @box_points[:top_back_right], @box_points[:top_back_left]],
|
|
33
|
+
:front => [@box_points[:top_front_left], @box_points[:top_front_right], @box_points[:bottom_front_right], @box_points[:bottom_front_left]],
|
|
34
|
+
:left => [@box_points[:top_front_left], @box_points[:bottom_front_left], @box_points[:bottom_back_left], @box_points[:top_back_left]],
|
|
35
|
+
:back => [@box_points[:top_back_left], @box_points[:top_back_right], @box_points[:bottom_back_right], @box_points[:bottom_back_left]],
|
|
36
|
+
:right => [@box_points[:top_back_right], @box_points[:bottom_back_right], @box_points[:bottom_front_right], @box_points[:top_front_right]],
|
|
37
|
+
:bottom => [@box_points[:bottom_front_left], @box_points[:bottom_front_right], @box_points[:bottom_back_right], @box_points[:bottom_back_left]]
|
|
38
|
+
}
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def draw
|
|
42
|
+
|
|
43
|
+
background 1
|
|
44
|
+
|
|
45
|
+
push_matrix
|
|
46
|
+
|
|
47
|
+
translate width/2, height/2, -30
|
|
48
|
+
|
|
49
|
+
@new_xmag = mouseX / width.to_f * TWO_PI
|
|
50
|
+
@new_ymag = mouseY / height.to_f * TWO_PI
|
|
51
|
+
|
|
52
|
+
diff = @xmag - @new_xmag
|
|
53
|
+
@xmag -= diff / 4 if diff.abs > 0.01
|
|
54
|
+
|
|
55
|
+
diff = @ymag - @new_ymag
|
|
56
|
+
@ymag -= diff / 4 if diff.abs > 0.01
|
|
57
|
+
|
|
58
|
+
rotate_x -@ymag
|
|
59
|
+
rotate_y -@xmag
|
|
60
|
+
|
|
61
|
+
scale 90
|
|
62
|
+
|
|
63
|
+
begin_shape QUADS
|
|
64
|
+
|
|
65
|
+
[:top, :front, :left, :back, :right, :bottom].each { |s|
|
|
66
|
+
@box[s].each { |p|
|
|
67
|
+
fill_from_points p
|
|
68
|
+
vertex_from_points p
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
end_shape
|
|
73
|
+
|
|
74
|
+
pop_matrix
|
|
75
|
+
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def fill_from_points ( points )
|
|
79
|
+
fill points[0] + 1, points[1] + 1, points[2] + 1 # "+1" translates -1,1 to 0,2
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def vertex_from_points ( points )
|
|
83
|
+
vertex points[0], points[1], points[2]
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
RgbCube.new :title => "Rgb Cube"
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Shape Transform
|
|
2
|
+
# by Ira Greenberg.
|
|
3
|
+
#
|
|
4
|
+
# Illustrates the geometric relationship
|
|
5
|
+
# between Cube, Pyramid, Cone and
|
|
6
|
+
# Cylinder 3D primitives.
|
|
7
|
+
#
|
|
8
|
+
# Instructions:
|
|
9
|
+
# Up Arrow - increases points
|
|
10
|
+
# Down Arrow - decreases points
|
|
11
|
+
# 'p' key toggles between cube/pyramid
|
|
12
|
+
|
|
13
|
+
class ShapeTransform < Processing::App
|
|
14
|
+
|
|
15
|
+
def setup
|
|
16
|
+
|
|
17
|
+
size 640, 360, P3D
|
|
18
|
+
|
|
19
|
+
no_stroke
|
|
20
|
+
|
|
21
|
+
@angle_inc = PI/300
|
|
22
|
+
|
|
23
|
+
@pts = 4
|
|
24
|
+
@angle = 0
|
|
25
|
+
@radius = 99
|
|
26
|
+
@cylinder_length = 95
|
|
27
|
+
|
|
28
|
+
@is_pyramid = false
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def draw
|
|
33
|
+
|
|
34
|
+
background 170, 95, 95
|
|
35
|
+
lights
|
|
36
|
+
fill 255, 200, 200
|
|
37
|
+
|
|
38
|
+
translate width/2, height/2
|
|
39
|
+
rotate_x frame_count * @angle_inc
|
|
40
|
+
rotate_y frame_count * @angle_inc
|
|
41
|
+
rotate_z frame_count * @angle_inc
|
|
42
|
+
|
|
43
|
+
vertices = []
|
|
44
|
+
|
|
45
|
+
(0...2).each { |i|
|
|
46
|
+
@angle = 0
|
|
47
|
+
vertices[i] = []
|
|
48
|
+
0.upto(@pts) { |j|
|
|
49
|
+
pvec = PVector.new 0, 0
|
|
50
|
+
(
|
|
51
|
+
pvec.x = cos(radians( @angle )) * @radius
|
|
52
|
+
pvec.y = sin(radians( @angle )) * @radius
|
|
53
|
+
|
|
54
|
+
) unless ( @is_pyramid && i == 1 )
|
|
55
|
+
|
|
56
|
+
pvec.z = @cylinder_length
|
|
57
|
+
vertices[i][j] = pvec
|
|
58
|
+
|
|
59
|
+
@angle += 360.0/@pts
|
|
60
|
+
}
|
|
61
|
+
@cylinder_length *= -1
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
begin_shape QUAD_STRIP
|
|
65
|
+
0.upto(@pts) { |j|
|
|
66
|
+
vertex vertices[0][j].x, vertices[0][j].y, vertices[0][j].z
|
|
67
|
+
vertex vertices[1][j].x, vertices[1][j].y, vertices[1][j].z
|
|
68
|
+
}
|
|
69
|
+
end_shape
|
|
70
|
+
|
|
71
|
+
[0,1].each { |i|
|
|
72
|
+
begin_shape
|
|
73
|
+
0.upto(@pts) { |j|
|
|
74
|
+
vertex vertices[i][j].x, vertices[i][j].y, vertices[i][j].z
|
|
75
|
+
}
|
|
76
|
+
end_shape CLOSE
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def key_pressed
|
|
82
|
+
|
|
83
|
+
if key == CODED
|
|
84
|
+
@pts += 1 if keyCode == UP && @pts < 90
|
|
85
|
+
@pts -= 1 if keyCode == DOWN && @pts > 4
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
@is_pyramid = !@is_pyramid if key.eql? "p"
|
|
89
|
+
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
ShapeTransform.new :title => "Shape Transform"
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Interactive Toroid
|
|
2
|
+
# by Ira Greenberg.
|
|
3
|
+
#
|
|
4
|
+
# Illustrates the geometric relationship between Toroid, Sphere, and Helix
|
|
5
|
+
# 3D primitives, as well as lathing principal.
|
|
6
|
+
#
|
|
7
|
+
# Instructions:
|
|
8
|
+
# UP arrow key ____ pts++
|
|
9
|
+
# DOWN arrow key __ pts--
|
|
10
|
+
# LEFT arrow key __ segments--
|
|
11
|
+
# RIGHT arrow key _ segments++
|
|
12
|
+
# 'a' key _________ toroid radius--
|
|
13
|
+
# 's' key _________ toroid radius++
|
|
14
|
+
# 'z' key _________ initial polygon radius--
|
|
15
|
+
# 'x' key _________ initial polygon radius++
|
|
16
|
+
# 'w' key _________ toggle wireframe/solid shading
|
|
17
|
+
# 'h' key _________ toggle sphere/helix
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class Toroid < Processing::App
|
|
21
|
+
|
|
22
|
+
def setup
|
|
23
|
+
|
|
24
|
+
size 640, 360, P3D
|
|
25
|
+
|
|
26
|
+
@pts = 40
|
|
27
|
+
@angle = 0.0
|
|
28
|
+
@radius = 60.0
|
|
29
|
+
@segments = 60.0
|
|
30
|
+
@lathe_angle = 0.0
|
|
31
|
+
@lathe_radius = 100.0
|
|
32
|
+
@is_wireframe = false
|
|
33
|
+
@is_helix = false
|
|
34
|
+
@helix_offset = 5.0
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def draw
|
|
39
|
+
|
|
40
|
+
background 50, 64, 42
|
|
41
|
+
|
|
42
|
+
lights
|
|
43
|
+
|
|
44
|
+
if @is_wireframe
|
|
45
|
+
stroke 255, 255, 150
|
|
46
|
+
no_fill
|
|
47
|
+
else
|
|
48
|
+
no_stroke
|
|
49
|
+
fill 150, 195, 125
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
translate width/2, height/2, -100
|
|
53
|
+
|
|
54
|
+
rotate_x frame_count * PI / 150
|
|
55
|
+
rotate_y frame_count * PI / 170
|
|
56
|
+
rotate_z frame_count * PI / 90
|
|
57
|
+
|
|
58
|
+
vertices = []
|
|
59
|
+
vertices2 = []
|
|
60
|
+
|
|
61
|
+
0.upto(@pts) { |i|
|
|
62
|
+
|
|
63
|
+
vertices2[i] = PVector.new
|
|
64
|
+
vertices[i] = PVector.new
|
|
65
|
+
|
|
66
|
+
vertices[i].x = @lathe_radius + sin( radians( @angle ) ) * @radius
|
|
67
|
+
|
|
68
|
+
if @is_helix
|
|
69
|
+
vertices[i].z = cos( radians( @angle ) ) * @radius - (@helix_offset * @segments) / 2
|
|
70
|
+
else
|
|
71
|
+
vertices[i].z = cos( radians( @angle ) ) * @radius
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
@angle += 360.0 / @pts
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@lathe_angle = 0
|
|
78
|
+
|
|
79
|
+
0.upto(@segments) { |i|
|
|
80
|
+
begin_shape QUAD_STRIP
|
|
81
|
+
(0..@pts).each { |j|
|
|
82
|
+
vertex_for_pvector vertices2[j] if i > 0
|
|
83
|
+
|
|
84
|
+
vertices2[j].x = cos( radians( @lathe_angle ) ) * vertices[j].x
|
|
85
|
+
vertices2[j].y = sin( radians( @lathe_angle )
|
|
86
|
+
) * vertices[j].x
|
|
87
|
+
vertices2[j].z = vertices[j].z
|
|
88
|
+
|
|
89
|
+
vertices[j].z += @helix_offset if @is_helix
|
|
90
|
+
|
|
91
|
+
vertex_for_pvector vertices2[j]
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@lathe_angle += (@is_helix ? 720 : 360) / @segments
|
|
95
|
+
end_shape
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def vertex_for_pvector ( pvec )
|
|
101
|
+
vertex( pvec.x, pvec.y, pvec.z )
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def key_pressed
|
|
105
|
+
|
|
106
|
+
if key == CODED
|
|
107
|
+
|
|
108
|
+
@pts += 1 if keyCode == UP && @pts < 40
|
|
109
|
+
@pts -= 1 if keyCode == DOWN && @pts > 3
|
|
110
|
+
|
|
111
|
+
@segments += 1 if keyCode == RIGHT && @segments < 80
|
|
112
|
+
@segments -= 1 if keyCode == LEFT && @segments > 3
|
|
113
|
+
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
@lathe_radius += 1 if key.eql? "s"
|
|
117
|
+
@lathe_radius -= 1 if key.eql? "a" #&& @lathe_radius > 0
|
|
118
|
+
|
|
119
|
+
@radius += 1 if key.eql? "x"
|
|
120
|
+
@radius -= 1 if key.eql? "z" && @radius > 10
|
|
121
|
+
|
|
122
|
+
@is_wireframe = !@is_wireframe if key.eql? "w"
|
|
123
|
+
|
|
124
|
+
@is_helix = !@is_helix if key.eql? "h"
|
|
125
|
+
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
Toroid.new :title => "Toroid"
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Vertices
|
|
2
|
+
# by Simon Greenwold.
|
|
3
|
+
#
|
|
4
|
+
# Draw a cylinder centered on the y-axis, going down
|
|
5
|
+
# from y=0 to y=height. The radius at the top can be
|
|
6
|
+
# different from the radius at the bottom, and the
|
|
7
|
+
# number of sides drawn is variable.
|
|
8
|
+
|
|
9
|
+
class Vertices < Processing::App
|
|
10
|
+
|
|
11
|
+
def setup
|
|
12
|
+
|
|
13
|
+
size 640, 360, P3D
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def draw
|
|
18
|
+
|
|
19
|
+
background 0
|
|
20
|
+
lights
|
|
21
|
+
|
|
22
|
+
translate width/2, height/2
|
|
23
|
+
|
|
24
|
+
rotate_y map( mouse_x, 0, width, 0, PI )
|
|
25
|
+
rotate_z map( mouse_y, 0, height, 0, -PI )
|
|
26
|
+
|
|
27
|
+
no_stroke
|
|
28
|
+
fill 255, 255, 255
|
|
29
|
+
|
|
30
|
+
translate 0, -40
|
|
31
|
+
|
|
32
|
+
draw_cylinder 10, 180, 200, 16 # Draw a mix between a cylinder and a cone
|
|
33
|
+
#draw_cylinder 70, 70, 120, 64 # Draw a cylinder
|
|
34
|
+
#draw_cylinder 0, 180, 200, 4 # Draw a pyramid
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def draw_cylinder ( top_radius, bottom_radius, tall, sides )
|
|
39
|
+
|
|
40
|
+
angle = 0
|
|
41
|
+
angle_inc = TWO_PI / sides
|
|
42
|
+
|
|
43
|
+
begin_shape QUAD_STRIP
|
|
44
|
+
0.upto(sides+1) { |i|
|
|
45
|
+
vertex top_radius * cos(angle), 0, top_radius * sin(angle)
|
|
46
|
+
vertex bottom_radius * cos(angle), tall, bottom_radius * sin(angle)
|
|
47
|
+
angle += angle_inc
|
|
48
|
+
}
|
|
49
|
+
end_shape
|
|
50
|
+
|
|
51
|
+
unless top_radius == 0
|
|
52
|
+
angle = 0
|
|
53
|
+
|
|
54
|
+
begin_shape TRIANGLE_FAN
|
|
55
|
+
vertex 0, 0, 0
|
|
56
|
+
0.upto(sides+1){ |i|
|
|
57
|
+
vertex top_radius * cos(angle), 0, top_radius * sin(angle)
|
|
58
|
+
angle += angle_inc
|
|
59
|
+
}
|
|
60
|
+
end_shape
|
|
61
|
+
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
unless bottom_radius == 0
|
|
65
|
+
angle = 0
|
|
66
|
+
|
|
67
|
+
begin_shape TRIANGLE_FAN
|
|
68
|
+
vertex 0, 0, 0
|
|
69
|
+
0.upto(sides+1) { |i|
|
|
70
|
+
vertex bottom_radius * cos(angle), tall, bottom_radius * sin(angle)
|
|
71
|
+
angle += angle_inc
|
|
72
|
+
}
|
|
73
|
+
end_shape
|
|
74
|
+
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
Vertices.new :title => "Vertices"
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Explode
|
|
2
|
+
# by Daniel Shiffman.
|
|
3
|
+
#
|
|
4
|
+
# Mouse horizontal location controls breaking apart of image and
|
|
5
|
+
# Maps pixels from a 2D image into 3D space. Pixel brightness controls
|
|
6
|
+
# translation along z axis.
|
|
7
|
+
|
|
8
|
+
class Explode < Processing::App
|
|
9
|
+
|
|
10
|
+
def setup
|
|
11
|
+
|
|
12
|
+
size 640, 360, P3D
|
|
13
|
+
|
|
14
|
+
@cell_size = 2
|
|
15
|
+
@img = load_image "eames.jpg"
|
|
16
|
+
@columns = @img.width / @cell_size
|
|
17
|
+
@rows = @img.height / @cell_size
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def draw
|
|
22
|
+
|
|
23
|
+
background 0
|
|
24
|
+
|
|
25
|
+
(0...@columns).each { |i|
|
|
26
|
+
|
|
27
|
+
(0...@rows).each { |j|
|
|
28
|
+
|
|
29
|
+
x = i * @cell_size + @cell_size / 2
|
|
30
|
+
y = j * @cell_size + @cell_size / 2
|
|
31
|
+
|
|
32
|
+
loc = x + y * @img.width
|
|
33
|
+
|
|
34
|
+
c = @img.pixels[loc]
|
|
35
|
+
|
|
36
|
+
z = (mouse_x / width.to_f) * brightness( @img.pixels[loc] ) - 20
|
|
37
|
+
|
|
38
|
+
push_matrix
|
|
39
|
+
|
|
40
|
+
translate x + 200, y + 100, z
|
|
41
|
+
|
|
42
|
+
fill c, 204
|
|
43
|
+
no_stroke
|
|
44
|
+
rect_mode CENTER
|
|
45
|
+
|
|
46
|
+
rect 0, 0, @cell_size, @cell_size
|
|
47
|
+
|
|
48
|
+
pop_matrix
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
Explode.new :title => "Explode"
|