cf3 0.0.4 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +2 -0
- data/{CHANGELOG → CHANGELOG.md} +13 -0
- data/Gemfile +1 -1
- data/README.md +21 -21
- data/Rakefile +7 -3
- data/bin/cf3samples +4 -4
- data/cf3ruby.gemspec +12 -13
- data/docs/.sass-cache/cd612fe6616e7f514a2421dc73159618de35b85d/jekyll-theme-cayman.scssc +0 -0
- data/docs/.sass-cache/cd612fe6616e7f514a2421dc73159618de35b85d/normalize.scssc +0 -0
- data/docs/.sass-cache/cd612fe6616e7f514a2421dc73159618de35b85d/rouge-github.scssc +0 -0
- data/docs/.sass-cache/cd612fe6616e7f514a2421dc73159618de35b85d/variables.scssc +0 -0
- data/docs/README.md +1 -0
- data/docs/_config.yml +31 -0
- data/docs/_site/README.md +1 -0
- data/docs/_site/about/index.html +52 -0
- data/docs/_site/assets/css/style.css +809 -0
- data/docs/_site/assets/y.png +0 -0
- data/docs/_site/example/index.html +113 -0
- data/docs/_site/favicon.ico +0 -0
- data/docs/_site/feed.xml +10 -0
- data/docs/_site/index.html +51 -0
- data/docs/_site/robots.txt +1 -0
- data/docs/_site/sitemap.xml +12 -0
- data/docs/about.md +14 -0
- data/docs/assets/y.png +0 -0
- data/docs/example.md +73 -0
- data/docs/favicon.ico +0 -0
- data/docs/index.md +10 -0
- data/lib/cf3/version.rb +1 -1
- data/lib/cf3.rb +85 -100
- data/samples/Rakefile +30 -0
- data/samples/accident.rb +34 -30
- data/samples/alhambra.rb +32 -29
- data/samples/bar_code.rb +26 -22
- data/samples/city.rb +14 -11
- data/samples/creature.rb +10 -6
- data/samples/dark_star.rb +5 -3
- data/samples/data/java_args.txt +1 -2
- data/samples/dragon.rb +8 -4
- data/samples/escher.rb +115 -116
- data/samples/fern.rb +13 -9
- data/samples/hex_tube.rb +16 -13
- data/samples/isosceles.rb +16 -11
- data/samples/levy.rb +5 -2
- data/samples/pcr.rb +28 -24
- data/samples/rubystar.rb +23 -17
- data/samples/sierpinski.rb +15 -11
- data/samples/spiral.rb +14 -10
- data/samples/star.rb +10 -6
- data/samples/tree.rb +20 -17
- data/samples/tree4.rb +12 -8
- data/samples/vine.rb +11 -7
- data/samples/xcross.rb +10 -7
- data/samples/y.rb +13 -9
- data/test/test_cf3.rb +11 -7
- metadata +50 -42
data/samples/dark_star.rb
CHANGED
@@ -26,8 +26,12 @@ def setup_the_sun
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
29
|
+
def settings
|
30
30
|
size 600, 600
|
31
|
+
end
|
32
|
+
|
33
|
+
def setup
|
34
|
+
sketch_title 'Dark Star'
|
31
35
|
setup_the_sun
|
32
36
|
no_stroke
|
33
37
|
color_mode HSB, 1.0
|
@@ -43,5 +47,3 @@ def draw_it
|
|
43
47
|
@sun.render :start, size: height/7, stop_size: 0.8,
|
44
48
|
start_x: width/2, start_y: height/2
|
45
49
|
end
|
46
|
-
|
47
|
-
|
data/samples/data/java_args.txt
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
-
|
2
|
-
|
1
|
+
-XX:InlineSmallCode=500 -Xms256m -Xmx2g -XX:NewSize=64m -XX:MaxNewSize=64m
|
data/samples/dragon.rb
CHANGED
@@ -6,11 +6,11 @@ INV_SQRT = 1 / Math.sqrt(2)
|
|
6
6
|
|
7
7
|
def setup_the_dragon
|
8
8
|
@dragon = ContextFree.define do
|
9
|
-
|
9
|
+
|
10
10
|
shape :start do
|
11
11
|
dragon alpha: 1
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
shape :dragon do
|
15
15
|
square hue: 0, brightness: 0, saturation: 1, alpha: 0.02
|
16
16
|
split do
|
@@ -20,12 +20,16 @@ def setup_the_dragon
|
|
20
20
|
rewind
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
27
|
+
def settings
|
28
28
|
size 800, 500
|
29
|
+
end
|
30
|
+
|
31
|
+
def setup
|
32
|
+
sketch_title 'Heighway Dragon'
|
29
33
|
setup_the_dragon
|
30
34
|
smooth
|
31
35
|
draw_it
|
data/samples/escher.rb
CHANGED
@@ -1,124 +1,123 @@
|
|
1
1
|
require 'cf3'
|
2
2
|
|
3
|
-
def setup_the_birds
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
split do
|
78
|
-
10.times do |j|
|
79
|
-
bird size: 1, x: (i * 0.5 + 0.25 * (j%2)), y: j * 0.435
|
80
|
-
rewind
|
81
|
-
end
|
82
|
-
rewind
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
shape :bird do
|
89
|
-
wavy_diamond color: [38, 1, 1, 1]
|
90
|
-
end
|
91
|
-
|
92
|
-
shape :bird do
|
93
|
-
wavy_diamond color: [180, 1, 1, 1]
|
94
|
-
end
|
95
|
-
|
96
|
-
shape :bird do
|
97
|
-
wavy_diamond color: [36, 1, 1, 1]
|
98
|
-
end
|
99
|
-
|
100
|
-
shape :bird do
|
101
|
-
wavy_diamond color: [0.2, 1, 1, 1]
|
102
|
-
end
|
103
|
-
|
104
|
-
shape :bird do
|
105
|
-
wavy_diamond color: [0.01, 1, 1, 1]
|
3
|
+
def setup_the_birds
|
4
|
+
@birds= ContextFree.define do
|
5
|
+
############ Begin defining custom terminal, an wavy_triangle triangle
|
6
|
+
class << self
|
7
|
+
SQRT3 = Math.sqrt(3)
|
8
|
+
define_method(:wavy_diamond) do |some_options| # wavy_triangle triangle
|
9
|
+
options = self.get_shape_values(some_options)
|
10
|
+
size = options[:size]
|
11
|
+
rot = options[:rotation]
|
12
|
+
x0 = options[:x]
|
13
|
+
y0 = options[:y]
|
14
|
+
disp = options[:disp]
|
15
|
+
col = options[:color]
|
16
|
+
pts = Array.new(16)
|
17
|
+
pts[0] = Vec2D.new(x0 - 0.25 * size, y0 - size / SQRT3) # A
|
18
|
+
pts[2] = Vec2D.new(x0 + 0.75 * size, y0 - size / SQRT3) # B
|
19
|
+
pts[4] = Vec2D.new(x0 + 0.25 * size, y0 + (SQRT3 * size) / 6) # C
|
20
|
+
pts[6] = Vec2D.new(x0 - 0.75 * size, y0 + (SQRT3 * size) / 6) # D
|
21
|
+
pts[1] = get_mid_point(pts[0], pts[2])#Ab
|
22
|
+
pts[3] = get_mid_point(pts[2], pts[4])#Bc
|
23
|
+
pts[5] = get_mid_point(pts[4], pts[6])#Cd
|
24
|
+
pts[7] = get_mid_point(pts[6], pts[0])#Da
|
25
|
+
pts[8] = get_mid_point(pts[0], pts[1])#Aba
|
26
|
+
pts[8] += adjust_bezier(PI/2, -disp * size)#Aba
|
27
|
+
pts[9] = get_mid_point(pts[1], pts[2])
|
28
|
+
pts[9] += adjust_bezier(PI/2, disp * size)
|
29
|
+
pts[10] = get_mid_point(pts[2], pts[3])
|
30
|
+
pts[10] += adjust_bezier(PI/3, disp * size)
|
31
|
+
pts[11] = get_mid_point(pts[3], pts[4])
|
32
|
+
pts[11] += adjust_bezier(PI/3, -disp * size)
|
33
|
+
pts[12] = get_mid_point(pts[4], pts[5])
|
34
|
+
pts[12] += adjust_bezier(PI/2, disp * size)
|
35
|
+
pts[13] = get_mid_point(pts[5], pts[6])
|
36
|
+
pts[13] += adjust_bezier(PI/2, -disp * size)
|
37
|
+
pts[14] = get_mid_point(pts[6], pts[7])
|
38
|
+
pts[14] += adjust_bezier(PI/3, -disp * size)
|
39
|
+
pts[15] = get_mid_point(pts[7], pts[0])
|
40
|
+
pts[15] += adjust_bezier(PI/3, disp * size)
|
41
|
+
rotate(rot) if rot
|
42
|
+
fill *col
|
43
|
+
begin_shape
|
44
|
+
vertex(pts[0].x, pts[0].y)
|
45
|
+
bezier_vertex(pts[0].x, pts[0].y, pts[8].x, pts[8].y, pts[1].x, pts[1].y)
|
46
|
+
bezier_vertex(pts[1].x, pts[1].y, pts[9].x, pts[9].y, pts[2].x, pts[2].y)
|
47
|
+
bezier_vertex(pts[2].x, pts[2].y, pts[10].x, pts[10].y, pts[3].x, pts[3].y)
|
48
|
+
bezier_vertex(pts[3].x, pts[3].y, pts[11].x, pts[11].y, pts[4].x, pts[4].y)
|
49
|
+
bezier_vertex(pts[4].x, pts[4].y, pts[12].x, pts[12].y, pts[5].x, pts[5].y)
|
50
|
+
bezier_vertex(pts[5].x, pts[5].y, pts[13].x, pts[13].y, pts[6].x, pts[6].y)
|
51
|
+
bezier_vertex(pts[6].x, pts[6].y, pts[14].x, pts[14].y, pts[7].x, pts[7].y)
|
52
|
+
bezier_vertex(pts[7].x, pts[7].y, pts[15].x, pts[15].y, pts[0].x, pts[0].y)
|
53
|
+
vertex(pts[0].x, pts[0].y)
|
54
|
+
end_shape(CLOSE)
|
55
|
+
rotate(-rot) if rot
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
def adjust_bezier(theta, disp)
|
60
|
+
Vec2D.new(Math.cos(theta)*disp, Math.sin(theta)*disp)
|
61
|
+
end
|
62
|
+
|
63
|
+
def get_mid_point(a, b)
|
64
|
+
(a + b) / 2.0
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
########### End definition of custom terminal 'wavy_diamond' shape
|
69
|
+
shape :birds do
|
70
|
+
bird size: 0.1
|
71
|
+
split do
|
72
|
+
10.times do |i|
|
73
|
+
split do
|
74
|
+
10.times do |j|
|
75
|
+
bird size: 1, x: (i * 0.5 + 0.25 * (j%2)), y: j * 0.435
|
76
|
+
rewind
|
106
77
|
end
|
107
|
-
|
78
|
+
rewind
|
79
|
+
end
|
108
80
|
end
|
81
|
+
end
|
109
82
|
end
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
setup_the_birds
|
114
|
-
draw_it
|
83
|
+
|
84
|
+
shape :bird do
|
85
|
+
wavy_diamond color: [38, 1, 1, 1]
|
115
86
|
end
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
87
|
+
|
88
|
+
shape :bird do
|
89
|
+
wavy_diamond color: [180, 1, 1, 1]
|
90
|
+
end
|
91
|
+
|
92
|
+
shape :bird do
|
93
|
+
wavy_diamond color: [36, 1, 1, 1]
|
94
|
+
end
|
95
|
+
|
96
|
+
shape :bird do
|
97
|
+
wavy_diamond color: [0.2, 1, 1, 1]
|
120
98
|
end
|
121
|
-
|
122
|
-
|
123
|
-
|
99
|
+
|
100
|
+
shape :bird do
|
101
|
+
wavy_diamond color: [0.01, 1, 1, 1]
|
124
102
|
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def settings
|
107
|
+
size 1000, 800
|
108
|
+
end
|
109
|
+
|
110
|
+
def setup
|
111
|
+
sketch_title 'In pursuit of M.C. Escher'
|
112
|
+
setup_the_birds
|
113
|
+
draw_it
|
114
|
+
end
|
115
|
+
|
116
|
+
def draw_it
|
117
|
+
background 255
|
118
|
+
@birds.render :birds, :start_x => 0, :start_y => 0, size: 1000, :disp => 0.32, color: [0, 1, 1, 1]
|
119
|
+
end
|
120
|
+
|
121
|
+
def draw
|
122
|
+
# do nothing
|
123
|
+
end
|
data/samples/fern.rb
CHANGED
@@ -7,29 +7,33 @@ require 'cf3'
|
|
7
7
|
#######################################################
|
8
8
|
|
9
9
|
def setup_the_fern
|
10
|
-
|
10
|
+
|
11
11
|
@fern = ContextFree.define do
|
12
|
-
|
12
|
+
|
13
13
|
shape :start do
|
14
|
-
fern rotation:
|
14
|
+
fern rotation: 8, hue: 306
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
shape :fern do
|
18
|
-
|
18
|
+
square size: 0.75, rotation: -49
|
19
19
|
split do
|
20
|
-
fern size: 0.92, y: -2, rotation:
|
20
|
+
fern size: 0.92, y: -2, rotation: 5, hue: 306
|
21
21
|
rewind
|
22
22
|
fern size: 0.5, y: -2, rotation: 90
|
23
|
-
rewind
|
23
|
+
rewind
|
24
24
|
fern size: 0.5, y: -2, rotation: -90
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
31
|
+
def settings
|
32
32
|
size 600, 600
|
33
|
+
end
|
34
|
+
|
35
|
+
def setup
|
36
|
+
sketch_title 'Fern'
|
33
37
|
setup_the_fern
|
34
38
|
no_stroke
|
35
39
|
end
|
data/samples/hex_tube.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
#########################
|
2
|
-
# hextube.rb by Martin Prout
|
2
|
+
# hextube.rb by Martin Prout
|
3
3
|
#########################
|
4
4
|
require 'cf3'
|
5
|
-
#load_library :cf3
|
6
5
|
|
7
6
|
def setup_the_hextube
|
8
7
|
@hexa = ContextFree.define do
|
9
8
|
############ Begin defining custom terminal, as a hexagon (path C++ cfdg)
|
10
9
|
class << self
|
11
|
-
define_method(:hexagon) do |some_options|
|
12
|
-
|
10
|
+
define_method(:hexagon) do |some_options|
|
11
|
+
options = self.get_shape_values(some_options)
|
12
|
+
size = options[:size]
|
13
13
|
rot = (options[:rotation])? options[:rotation]: 0
|
14
14
|
no_fill
|
15
15
|
stroke(*options[:color])
|
@@ -19,29 +19,32 @@ def setup_the_hextube
|
|
19
19
|
vertex(size * Math.cos(Math::PI * i/3 + rot), size * Math.sin(Math::PI * i/3 + rot))
|
20
20
|
end
|
21
21
|
end_shape(CLOSE)
|
22
|
-
end
|
22
|
+
end
|
23
23
|
end
|
24
24
|
########### End definition of custom terminal 'hexagon'
|
25
25
|
shape :hextube do
|
26
|
-
hexa brightness: 1.0
|
26
|
+
hexa brightness: 1.0
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
shape :hexa do |i = nil, j = 0.5|
|
30
|
-
hexagon
|
31
|
-
hexa
|
30
|
+
hexagon(size: 1, brightness: 1.0)
|
31
|
+
hexa(size: 0.9, rotation: 5 * j)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
def
|
36
|
+
def settings
|
37
37
|
size 800, 800
|
38
|
-
|
39
|
-
|
38
|
+
end
|
39
|
+
|
40
|
+
def setup
|
41
|
+
sketch_title 'Hex-Tube'
|
42
|
+
background 0
|
40
43
|
setup_the_hextube
|
41
44
|
draw_it
|
42
45
|
end
|
43
46
|
|
44
47
|
def draw_it
|
45
|
-
@hexa.render :hextube, start_x: width/2, start_y: height/2,
|
48
|
+
@hexa.render :hextube, start_x: width/2, start_y: height/2,
|
46
49
|
size: height/2.1, color: [60, 1, 1, 0.5]
|
47
50
|
end
|
data/samples/isosceles.rb
CHANGED
@@ -2,26 +2,31 @@ require 'cf3'
|
|
2
2
|
|
3
3
|
def setup_the_spiral
|
4
4
|
@spiral= ContextFree.define do
|
5
|
-
############ Begin defining custom terminal, an
|
6
|
-
class << self
|
7
|
-
define_method(:
|
8
|
-
|
5
|
+
############ Begin defining custom terminal, an isosceles triangle
|
6
|
+
class << self
|
7
|
+
define_method(:isosceles) do |some_options| # isosceles triangle
|
8
|
+
options = get_shape_values(some_options)
|
9
|
+
size = options[:size]
|
9
10
|
rot = options[:rotation]
|
10
|
-
rotate(rot) if rot
|
11
|
-
|
11
|
+
rotate(rot) if rot
|
12
|
+
@app.triangle(-0.5 * size, -0.5 * size, -0.5 * size, 0.5 * size, 0.5 * size, 0.5 * size)
|
12
13
|
rotate(-rot) if rot
|
13
14
|
end
|
14
15
|
end
|
15
|
-
########### End definition of custom terminal '
|
16
|
+
########### End definition of custom terminal 'isosceles'
|
16
17
|
shape :spiral do
|
17
|
-
|
18
|
-
spiral rotation: 135, size: 1/sqrt(2), x: 1/sqrt(2)
|
18
|
+
isosceles brightness: -1, rotation: 90
|
19
|
+
spiral rotation: 135, size: 1 / sqrt(2), x: 1 / sqrt(2)
|
19
20
|
end
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
23
|
-
def
|
24
|
+
def settings
|
24
25
|
size 800, 500
|
26
|
+
end
|
27
|
+
|
28
|
+
def setup
|
29
|
+
sketch_title 'Isosceles'
|
25
30
|
setup_the_spiral
|
26
31
|
draw_it
|
27
32
|
end
|
@@ -32,5 +37,5 @@ end
|
|
32
37
|
|
33
38
|
def draw_it
|
34
39
|
background 255
|
35
|
-
@spiral.render :spiral, size: height, start_x: width/3, start_y: height/2
|
40
|
+
@spiral.render :spiral, size: height, start_x: width / 3, start_y: height / 2
|
36
41
|
end
|