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
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -39,9 +39,9 @@ end
|
|
|
39
39
|
###########################
|
|
40
40
|
class Hilbert
|
|
41
41
|
include Processing::Proxy
|
|
42
|
-
|
|
42
|
+
ADJUSTMENT = [0, 0.5, 1.5, 3.5, 7.5, 15]
|
|
43
43
|
attr_reader :grammar, :axiom, :production, :premis, :rule,
|
|
44
|
-
:theta, :
|
|
44
|
+
:theta, :distance, :phi, :gen
|
|
45
45
|
|
|
46
46
|
def initialize(len)
|
|
47
47
|
@axiom = "X"
|
|
@@ -49,16 +49,14 @@ class Hilbert
|
|
|
49
49
|
@production = axiom
|
|
50
50
|
@premis = "X"
|
|
51
51
|
@rule = "^<XF^<XFX-F^>>XFX&F+>>XFX-F>X->"
|
|
52
|
-
@
|
|
53
|
-
@distance = len/12 # distance value relative to screen height
|
|
52
|
+
@distance = len
|
|
54
53
|
@theta = Math::PI/180 * 90
|
|
55
|
-
@phi = Math::PI/180 * 90
|
|
54
|
+
@phi = Math::PI/180 * 90
|
|
56
55
|
grammar.add_rule(premis, rule)
|
|
57
|
-
no_stroke()
|
|
58
56
|
end
|
|
59
57
|
|
|
60
|
-
def render()
|
|
61
|
-
translate(
|
|
58
|
+
def render()
|
|
59
|
+
translate( -distance * ADJUSTMENT[gen], distance * ADJUSTMENT[gen], -distance * ADJUSTMENT[gen])
|
|
62
60
|
fill(0, 75, 152)
|
|
63
61
|
light_specular(204, 204, 204)
|
|
64
62
|
specular(255, 255, 255)
|
|
@@ -93,7 +91,10 @@ class Hilbert
|
|
|
93
91
|
##############################
|
|
94
92
|
|
|
95
93
|
def create_grammar(gen)
|
|
96
|
-
@
|
|
94
|
+
@gen = gen # required for depth adjustment
|
|
95
|
+
@distance *= 1/(pow(2, gen) - 1)
|
|
97
96
|
@production = @grammar.generate gen
|
|
98
97
|
end
|
|
99
|
-
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Move Eye.
|
|
2
|
+
# by Simon Greenwold.
|
|
3
|
+
#
|
|
4
|
+
# The camera lifts up (controlled by mouseY) while looking at the same point.
|
|
5
|
+
|
|
6
|
+
class MoveEye < Processing::App
|
|
7
|
+
|
|
8
|
+
def setup
|
|
9
|
+
size 640, 360, P3D
|
|
10
|
+
fill 204
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def draw
|
|
14
|
+
lights
|
|
15
|
+
background 0
|
|
16
|
+
|
|
17
|
+
camera 30, mouseY, 220, 0, 0, 0, 0, 1, 0
|
|
18
|
+
|
|
19
|
+
noStroke
|
|
20
|
+
box 90
|
|
21
|
+
stroke 255
|
|
22
|
+
line( -100, 0, 0, 100, 0, 0)
|
|
23
|
+
line( 0, -100, 0, 0, 100, 0)
|
|
24
|
+
line( 0, 0, -100, 0, 0, 100)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
MoveEye.new :title => "Move Eye"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# 3D castle tower constructed out of individual bricks.
|
|
4
4
|
# Uses the PVecor and Cube classes.
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
def setup
|
|
7
7
|
@bricks_per_layer = 16
|
|
8
8
|
@brick_layers = 18
|
|
@@ -27,7 +27,7 @@ end
|
|
|
27
27
|
|
|
28
28
|
def draw_layer(layer_num)
|
|
29
29
|
@layer_num = layer_num
|
|
30
|
-
@temp_y -= @brick_height # increment rows
|
|
30
|
+
@temp_y -= @brick_height # increment rows
|
|
31
31
|
@angle = 360.0 / @bricks_per_layer * @layer_num / 2.0 # alternate brick seams
|
|
32
32
|
@bricks_per_layer.times {|i| draw_bricks(i) }
|
|
33
33
|
end
|
|
@@ -59,14 +59,14 @@ class Cubeish
|
|
|
59
59
|
:back => ['---', ' --', ' -', '- -'],
|
|
60
60
|
:top => ['-- ', '---', ' --', ' - '],
|
|
61
61
|
:bottom => ['- ', '- -', ' -', ' ']}
|
|
62
|
-
|
|
63
|
-
SIGNS = {'-' => -1,
|
|
62
|
+
|
|
63
|
+
SIGNS = {'-' => -1,
|
|
64
64
|
' ' => 1}
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
def initialize(width, height, depth)
|
|
67
67
|
@vertices = {}
|
|
68
68
|
@w, @h, @d = width, height, depth
|
|
69
|
-
|
|
69
|
+
|
|
70
70
|
SIDES.each do |side, signs|
|
|
71
71
|
@vertices[side] = signs.map do |s|
|
|
72
72
|
s = s.split('').map {|el| SIGNS[el] }
|
|
@@ -74,13 +74,13 @@ class Cubeish
|
|
|
74
74
|
end
|
|
75
75
|
end
|
|
76
76
|
end
|
|
77
|
-
|
|
77
|
+
|
|
78
78
|
def create
|
|
79
79
|
@vertices.each do |name, vectors|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
begin_shape App::QUADS
|
|
81
|
+
vectors.each {|v| vertex(v.x, v.y, v.z) }
|
|
82
|
+
end_shape
|
|
83
83
|
end
|
|
84
84
|
end
|
|
85
|
-
|
|
85
|
+
|
|
86
86
|
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Cubic Grid
|
|
2
|
+
# by Ira Greenberg.
|
|
3
|
+
#
|
|
4
|
+
# 3D translucent colored grid uses nested pushMatrix()
|
|
5
|
+
# and popMatrix() functions.
|
|
6
|
+
|
|
7
|
+
class CubicGrid < Processing::App
|
|
8
|
+
|
|
9
|
+
def setup
|
|
10
|
+
size 640, 360, P3D
|
|
11
|
+
no_stroke
|
|
12
|
+
|
|
13
|
+
@box_size = 40
|
|
14
|
+
@margin = @box_size * 2
|
|
15
|
+
@depth = 400
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def draw
|
|
19
|
+
background 255
|
|
20
|
+
|
|
21
|
+
translate width/2, height/2, -@depth
|
|
22
|
+
rotate_x frame_count * 0.01
|
|
23
|
+
rotate_y frame_count * 0.01
|
|
24
|
+
|
|
25
|
+
((-@depth/2 + @margin)..(@depth/2 - @margin)).step( @box_size ) { |i|
|
|
26
|
+
push_matrix
|
|
27
|
+
|
|
28
|
+
((-height + @margin)..(height - @margin)).step( @box_size ) { |j|
|
|
29
|
+
push_matrix
|
|
30
|
+
|
|
31
|
+
((-width + @margin)..(width - @margin)).step( @box_size ) { |k|
|
|
32
|
+
box_fill = color i.abs, j.abs, k.abs, 50
|
|
33
|
+
push_matrix
|
|
34
|
+
|
|
35
|
+
translate k, j, i
|
|
36
|
+
fill box_fill
|
|
37
|
+
box @box_size
|
|
38
|
+
|
|
39
|
+
pop_matrix
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
pop_matrix
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
pop_matrix
|
|
46
|
+
}
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
CubicGrid.new :title => "Cubic Grid"
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# I Like Icosahedra
|
|
2
|
+
# by Ira Greenberg.
|
|
3
|
+
#
|
|
4
|
+
# This example plots icosahedra. The Icosahdron is a regular
|
|
5
|
+
# polyhedron composed of twenty equalateral triangles.
|
|
6
|
+
|
|
7
|
+
# fjenett, 2010-03-11:
|
|
8
|
+
# This is by far not an exact translation of Iras code. I removed
|
|
9
|
+
# the unneeded Dimension3D class, simplyfied Shape3D and improved
|
|
10
|
+
# the Icosahedron class. That and the rubyfication ...
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Icosahedra < Processing::App
|
|
14
|
+
|
|
15
|
+
def setup
|
|
16
|
+
|
|
17
|
+
size 640, 360, P3D
|
|
18
|
+
|
|
19
|
+
@ico1 = Icosahedron.new 75
|
|
20
|
+
@ico2 = Icosahedron.new 75
|
|
21
|
+
@ico3 = Icosahedron.new 75
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def draw
|
|
26
|
+
|
|
27
|
+
background 0
|
|
28
|
+
lights
|
|
29
|
+
|
|
30
|
+
translate width/2, height/2
|
|
31
|
+
|
|
32
|
+
push_matrix
|
|
33
|
+
|
|
34
|
+
translate -width/3.5, 0
|
|
35
|
+
rotate_x frame_count * PI / 185
|
|
36
|
+
rotate_y frame_count * PI / -200
|
|
37
|
+
|
|
38
|
+
stroke 170, 0, 0
|
|
39
|
+
no_fill
|
|
40
|
+
|
|
41
|
+
@ico1.draw
|
|
42
|
+
|
|
43
|
+
pop_matrix
|
|
44
|
+
|
|
45
|
+
push_matrix
|
|
46
|
+
|
|
47
|
+
rotate_x frame_count * PI / 200
|
|
48
|
+
rotate_y frame_count * PI / 300
|
|
49
|
+
|
|
50
|
+
stroke 170, 0, 180
|
|
51
|
+
fill 170, 170, 0
|
|
52
|
+
|
|
53
|
+
@ico2.draw
|
|
54
|
+
|
|
55
|
+
pop_matrix
|
|
56
|
+
|
|
57
|
+
push_matrix
|
|
58
|
+
|
|
59
|
+
translate width/3.5, 0
|
|
60
|
+
rotate_x frame_count * PI / -200
|
|
61
|
+
rotate_y frame_count * PI / 200
|
|
62
|
+
|
|
63
|
+
no_stroke
|
|
64
|
+
fill 0, 0, 185
|
|
65
|
+
|
|
66
|
+
@ico3.draw
|
|
67
|
+
|
|
68
|
+
pop_matrix
|
|
69
|
+
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
require 'icosahedron' # load icosahedron.rb
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
Icosahedra.new :title => "Icosahedra"
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
|
|
2
|
+
# fjenett, 2010-03-11:
|
|
3
|
+
# Mixing in Processing::Proxy makes classes behave like inner classes(*) of
|
|
4
|
+
# a Processing sketch (any class that's defined in a sketch and that is
|
|
5
|
+
# inside a .pde file). This is needed for a class to be able to call any
|
|
6
|
+
# drawing commands etc.
|
|
7
|
+
# (*) Ruby does not know inner classes btw. ...
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
require 'shape_3D' # load shape_3D.rb
|
|
11
|
+
|
|
12
|
+
class Icosahedron < Shape3D # extends Shape3D
|
|
13
|
+
|
|
14
|
+
include Processing::Proxy # mixin Processing::Proxy
|
|
15
|
+
|
|
16
|
+
attr_accessor :top_point, :top_pent
|
|
17
|
+
attr_accessor :bottom_point, :bottom_pent
|
|
18
|
+
attr_accessor :angle, :radius
|
|
19
|
+
attr_accessor :tri_dist, :tri_ht
|
|
20
|
+
attr_accessor :a, :b, :c
|
|
21
|
+
|
|
22
|
+
def initialize ( *args )
|
|
23
|
+
|
|
24
|
+
super args # call Shape3D.new( args )
|
|
25
|
+
|
|
26
|
+
@radius = args.first
|
|
27
|
+
@top_pent = Array.new 5
|
|
28
|
+
@bottom_pent = Array.new 5
|
|
29
|
+
@angle = 0.0
|
|
30
|
+
|
|
31
|
+
init
|
|
32
|
+
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def init
|
|
36
|
+
|
|
37
|
+
@c = dist( cos(0) * @radius,
|
|
38
|
+
sin(0) * @radius,
|
|
39
|
+
cos(radians( 72 )) * @radius,
|
|
40
|
+
sin(radians( 72 )) * @radius )
|
|
41
|
+
|
|
42
|
+
@b = @radius
|
|
43
|
+
|
|
44
|
+
@a = sqrt(@c*@c - @b*@b)
|
|
45
|
+
|
|
46
|
+
@tri_ht = sqrt( @c*@c - (@c/2) * (@c/2) )
|
|
47
|
+
|
|
48
|
+
@top_pent.each_with_index { |v, i|
|
|
49
|
+
|
|
50
|
+
@top_pent[i] = PVector.new( cos(@angle) * @radius,
|
|
51
|
+
sin(@angle) * @radius,
|
|
52
|
+
@tri_ht / 2 )
|
|
53
|
+
|
|
54
|
+
@angle += radians 72
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@top_point = PVector.new 0, 0, @tri_ht / 2 + @a
|
|
58
|
+
|
|
59
|
+
@angle = 72.0/2
|
|
60
|
+
|
|
61
|
+
@bottom_pent.each_with_index { |v, i|
|
|
62
|
+
|
|
63
|
+
@bottom_pent[i] = PVector.new( cos(@angle) * @radius,
|
|
64
|
+
sin(@angle) * @radius,
|
|
65
|
+
-@tri_ht / 2 )
|
|
66
|
+
@angle += radians 72
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@bottom_point = PVector.new 0, 0, -(@tri_ht / 2 + @a)
|
|
70
|
+
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def draw
|
|
74
|
+
|
|
75
|
+
[@top_pent, @bottom_pent].each { |pent| # top and bottom pentagram
|
|
76
|
+
|
|
77
|
+
(0...pent.length).each { |i|
|
|
78
|
+
|
|
79
|
+
begin_shape
|
|
80
|
+
|
|
81
|
+
# next or first
|
|
82
|
+
n = i+1
|
|
83
|
+
n = n % @top_pent.length # wrap around
|
|
84
|
+
|
|
85
|
+
# choose point depending on pentagram
|
|
86
|
+
pnt = @top_point
|
|
87
|
+
pnt = @bottom_point if pent == @bottom_pent
|
|
88
|
+
|
|
89
|
+
# draw triangle
|
|
90
|
+
vertex @x + pent[i].x, @y + pent[i].y, @z + pent[i].z
|
|
91
|
+
vertex @x + pnt.x, @y + pnt.y, @z + pnt.z
|
|
92
|
+
vertex @x + pent[n].x, @y + pent[n].y, @z + pent[n].z
|
|
93
|
+
|
|
94
|
+
end_shape CLOSE
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
begin_shape TRIANGLE_STRIP
|
|
99
|
+
|
|
100
|
+
0.upto(6) { |i| # stitch pentagrams together with triangles
|
|
101
|
+
|
|
102
|
+
j = i
|
|
103
|
+
j = j % @top_pent.length
|
|
104
|
+
|
|
105
|
+
n = i+2
|
|
106
|
+
n = n % @bottom_pent.length
|
|
107
|
+
|
|
108
|
+
vertex @x + @top_pent[j].x, @y + @top_pent[j].y, @z + @top_pent[j].z
|
|
109
|
+
vertex @x + @bottom_pent[n].x, @y + @bottom_pent[n].y, @z + @bottom_pent[n].z
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
end_shape
|
|
113
|
+
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
# fjenett, 2010-03-11:
|
|
3
|
+
# Left this in although it's not needed as an example for
|
|
4
|
+
# how to extend classes.
|
|
5
|
+
|
|
6
|
+
class Shape3D
|
|
7
|
+
|
|
8
|
+
attr_accessor :x, :y, :z
|
|
9
|
+
attr_accessor :w, :h, :d
|
|
10
|
+
|
|
11
|
+
def initialize (*args)
|
|
12
|
+
@x, @y, @z = 0.0, 0.0, 0.0
|
|
13
|
+
@w, @h, @d = 0.0, 0.0, 0.0
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def rotate_x ( theta )
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def rotate_y ( theta )
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def rotate_z ( theta )
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Primitives 3D.
|
|
2
|
+
#
|
|
3
|
+
# Placing mathematically 3D objects in synthetic space.
|
|
4
|
+
# The lights() method reveals their imagined dimension.
|
|
5
|
+
# The box() and sphere() functions each have one parameter
|
|
6
|
+
# which is used to specify their size. These shapes are
|
|
7
|
+
# positioned using the translate() function.
|
|
8
|
+
|
|
9
|
+
class Primitives < Processing::App
|
|
10
|
+
|
|
11
|
+
def setup
|
|
12
|
+
|
|
13
|
+
size 640, 360, P3D
|
|
14
|
+
|
|
15
|
+
background 0
|
|
16
|
+
lights
|
|
17
|
+
|
|
18
|
+
no_stroke
|
|
19
|
+
push_matrix
|
|
20
|
+
|
|
21
|
+
translate 130, height/2, 0
|
|
22
|
+
rotate_y 1.25
|
|
23
|
+
rotate_x -0.4
|
|
24
|
+
|
|
25
|
+
box 100
|
|
26
|
+
|
|
27
|
+
pop_matrix
|
|
28
|
+
|
|
29
|
+
no_fill
|
|
30
|
+
stroke 255
|
|
31
|
+
push_matrix
|
|
32
|
+
|
|
33
|
+
translate 500, height*0.35, -200
|
|
34
|
+
sphere 280
|
|
35
|
+
|
|
36
|
+
pop_matrix
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
Primitives.new :title => "Primitives"
|