ruby-processing 1.0.9 → 1.0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- 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,36 @@
|
|
1
|
+
# Redraw.
|
2
|
+
#
|
3
|
+
# The redraw() function makes draw() execute once.
|
4
|
+
# In this example, draw() is executed once every time
|
5
|
+
# the mouse is clicked.
|
6
|
+
|
7
|
+
class Redraw < Processing::App
|
8
|
+
|
9
|
+
def setup
|
10
|
+
|
11
|
+
size 200, 200
|
12
|
+
|
13
|
+
@y = 100
|
14
|
+
|
15
|
+
stroke 255
|
16
|
+
no_loop
|
17
|
+
end
|
18
|
+
|
19
|
+
def draw
|
20
|
+
|
21
|
+
background 0
|
22
|
+
|
23
|
+
@y = @y - 1
|
24
|
+
@y = height if @y < 0
|
25
|
+
|
26
|
+
line 0, @y, width, @y
|
27
|
+
end
|
28
|
+
|
29
|
+
def mouse_pressed
|
30
|
+
|
31
|
+
redraw
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
Redraw.new :title => "Redraw"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# Setup and Draw.
|
2
|
+
#
|
3
|
+
# The draw() function creates a structure in which
|
4
|
+
# to write programs that change with time.
|
5
|
+
|
6
|
+
class SetupDraw < Processing::App
|
7
|
+
|
8
|
+
def setup
|
9
|
+
|
10
|
+
size 200, 200
|
11
|
+
|
12
|
+
@y = 100
|
13
|
+
|
14
|
+
stroke 255
|
15
|
+
frame_rate 30
|
16
|
+
end
|
17
|
+
|
18
|
+
def draw
|
19
|
+
|
20
|
+
background 0
|
21
|
+
|
22
|
+
@y = @y - 1
|
23
|
+
@y = height if @y < 0
|
24
|
+
|
25
|
+
line 0, @y, width, @y
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
SetupDraw.new :title => "Setup Draw"
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Statements and Comments.
|
2
|
+
#
|
3
|
+
# Statements are the elements that make up programs.
|
4
|
+
# In Ruby you can end statements with a semi-colon ";" but you don't have to.
|
5
|
+
#
|
6
|
+
# Comments are used for making notes to help people better understand programs.
|
7
|
+
# A comment begins with a "#" in Ruby.
|
8
|
+
|
9
|
+
class StatementsComments < Processing::App
|
10
|
+
|
11
|
+
def setup
|
12
|
+
|
13
|
+
# The size function is a statement that tells the computer
|
14
|
+
# how large to make the window.
|
15
|
+
# Each function statement has zero or more parameters.
|
16
|
+
# Parameters are data passed into the function
|
17
|
+
# and used as values for specifying what the computer will do.
|
18
|
+
size 200, 200
|
19
|
+
|
20
|
+
# The background function is a statement that tells the computer
|
21
|
+
# which color to make the background of the window
|
22
|
+
background 102
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
def draw
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
StatementsComments.new :title => "Statements Comments"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Width and Height.
|
2
|
+
#
|
3
|
+
# The 'width' and 'height' variables contain the width and height
|
4
|
+
# of the display window as defined in the size() function.
|
5
|
+
|
6
|
+
class WidthHeight < Processing::App
|
7
|
+
|
8
|
+
def setup
|
9
|
+
|
10
|
+
size 200, 200
|
11
|
+
|
12
|
+
background 127
|
13
|
+
no_stroke
|
14
|
+
|
15
|
+
(0...height).step( 20 ) do |i|
|
16
|
+
fill 0
|
17
|
+
rect 0, i, width, 10
|
18
|
+
fill 255
|
19
|
+
rect i, 0, 10, height
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def draw
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
WidthHeight.new :title => "Width Height"
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# Arm.
|
2
|
+
#
|
3
|
+
# The angle of each segment is controlled with the mouseX and
|
4
|
+
# mouseY position. The transformations applied to the first segment
|
5
|
+
# are also applied to the second segment because they are inside
|
6
|
+
# the same push_matrix and pop_matrix group.
|
7
|
+
|
8
|
+
class Arm < Processing::App
|
9
|
+
|
10
|
+
def setup
|
11
|
+
|
12
|
+
size 200, 200
|
13
|
+
|
14
|
+
@x, @y = 50, 100
|
15
|
+
@angle1, @angle2 = 0.0, 0.0
|
16
|
+
@seg_length = 50
|
17
|
+
|
18
|
+
smooth
|
19
|
+
stroke_weight 20
|
20
|
+
stroke 0, 100
|
21
|
+
end
|
22
|
+
|
23
|
+
def draw
|
24
|
+
|
25
|
+
background 226
|
26
|
+
|
27
|
+
@angle1 = (mouse_x / width.to_f - 0.5) * -PI
|
28
|
+
@angle2 = (mouse_y / height.to_f - 0.5) * PI
|
29
|
+
|
30
|
+
push_matrix
|
31
|
+
|
32
|
+
segment @x, @y, @angle1
|
33
|
+
segment @seg_length, 0, @angle2
|
34
|
+
pop_matrix
|
35
|
+
end
|
36
|
+
|
37
|
+
def segment ( x, y, a )
|
38
|
+
|
39
|
+
translate x, y
|
40
|
+
rotate a
|
41
|
+
|
42
|
+
line 0, 0, @seg_length, 0
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
Arm.new :title => "Arm"
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Rotate.
|
2
|
+
#
|
3
|
+
# Rotating a square around the Z axis. To get the results
|
4
|
+
# you expect, send the rotate function angle parameters that are
|
5
|
+
# values between 0 and PI*2 (TWO_PI which is roughly 6.28). If you prefer to
|
6
|
+
# think about angles as degrees (0-360), you can use the radians()
|
7
|
+
# method to convert your values. For example: scale(radians(90))
|
8
|
+
# is identical to the statement scale(PI/2).
|
9
|
+
|
10
|
+
class Rotate < Processing::App
|
11
|
+
|
12
|
+
def setup
|
13
|
+
|
14
|
+
size 200, 200
|
15
|
+
|
16
|
+
no_stroke
|
17
|
+
fill 255
|
18
|
+
frame_rate 30
|
19
|
+
rect_mode CENTER
|
20
|
+
|
21
|
+
@angle = 0.0
|
22
|
+
@cosine = 0.0
|
23
|
+
@jitter = 0.0
|
24
|
+
end
|
25
|
+
|
26
|
+
def draw
|
27
|
+
|
28
|
+
background 102
|
29
|
+
|
30
|
+
@jitter = random -0.1, 0.1 if second % 2 == 0
|
31
|
+
|
32
|
+
@angle += @jitter
|
33
|
+
@cosine = cos( @angle )
|
34
|
+
|
35
|
+
translate width/2, height/2
|
36
|
+
rotate @cosine
|
37
|
+
|
38
|
+
rect 0, 0, 115, 115
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
Rotate.new :title => "Rotate"
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# Scale
|
2
|
+
# by Denis Grutze.
|
3
|
+
#
|
4
|
+
# Paramenters for the scale() function are values specified
|
5
|
+
# as decimal percentages. For example, the method call scale(2.0)
|
6
|
+
# will increase the dimension of the shape by 200 percent.
|
7
|
+
# Objects always scale from the origin.
|
8
|
+
|
9
|
+
class Scale < Processing::App
|
10
|
+
|
11
|
+
def setup
|
12
|
+
|
13
|
+
size 200, 200
|
14
|
+
|
15
|
+
no_stroke
|
16
|
+
rect_mode CENTER
|
17
|
+
|
18
|
+
frame_rate 30
|
19
|
+
|
20
|
+
@a, @s = 0.0, 0.0
|
21
|
+
end
|
22
|
+
|
23
|
+
def draw
|
24
|
+
|
25
|
+
background 102
|
26
|
+
|
27
|
+
@a += 0.04
|
28
|
+
@s = cos( @a ) * 2
|
29
|
+
|
30
|
+
translate width/2, height/2
|
31
|
+
scale @s
|
32
|
+
|
33
|
+
fill 51
|
34
|
+
rect 0, 0, 50, 50
|
35
|
+
|
36
|
+
translate 75, 0
|
37
|
+
|
38
|
+
fill 255
|
39
|
+
scale @s
|
40
|
+
rect 0, 0, 50, 50
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
Scale.new :title => "Scale"
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# Translate.
|
2
|
+
#
|
3
|
+
# The translate() function allows objects to be moved
|
4
|
+
# to any location within the window. The first parameter
|
5
|
+
# sets the x-axis offset and the second parameter sets the
|
6
|
+
# y-axis offset.
|
7
|
+
|
8
|
+
class Translate < Processing::App
|
9
|
+
|
10
|
+
def setup
|
11
|
+
|
12
|
+
size 200, 200
|
13
|
+
no_stroke
|
14
|
+
frame_rate 30
|
15
|
+
|
16
|
+
@x, @y = 0.0, 0.0
|
17
|
+
@size = 40.0
|
18
|
+
end
|
19
|
+
|
20
|
+
def draw
|
21
|
+
|
22
|
+
background 102
|
23
|
+
|
24
|
+
@x += 0.8
|
25
|
+
|
26
|
+
@x = -@size if @x > width + @size
|
27
|
+
|
28
|
+
translate @x, height/2 - @size/2
|
29
|
+
|
30
|
+
fill 255
|
31
|
+
rect -@size/2, -@size/2, @size, @size
|
32
|
+
|
33
|
+
translate @x, @size
|
34
|
+
|
35
|
+
fill 0
|
36
|
+
rect -@size/2, -@size/2, @size, @size
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
Translate.new :title => "Translate"
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# Triangle Flower
|
2
|
+
# by Ira Greenberg.
|
3
|
+
#
|
4
|
+
# Using rotate() and triangle() functions generate a pretty
|
5
|
+
# flower. Uncomment the line "// rotate(rot+=radians(spin));"
|
6
|
+
# in the triBlur() function for a nice variation.
|
7
|
+
|
8
|
+
class TriangleFlower < Processing::App
|
9
|
+
|
10
|
+
def setup
|
11
|
+
|
12
|
+
size 200, 200
|
13
|
+
|
14
|
+
background 0
|
15
|
+
smooth
|
16
|
+
|
17
|
+
@fill_color = 0.0
|
18
|
+
@shift = 1.0
|
19
|
+
@rot = 0.0
|
20
|
+
@fade = 255.0 / ( width / 2.0 / @shift )
|
21
|
+
@spin = 360.0 / ( width / 2.0 / @shift )
|
22
|
+
|
23
|
+
@p = []
|
24
|
+
@p.push Point.new -width / 2.0, height / 2.0
|
25
|
+
@p.push Point.new width / 2.0, height / 2.0
|
26
|
+
@p.push Point.new 0.0, -height / 2.0
|
27
|
+
|
28
|
+
no_stroke
|
29
|
+
translate width/2, height/2
|
30
|
+
|
31
|
+
while @p[0].x < 0 do
|
32
|
+
tri_blur
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def tri_blur
|
37
|
+
|
38
|
+
fill @fill_color
|
39
|
+
@fill_color += @fade
|
40
|
+
|
41
|
+
rotate @spin
|
42
|
+
|
43
|
+
# try these lines also ..
|
44
|
+
#@rot += radians @spin
|
45
|
+
#rotate @rot
|
46
|
+
|
47
|
+
@p[0].x += @shift
|
48
|
+
@p[0].y -= @shift / 2
|
49
|
+
@p[1].x -= @shift
|
50
|
+
@p[1].y -= @shift / 2
|
51
|
+
@p[2].y += @shift
|
52
|
+
|
53
|
+
triangle @p[0].x, @p[0].y, @p[1].x, @p[1].y, @p[2].x, @p[2].y
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
class Point
|
59
|
+
|
60
|
+
attr_accessor :x, :y
|
61
|
+
|
62
|
+
def initialize ( x, y )
|
63
|
+
|
64
|
+
@x, @y = x, y
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
TriangleFlower.new :title => "Triangle Flower"
|
Binary file
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# Letters.
|
2
|
+
#
|
3
|
+
# Draws letters to the screen. This requires loading a font,
|
4
|
+
# setting the font, and then drawing the letters.
|
5
|
+
|
6
|
+
class Letters < Processing::App
|
7
|
+
|
8
|
+
def setup
|
9
|
+
|
10
|
+
size 200, 200
|
11
|
+
|
12
|
+
smooth
|
13
|
+
|
14
|
+
@font = load_font "CourierNew36.vlw" # you need the Processing IDE to
|
15
|
+
# generate .vlw fonts ..
|
16
|
+
text_font @font, 32
|
17
|
+
text_align CENTER
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
def draw
|
22
|
+
|
23
|
+
background 0
|
24
|
+
|
25
|
+
translate 24, 32
|
26
|
+
|
27
|
+
x, y = 0.0, 0.0
|
28
|
+
gap = 30
|
29
|
+
|
30
|
+
letters = ("A".."Z").to_a + ("0".."9").to_a # ranges -> arrays -> joined!
|
31
|
+
|
32
|
+
letters.each do |letter|
|
33
|
+
|
34
|
+
fill 255
|
35
|
+
fill 204, 204, 0 if letter =~ /[AEIOU]/
|
36
|
+
fill 153 if letter =~ /[0-9]/
|
37
|
+
fill 255, 100, 0 if key_pressed? && (letter.downcase.eql? key)
|
38
|
+
|
39
|
+
text letter, x, y
|
40
|
+
|
41
|
+
x += gap
|
42
|
+
|
43
|
+
if x > width - 30
|
44
|
+
x = 0
|
45
|
+
y += gap
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
Letters.new :title => "Letters"
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Words.
|
2
|
+
#
|
3
|
+
# The text() function is used for writing words to the screen.
|
4
|
+
|
5
|
+
class Words < Processing::App
|
6
|
+
|
7
|
+
def setup
|
8
|
+
|
9
|
+
size 200, 200
|
10
|
+
|
11
|
+
@x = 30
|
12
|
+
|
13
|
+
@font = load_font "Ziggurat-HTF-Black-32.vlw" # generate with Processing IDE
|
14
|
+
|
15
|
+
text_font @font, 32
|
16
|
+
|
17
|
+
no_loop
|
18
|
+
end
|
19
|
+
|
20
|
+
def draw
|
21
|
+
|
22
|
+
background 102
|
23
|
+
|
24
|
+
fill 0
|
25
|
+
text "ichi", @x, 60
|
26
|
+
fill 51
|
27
|
+
text "ni", @x, 95
|
28
|
+
fill 204
|
29
|
+
text "san", @x, 130
|
30
|
+
fill 255
|
31
|
+
text "shi", @x, 165
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
Words.new :title => "Words"
|