Skip to content

Commit bcc5b64

Browse files
committed
re-arrange
1 parent bf1f901 commit bcc5b64

File tree

154 files changed

+39764
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+39764
-3
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Simple demo Rakefile to autorun samples in current directory
2+
# adjust path to rp5 executable, and or opts as required
3+
4+
SAMPLES_DIR = './'
5+
6+
desc 'run demo'
7+
task default: [:demo]
8+
9+
desc 'demo'
10+
task :demo do
11+
samples_list.shuffle.each{ |sample| run_sample sample }
12+
end
13+
14+
def samples_list
15+
files = []
16+
Dir.chdir(SAMPLES_DIR)
17+
Dir.glob('*.rb').each do |file|
18+
files << File.join(SAMPLES_DIR, file)
19+
end
20+
return files
21+
end
22+
23+
def run_sample(sample_name)
24+
puts "Running #{sample_name}...quit to run next sample"
25+
open("|jruby #{sample_name}", 'r') do |io|
26+
while l = io.gets
27+
puts(l.chop)
28+
end
29+
end
30+
end
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env jruby -v -W2
2+
# frozen_string_literal: true
3+
require 'picrate'
4+
require 'arcball'
5+
# The current local time can be read with the Time.now
6+
# the seconds Time.now.sec, minutes Time.now.min etc...
7+
# functions. In this example, DegLut.sin() and DegLut.cos() values are used to
8+
# set the position of the hands, perfect for degree precision Lookup Table.
9+
class ArcBallBox < Processing::App
10+
############################
11+
# Use mouse drag to rotate
12+
# the arcball. Use mousewheel
13+
# to zoom. Hold down x, y, z
14+
# to constrain rotation axis.
15+
############################
16+
def setup
17+
sketch_title 'Arcball Box'
18+
Processing::ArcBall.init self, 300, 300
19+
fill 180
20+
end
21+
22+
def draw
23+
background 50
24+
box 300, 300, 300
25+
end
26+
27+
def settings
28+
size 600, 600, P3D
29+
smooth 8
30+
end
31+
end
32+
33+
ArcBallBox.new
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin//env jruby -v -w
2+
3+
require 'picrate'
4+
require 'arcball'
5+
6+
############################
7+
# Use mouse drag to rotate
8+
# the arcball. Use mousewheel
9+
# to zoom. Custom constrain
10+
# default is yaxis.
11+
############################
12+
13+
class ArcballBox < Processing::App
14+
15+
def settings
16+
size(600, 600, P3D)
17+
smooth(8)
18+
end
19+
20+
def setup
21+
sketch_title 'ArcBall Box'
22+
Processing::ArcBall.constrain(self, :xaxis)
23+
fill 180
24+
end
25+
26+
def draw
27+
background(50)
28+
box(300, 300, 300)
29+
end
30+
end
31+
32+
ArcballBox.new
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env jruby -v -W2
2+
# frozen_string_literal: true
3+
require 'picrate'
4+
require 'arcball'
5+
6+
class ArcBallShape < Processing::App
7+
attr_reader :my_cube
8+
9+
def setup
10+
sketch_title 'Arcball Shape'
11+
Processing::ArcBall.init(self)
12+
@my_cube = create_shape BOX, 400, 400, 400
13+
my_cube.set_fill(color(100, 10, 100))
14+
end
15+
16+
def draw
17+
background(50, 50, 100)
18+
define_lights
19+
lights
20+
stroke(0)
21+
shape(my_cube)
22+
end
23+
24+
def define_lights
25+
ambient(20, 20, 20)
26+
ambient_light(50, 50, 50)
27+
point_light(30, 30, 30, 200, -150, 0)
28+
directional_light(0, 30, 50, 1, 0, 0)
29+
spot_light(30, 30, 30, 0, 40, 200, 0, -0.5, -0.5, PI / 2, 2)
30+
end
31+
32+
def settings
33+
size 600, 600, P3D
34+
smooth 8
35+
end
36+
end
37+
38+
ArcBallShape.new
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env jruby -v -W2
2+
# frozen_string_literal: true
3+
require 'picrate'
4+
require 'arcball'
5+
6+
############################
7+
# Use mouse drag to rotate
8+
# the arcball. Use mousewheel
9+
# to zoom. Constrained to
10+
# rotation around y-axis.
11+
############################
12+
class Constrain < Processing::App
13+
14+
def setup
15+
sketch_title 'Arcball Box'
16+
Processing::ArcBall.constrain self
17+
fill 180
18+
end
19+
20+
def draw
21+
background 50
22+
box 300, 300, 300
23+
end
24+
25+
def settings
26+
size 600, 600, P3D
27+
smooth 8
28+
end
29+
end
30+
31+
Constrain.new
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env jruby -v -W2
2+
# frozen_string_literal: true
3+
require 'picrate'
4+
require 'arcball'
5+
6+
############################
7+
# Use mouse drag to rotate
8+
# the arcball. Use mousewheel
9+
# to zoom. Constrained to
10+
# rotation around z-axis
11+
############################
12+
class Constrain < Processing::App
13+
14+
def setup
15+
sketch_title 'Arcball Box'
16+
Processing::ArcBall.constrain self, :zaxis
17+
fill 180
18+
end
19+
20+
def draw
21+
background 50
22+
box 300, 300, 300
23+
end
24+
25+
def settings
26+
size 600, 600, P3D
27+
smooth 8
28+
end
29+
end
30+
31+
Constrain.new
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
### Tutorials on Geomerative library ###
2+
3+
In english by some clever [French men][french]
4+
5+
In english by a clever [Dutch man][dutch], since 2016 requires a subscription
6+
7+
In [german][german]
8+
9+
### Examples ###
10+
11+
The solid_type sketch is a variant of an Amon Owed sketch requires picrate-2.0.7 (or latest github version).
12+
Requires [geomerative.gem][gem] and hemesh library, see [guide to install vanilla processing libraries][guide] in picrate. You need to do something similar for vanilla processing pdf library (I have copy installed for PiCrate), there might be other ways to get it eg github, ie without requiring a full vanilla processing install.
13+
14+
NB: to load `ttf` also known as true type fonts you should us absolute path unless they are included in the data folder (then use `data_path` wrapper)
15+
16+
### Other Examples ###
17+
18+
Here is a collection on [Open Processing][open_processing]
19+
20+
21+
22+
[french]:http://freeartbureau.org/fab_activity/geomerative-tutorial-part-1/
23+
[dutch]:http://www.creativeapplications.net/processing/generative-typography-processing-tutorial/
24+
[german]:https://lernprocessing.wordpress.com/2011/11/15/geomerative-library/
25+
[open_processing]:http://www.openprocessing.org/collection/1374
26+
[gem]:https://github.com/ruby-processing/geomerativegem/
27+
[guide]:https://ruby-processing.github.io/picrate/contributed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Simple demo Rakefile to autorun samples in current directory
2+
# adjust path to jruby executable, and or opts as required
3+
4+
SAMPLES_DIR = './'
5+
6+
desc 'run demo'
7+
task default: [:demo]
8+
9+
desc 'demo'
10+
task :demo do
11+
samples_list.shuffle.each { |sample| run_sample sample }
12+
end
13+
14+
def samples_list
15+
files = []
16+
Dir.chdir(SAMPLES_DIR)
17+
Dir.glob('*.rb').each do |file|
18+
files << File.join(SAMPLES_DIR, file)
19+
end
20+
return files
21+
end
22+
23+
def run_sample(sample_name)
24+
puts "Running #{sample_name}...quit to run next sample"
25+
open("|jruby --dev #{sample_name}", 'r') do |io|
26+
while l = io.gets
27+
puts(l.chop)
28+
end
29+
end
30+
end
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env jruby
2+
require 'picrate'
3+
require 'geomerative'
4+
5+
class BinaryIntersection < Processing::App
6+
include_package 'geomerative'
7+
attr_reader :shp1, :shp2, :shp3, :cursor_shape
8+
9+
def setup
10+
sketch_title 'Binary Intersection'
11+
RG.init(self)
12+
@shp1 = RShape.create_ring(0, 0, 120, 50)
13+
@shp2 = RShape.create_star(0, 0, 100.0, 80.0, 20)
14+
end
15+
16+
def draw
17+
background(255)
18+
translate(width / 2, height / 2)
19+
@cursor_shape = RShape.new(shp2)
20+
cursor_shape.translate(mouse_x - width / 2, mouse_y - height / 2)
21+
# Only intersection does not work for shapes with more than one path
22+
@shp3 = RG.diff(shp1, cursor_shape)
23+
stroke_weight 3
24+
if mouse_pressed?
25+
fill(220, 0, 0, 30)
26+
stroke(120, 0, 0)
27+
RG.shape(cursor_shape)
28+
fill(0, 220, 0, 30)
29+
stroke(0, 120, 0)
30+
RG.shape(shp1)
31+
else
32+
fill(220)
33+
stroke(120)
34+
RG.shape(shp3)
35+
end
36+
end
37+
38+
def settings
39+
size(400, 400)
40+
smooth
41+
end
42+
end
43+
44+
BinaryIntersection.new
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env jruby -w
2+
require 'picrate'
3+
require 'geomerative'
4+
# After an original sketch by fjenett
5+
# Declare the objects we are going to use, so that they are accesible
6+
# from setup and from draw
7+
class BlobbyTrail < Processing::App
8+
attr_reader :shp, :x, :y, :xd, :yd
9+
10+
def settings
11+
size(600, 400)
12+
smooth(4)
13+
end
14+
15+
def setup
16+
sketch_title 'Blobby Trail'
17+
RG.init(self)
18+
@xd = rand(-5..5)
19+
@yd = rand(-5..5)
20+
@x = width / 2
21+
@y = height / 2
22+
@shp = RShape.new
23+
end
24+
25+
def draw
26+
background(120)
27+
move
28+
elli = RG.getEllipse(x, y, rand(2..20))
29+
@shp = RG.union(shp, elli)
30+
RG.shape(shp)
31+
end
32+
33+
def move
34+
@x += xd
35+
@xd *= -1 unless (0..width).cover?(x)
36+
@y += yd
37+
@yd *= -1 unless (0..height).cover?(y)
38+
end
39+
end
40+
41+
BlobbyTrail.new

0 commit comments

Comments
 (0)