-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.cfdg
132 lines (113 loc) · 2.31 KB
/
lib.cfdg
1
2
3
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
//╺┳╸┏━╸╺┳┓╺┳┓╻ ╻╺┳┓╺┳┓ ╻ ╻┏┓
// ┃ ┣╸ ┃┃ ┃┃┗┳┛ ┃┃ ┃┃ ┃ ┃┣┻┓
// ╹ ┗━╸╺┻┛╺┻┛ ╹ ╺┻┛╺┻┛ ┗━╸╹┗━┛
shape Grid(shape Shp, number Size, number Separation) {
loop Size [x Separation]
loop Size [y Separation]
Shp []
}
shape Quad(shape Shp, number Shift) {
Shp [x -Shift y Shift]
Shp [x -Shift y -Shift]
Shp [x Shift y -Shift]
Shp [x Shift y Shift]
}
shape Maybe(shape Shp)
rule { Shp [] }
rule {}
shape Rotated(shape Shp)
rule {
Shp []
}
rule {
Shp [r 90]
}
rule {
Shp [r -90]
}
rule {
Shp [r 180]
}
shape Shifted(shape Shp, number Minoff, number Maxoff)
rule {
Shp [x Minoff..Maxoff]
}
rule {
Shp [y Minoff..Maxoff]
}
rule {
Shp [x -Minoff..-Maxoff]
}
rule {
Shp [y -Minoff..-Maxoff]
}
shape Flipped(shape Shp)
rule {
Shp [s 1 -1]
}
rule {
Shp [s -1 1]
}
rule {
Shp [s -1 -1]
}
shape Or(shape One, shape Two)
rule {
One []
}
rule {
Two []
}
shape Tree(shape Shp, number Offset, number Rot, number Scal) {
Shp []
Tree(=) [y Offset r Rot s Scal]
Tree(=) [y Offset r -Rot s Scal]
}
// Any basic shape
shape Basic
rule { SQUARE [] }
rule { CIRCLE [] }
rule { TRIANGLE [] }
// Ring that keeps initial rotation of a shape
shape RingKeep(shape Shp, number Rad, number Count){
deg = 360 / Count
loop i=Count [r deg]
Shp [[x Rad r (i * -deg)]]
}
// Ring that rotates shapes outwards
shape RingOut(shape Shp, number Rad, number Count){
deg = 360 / Count
loop i=Count []
Shp [[r (deg * i) y Rad]]
}
// Percentage filter, useful for non transparent, constant shapes
// Does not give exact results, based on probability
shape Pass(number N, shape Shp) {
loop N []
OnePercent (Shp) []
}
shape OnePercent(shape Shp)
rule 1% { Shp [] }
rule {}
// Colors
shape Grayscale(shape Shp) {
Shp [b 1..-1]
}
// Paths
path LINE(number Width) {
MOVETO( 0, 0.5 )
LINETO( 0, -0.5 )
STROKE(Width, CF::SquareCap) []
}
path ARC(number Width) {
MOVETO(-0.5, -0.5)
ARCTO( 0.5, 0.5, 1)
STROKE(Width, CF::SquareCap) []
}
path ANGLE(number Width) {
MOVETO(-0.5, 0.5)
LINETO(-0.5, 0.5)
LINETO(-0.5, -0.5)
LINETO( 0.5, -0.5)
STROKE(Width, CF::SquareCap) []
}