-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpstair_viewer.cfdg
199 lines (198 loc) · 5.17 KB
/
pstair_viewer.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
//-------------------------------------------------------//
// THE INFINITY-STAIRCASE VIEWER (CFDG) //
// (c) and written 2022 by F. Lehr / flx //
// For more info visit https://www.ferdinandlehr.de //
// https://github.com/fl3000/Penrose-Staircase-Generator //
// https://www.contextfreeart.org //
// This code is Creative Commons licensed: //
// Creative Commons Attribution-NonCommercial- //
// ShareAlike 4.0 International: //
// https://creativecommons.org/licenses/by-nc-sa/4.0/ //
//-------------------------------------------------------//
CF::Impure=1
//----------------- PLAYAROUND-AREA ---------------------//
COLOR1 = [b 0.007 sat 0.5 h 0]
COLOR2 = [b 0.5 sat 0.5 h 150]
COLOR3 = [b 1 sat 0.2 h 200]
// R = 3,2,2,3,6 // Smallest Staircase
R = 6,3,3,6,4.66666 // Penrose-Staircase 1958
// R = 24,6,14,16,5.6 // For Reutersvard and Escher
// R = 15,2,5,12,3 // Castle of the Wizards
// R = 17,17,10,24,9.14285 // Large Antique Arena
// R = 100,66,67,99,9.93939 // Chinese Wall
// For more ratios read the CSV-File(s) at GitHub:
// https://github.com/fl3000/Penrose-Staircase-Generator
//-------------------------------------------------------//
U = 1
H = 0.866025404
L = R[4]
A=R[0]
B=R[1]
C=R[2]
D=R[3]
WH = D*2
startshape PAGE
shape PAGE {
PSTAIR[skew 2 6 r -30]
}
shape PSTAIR {
loop i=A-1,-1,-1 [] {
S(L)[x ((U*0.5*L)*i+(U/2)*i) y (((H*L)-H)*i)]
}
loop m=1,D-1,1 [] {
xx1 = ((U*0.5*L)*(A-1)+(U/2)*(A-1)+(L*1+U/2)*(B-1))
yy1 = (((H*L)-H)*(A-1)-(B-1)*H)
xxx1 = (xx1-L*U*0.5*(C-1)+(U/2)*(C-1))
yyy1 = (yy1-(C-1)*H*(L+1))
S(L)[x (xxx1-L*U*m+(U/2)*m) y (yyy1-H*m) z (-m+A+B+C+D+1)]
}
loop j=1,B,1 [] {
S(L)[x ((U*0.5*L)*(A-1)+(U/2)*(A-1)+(L*1+U/2)*j) y (((H*L)-H)*(A-1)-j*H)]
}
loop k=1,C,1 [] {
xx1 = ((U*0.5*L)*(A-1)+(U/2)*(A-1)+(L*1+U/2)*(B-1))
yy1 = (((H*L)-H)*(A-1)-(B-1)*H)
S(L)[x (xx1-L*U*0.5*k+(U/2)*k) y (yy1-k*H*(L+1)) z (A+B+C+D+2)]
}
inner_wall2[]
front_wall[z (A+B+C+D+3)]
mid_wall2[]
right_wall[]
loop n=2,B,1 [] {
px = ((U*0.5*L)*(A-1)+(U/2)*(A-1)) + L*U*n + (n-1)*(U/2)
py = (((H*L)-H)*(A-1))-H*(n-1)
stair_rect_C[x px y py]
}
loop o=1,C-1,1 [] {
px = ((U*0.5*L)*(A-1)+(U/2)*(A-1)) + L*U*B + (B-1)*(U/2) - L*U
py = (((H*L)-H)*(A-1))-H*(B-1)
stair_rect_D[x (px-L*U*0.5*o+(U/2)*o) y (py-(L+1)*H*o)]
}
}
path stair_rect_D {
MOVETO(0,0)
LINETO(U*L,0)
LINEREL(U/2,-H)
LINEREL(-U*L,0)
CLOSEPOLY()
FILL()[trans COLOR1]
STROKE(0.1, CF::RoundJoin)[]
}
path stair_rect_C {
MOVETO(0,0)
LINETO(U*L*0.5,H*L)
LINEREL(U/2,-H)
LINEREL(-U*L*0.5,-H*L)
CLOSEPOLY()
FILL()[trans COLOR2]
STROKE(0.1, CF::RoundJoin)[]
}
path stairlinesC {
MOVETO(0,0)
MOVEREL(L*U*0.5+U*2*A+L+(L/3)+U/2,H*L+H*2*(A-1)-H)
loop i=0,(B-2),1 [] {
MOVEREL(U/2,-H)
MOVEREL(-L*U*0.5,-H*3)
MOVEREL(-U/2,H)
MOVEREL(L*U*0.5,H*L)
MOVEREL(U*0.5+L,-H)
}
MOVEREL(-L-U*1.5,-H*L)
MOVEREL(U/2,-H)
MOVEREL(-U*0.5*L,-H*L)
loop j=0,(C-2),1 [] {
LINEREL(U*0.5,-H)
MOVEREL(-L*U*0.5,-H*L)
}
FILL()[b 1]
STROKE(0.1, CF::RoundJoin)[]
}
path stairlinesB {
MOVETO(0,0)
MOVEREL(L*U*0.5+U*2*A+L+(L/3)+U/2,H*L+H*2*(A-1)-H)
loop i=0,(B-2),1 [] {
LINEREL(U/2,-H)
MOVEREL(-L*U*0.5,-H*3)
LINEREL(-U/2,H)
MOVEREL(L*U*0.5,H*L)
MOVEREL(U*0.5+L,-H)
}
FILL()[b 1]
STROKE(0.1, CF::RoundJoin)[]
}
path mid_wall2 {
MOVEREL(L*U+L*U*0.5+U/2,H*L-H)
loop n=1,A,1 [] {
LINEREL(L*U*0.5,H*L)
LINEREL(U*0.5,-H)
}
LINEREL(-L*0.5*U,-H*L)
LINEREL(U*WH*0.5,-H*WH)
LINEREL(-U*0.5*L*(C-1),-H*L*(C-1))
CLOSEPOLY()
FILL()[trans COLOR2]
STROKE(0.1, CF::RoundJoin)[]
}
path inner_wall2 {
MOVEREL(L*U+L*U*0.5+U/2,H*L-H)
loop n=1,A,1 [] {
MOVEREL(L*U*0.5,H*L)
MOVEREL(U*0.5,-H)
}
MOVEREL(-L*0.5*U,-H*L)
loop m=1,B-1,1 [] {
LINEREL(L*U,0)
LINEREL(U*0.5,-H)
}
LINEREL(L,0)
LINEREL(U*0.5,-H)
LINEREL(-L,0)
LINEREL(U*WH*0.5-(B*U*0.5),-H*WH+H*B)
LINEREL(-L*U*(B-2)+U*0.5,-H)
CLOSEPOLY()
FILL()[trans COLOR1]
STROKE(0.1, CF::RoundJoin)[]
}
path right_wall {
MOVETO(0,0)
loop i=1,(D),1 [] {
MOVEREL(L,0)
MOVEREL(-U*0.5,H)
}
MOVEREL(L,0)
loop i=1,C,1 [] {
LINEREL(L*U*0.5,H*L)
LINEREL(-U*0.5,H)
}
LINEREL(L*U*0.5,H*L)
loop j=1,C,1 [] {
LINEREL(U*0.5,-H)
}
LINEREL(U*WH*0.5,-H*WH)
LINEREL(-U*0.5*L*C,-H*L*C)
CLOSEPOLY()
FILL()[trans COLOR2]
STROKE(CF::RoundJoin)[]
}
path front_wall {
MOVETO(0,0)
loop i=1,(D),1 [] {
LINEREL(L,0)
LINEREL(-U*0.5,H)
}
LINEREL(L,0)
LINEREL(U*WH*0.5,-H*WH)
LINEREL(-U*D*L,0)
CLOSEPOLY()
FILL()[trans COLOR1]
STROKE(CF::RoundJoin)[]
}
path S(l) {
MOVETO(0,0)
LINETO(U*0.5*l,H*l)
LINETO(U*0.5*l+U*l,H*l)
LINETO(U*l,0)
CLOSEPOLY()
FILL()[trans COLOR3]
STROKE(CF::RoundJoin)[]
}