cf3 0.0.5 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG +6 -0
- data/Gemfile +1 -1
- data/README.md +21 -21
- data/Rakefile +6 -2
- data/cf3ruby.gemspec +13 -13
- data/lib/cf3.rb +75 -90
- data/lib/cf3/version.rb +1 -1
- 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 +10 -6
- data/samples/hex_tube.rb +16 -13
- data/samples/isosceles.rb +16 -11
- data/samples/levy.rb +4 -1
- 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 +19 -16
- data/samples/tree4.rb +12 -8
- data/samples/vine.rb +11 -7
- data/samples/xcross.rb +10 -7
- data/samples/y.rb +12 -8
- data/test/test_cf3.rb +11 -7
- metadata +23 -20
data/samples/tree4.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# tree4.rb by Martin Prout after tree4.cfdg
|
3
3
|
# A non deterministic sketch run it until you get a result you like
|
4
4
|
# uncomment "srand 5" to get a more deterministic result. It looked
|
5
|
-
# pretty good on my linux box (however I'm not sure how universal the
|
5
|
+
# pretty good on my linux box (however I'm not sure how universal the
|
6
6
|
# random seeding is in jruby)
|
7
7
|
#################################################################
|
8
8
|
|
@@ -12,14 +12,14 @@ def setup_the_tree
|
|
12
12
|
@tree = ContextFree.define do
|
13
13
|
shape :trunk, 20 do # rule has a probability weighting of 20
|
14
14
|
circle size: 0.25, brightness: 0.5 # giving an actual probability = 0.952381
|
15
|
-
scraggle y: -0.1 # the minus is require by the upside down coordinate system
|
15
|
+
scraggle y: -0.1 # the minus is require by the upside down coordinate system
|
16
16
|
end
|
17
17
|
|
18
18
|
shape :trunk, 1 do # rule has a probability weighting of 1
|
19
|
-
branch size: 0.7 # giving an actual probability = 0.047619
|
19
|
+
branch size: 0.7 # giving an actual probability = 0.047619
|
20
20
|
end
|
21
21
|
|
22
|
-
shape :trunk, 0.02 do # empty rule top stop early
|
22
|
+
shape :trunk, 0.02 do # empty rule top stop early
|
23
23
|
end
|
24
24
|
|
25
25
|
shape :branch do
|
@@ -30,8 +30,8 @@ def setup_the_tree
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
shape :scraggle do # without an explicit weighting
|
34
|
-
trunk rotation: 5 # probability of each scraggle rule
|
33
|
+
shape :scraggle do # without an explicit weighting
|
34
|
+
trunk rotation: 5 # probability of each scraggle rule
|
35
35
|
end # is 0.5
|
36
36
|
|
37
37
|
shape :scraggle do
|
@@ -40,8 +40,12 @@ def setup_the_tree
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
def
|
43
|
+
def settings
|
44
44
|
size 600, 600
|
45
|
+
end
|
46
|
+
|
47
|
+
def setup
|
48
|
+
sketch_title 'Tree 4'
|
45
49
|
srand 5 # comment this to get variable tree shape
|
46
50
|
setup_the_tree
|
47
51
|
end
|
@@ -54,7 +58,7 @@ end
|
|
54
58
|
# color: [0, 0, 0, 1] even in HSB this should be black, seems to work...
|
55
59
|
#####
|
56
60
|
def draw_it
|
57
|
-
@tree.render :trunk, start_x: width/2, start_y: height * 0.9, stop_size: height/150, size: height/15, color: [0, 0, 0, 1]
|
61
|
+
@tree.render :trunk, start_x: width/2, start_y: height * 0.9, stop_size: height/150, size: height/15, color: [0, 0, 0, 1]
|
58
62
|
end
|
59
63
|
|
60
64
|
def mouse_clicked
|
data/samples/vine.rb
CHANGED
@@ -3,11 +3,11 @@
|
|
3
3
|
require 'cf3'
|
4
4
|
|
5
5
|
def setup_the_vine
|
6
|
-
|
6
|
+
|
7
7
|
@vine = ContextFree.define do
|
8
|
-
|
8
|
+
|
9
9
|
shrink = 0.961
|
10
|
-
|
10
|
+
|
11
11
|
shape :root do
|
12
12
|
split do
|
13
13
|
shoot y: 1
|
@@ -15,12 +15,12 @@ def setup_the_vine
|
|
15
15
|
shoot rotation: 180
|
16
16
|
end
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
shape :shoot do
|
20
20
|
square
|
21
21
|
shoot y: 0.98, rotation: 5, size: shrink + rand * 0.05, brightness: 0.990
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
shape :shoot, 0.02 do
|
25
25
|
square
|
26
26
|
split do
|
@@ -29,12 +29,16 @@ def setup_the_vine
|
|
29
29
|
shoot rotation: -90
|
30
30
|
end
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
def
|
36
|
+
def settings
|
37
37
|
size 700, 700
|
38
|
+
end
|
39
|
+
|
40
|
+
def setup
|
41
|
+
sketch_title 'Vine'
|
38
42
|
setup_the_vine
|
39
43
|
no_stroke
|
40
44
|
end
|
data/samples/xcross.rb
CHANGED
@@ -5,10 +5,13 @@ require 'cf3'
|
|
5
5
|
# from primitive terminals (renders on mouse clicked)
|
6
6
|
###
|
7
7
|
|
8
|
+
def settings
|
9
|
+
size 400, 200
|
10
|
+
end
|
11
|
+
|
8
12
|
def setup
|
9
|
-
|
10
|
-
@stars = ContextFree.define do
|
11
|
-
|
13
|
+
sketch_title 'X-Cross'
|
14
|
+
@stars = ContextFree.define do
|
12
15
|
shape :stars do
|
13
16
|
split do
|
14
17
|
cross size: 0.5, x: -2
|
@@ -16,21 +19,21 @@ def setup
|
|
16
19
|
plus size: 0.5, x: 2
|
17
20
|
end
|
18
21
|
end
|
19
|
-
|
22
|
+
|
20
23
|
shape :cross do
|
21
24
|
square w: 1, h: 3, rotation: -45
|
22
25
|
square w: 1, h: 3, rotation: 45
|
23
26
|
end
|
24
|
-
|
27
|
+
|
25
28
|
shape :plus do
|
26
29
|
square w: 1, h: 3
|
27
30
|
square w: 1, h: 3, rotation: 90
|
28
31
|
end
|
29
|
-
end
|
32
|
+
end
|
30
33
|
end
|
31
34
|
|
32
35
|
def draw_it
|
33
|
-
background 0.2
|
36
|
+
background 0.2
|
34
37
|
@stars.render :stars, size: height/2, color: [220, 1, 1, 1]
|
35
38
|
end
|
36
39
|
|
data/samples/y.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
# y.rb ruby-processing by Martin Prout
|
2
2
|
require 'cf3'
|
3
|
-
Y_TOP = -1 / Math.sqrt(3)
|
3
|
+
Y_TOP = -1 / Math.sqrt(3)
|
4
4
|
Y_BOT = Math.sqrt(3) / 6
|
5
5
|
|
6
6
|
def setup_the_triangle
|
7
7
|
@triangle = ContextFree.define do
|
8
|
-
########
|
8
|
+
########
|
9
9
|
shape :start do
|
10
10
|
unit brightness: 1.0
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
shape :unit do
|
14
14
|
triangle size: 1.0
|
15
15
|
split do
|
16
16
|
unit size: 0.5, x: 0, y: Y_TOP/2, brightness: 0.8
|
17
|
-
rewind
|
18
|
-
unit size: 0.5, x: -0.25, y: -Y_TOP/4, brightness: 0.8
|
17
|
+
rewind
|
18
|
+
unit size: 0.5, x: -0.25, y: -Y_TOP/4, brightness: 0.8
|
19
19
|
rewind
|
20
20
|
unit size: 0.5, x: 0.25, y: -Y_TOP/4, brightness: 0.8
|
21
21
|
end
|
@@ -23,13 +23,17 @@ def setup_the_triangle
|
|
23
23
|
########
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
27
|
-
def
|
26
|
+
|
27
|
+
def settings
|
28
28
|
size 1024, 1024
|
29
|
+
smooth 8
|
30
|
+
end
|
31
|
+
|
32
|
+
def setup
|
33
|
+
sketch_title 'Y'
|
29
34
|
setup_the_triangle
|
30
35
|
no_stroke
|
31
36
|
color_mode RGB, 1
|
32
|
-
smooth 8
|
33
37
|
draw_it
|
34
38
|
save_frame("y.png")
|
35
39
|
end
|
data/test/test_cf3.rb
CHANGED
@@ -1,19 +1,23 @@
|
|
1
1
|
require_relative '../lib/cf3.rb'
|
2
2
|
|
3
|
+
def settings
|
4
|
+
size 200, 200
|
5
|
+
end
|
6
|
+
|
3
7
|
def setup
|
4
|
-
|
8
|
+
sketch_title 'Test'
|
5
9
|
@triangle = ContextFree.define do
|
6
10
|
shape :tri do
|
7
|
-
circle
|
8
|
-
triangle brightness: 0.8
|
9
|
-
|
11
|
+
circle brightness: 1.0, sat: 1.0, hue: 200
|
12
|
+
triangle brightness: 0.8, hue: 60
|
13
|
+
square brightness: 0.02, size: 0.05
|
10
14
|
end
|
11
|
-
end
|
15
|
+
end
|
12
16
|
end
|
13
17
|
|
14
18
|
def draw_it
|
15
|
-
background 0
|
16
|
-
@triangle.render :tri, size: height/2
|
19
|
+
background 255, 255, 0 # NB: default color_mode here
|
20
|
+
@triangle.render :tri, size: height / 2.0
|
17
21
|
end
|
18
22
|
|
19
23
|
def draw
|
metadata
CHANGED
@@ -1,30 +1,30 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cf3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Ashkenas
|
8
|
-
- Martin Prout
|
8
|
+
- Martin Prout, Funatsufumiya
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-02-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: jruby_art
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 1.
|
20
|
+
version: '1.4'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - "
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 1.
|
27
|
+
version: '1.4'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: bundler
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -43,23 +43,24 @@ dependencies:
|
|
43
43
|
name: rake
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '0'
|
48
|
+
version: '12.0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - "
|
53
|
+
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '0'
|
56
|
-
description:
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
55
|
+
version: '12.0'
|
56
|
+
description: |2
|
57
|
+
A library for JRubyArt, that allows the writing of context free
|
58
|
+
sketches (like context free art) in a ruby DSL. It is a bit of a toy
|
59
|
+
compared to the c++ version. However you can get quite a bit of
|
60
|
+
satisfaction creating an interesting graphic, and you can't always
|
61
|
+
predict what you are going to get.
|
61
62
|
email:
|
62
|
-
-
|
63
|
+
- mamba2928@yahoo.co.uk
|
63
64
|
executables:
|
64
65
|
- cf3samples
|
65
66
|
extensions: []
|
@@ -77,6 +78,7 @@ files:
|
|
77
78
|
- cf3ruby.gemspec
|
78
79
|
- lib/cf3.rb
|
79
80
|
- lib/cf3/version.rb
|
81
|
+
- samples/Rakefile
|
80
82
|
- samples/accident.rb
|
81
83
|
- samples/alhambra.rb
|
82
84
|
- samples/bar_code.rb
|
@@ -103,7 +105,8 @@ files:
|
|
103
105
|
- test/test_cf3.rb
|
104
106
|
homepage: http://learning-ruby-processing.blogspot.co.uk/
|
105
107
|
licenses:
|
106
|
-
-
|
108
|
+
- GPL-3.0
|
109
|
+
- LGPL-2.0
|
107
110
|
metadata: {}
|
108
111
|
post_install_message:
|
109
112
|
rdoc_options: []
|
@@ -121,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
124
|
version: '0'
|
122
125
|
requirements: []
|
123
126
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.
|
127
|
+
rubygems_version: 2.7.4
|
125
128
|
signing_key:
|
126
129
|
specification_version: 4
|
127
130
|
summary: A ruby-DSL library for CF3 sketches
|