File: lesson2.cfdg

package info (click to toggle)
contextfree 3.4.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,448 kB
  • sloc: cpp: 37,995; lex: 414; makefile: 123; sh: 43; python: 34
file content (190 lines) | stat: -rw-r--r-- 3,443 bytes parent folder | download | duplicates (4)
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
/* CFDG Lesson */

startshape TOC

shape TOC
{
    CHAPTER5 [ x 0 y 0 ]
    CHAPTER6 [ x 10 y 0 ]
    CHAPTER7 [ x 0 y -10 ]
    CHAPTER8 [ x 10 y -10 ]

    TITLES [ ]
}

shape CHAPTER5
{
    ## SKEW TRANSFORM ##
    SierpinskiTri [ x 2 y 4 size 6.0 ]
    SQUARE [ x 0.5 y 5.5 skew 15 15 size 2 ]
	// a skew transform (also called 
	// a shear) pushes a shape parallel
	// to the x axis or y axis or both.
	// The two numbers following
}

shape SierpinskiTri
{
	polygonRightTriangle [ ]
	hole [ b 1 ]
}

shape hole
{
	polygonRightTriangle [ size -0.495 x 0.25 y -0.25 ]
	hole [ b -0.2 size 0.5 x -0.25 y -0.25 ]
	hole [ b -0.2 size 0.5 x  0.25 y -0.25 ]
	hole [ b -0.2 size 0.5 x  0.25 y  0.25 ]
}

shape polygonRightTriangle
{
	TRIANGLE [[ size 1 1.155 x 0.165 y -0.144 skew 30 0 ]]
}

shape CHAPTER6
 {
    ## FLIP TRANSFORM ##
    HEART [ x 2 y 1 size 0.12 0.1]
	// A flip transform reflects a 
	// shape across a line at the
	// specified angle. 
}

import i_curves.cfdg

shape HEART
{
    curveright_0_99_1 [ r 64 ]
    curveright_0_99_1 [ flip 90 r -64 ]
    HEART [ s 0.9 y 2.5 ]
}

shape CHAPTER7
{
    ## TRANSFORM ORDERING ##
    TranSquare [ s 0.5 x 1 y 5 ]
    TranCircle [ s 0.5 x 1 y 3 ]
    TranTriangle [ s 0.5 x -1 y 1 ]
    SquareLine [ x -1 y 7 ]
	// When transforms are in curly
	// braces then they are applied
	// in a fixed order:
	// 1) Translate
	// 2) Rotate
	// 3) Scale
	// 4) Skew
	// 5) Reflect
	// Only one transform of each 
	// type is allowed (all but the 
	// last are ignored).

	// When transforms are in square
	// braces then they are applied
	// in the order they are found
	// and there can be multiple
	// occurrences of a given type
	// of transform.
}

shape TranSquare
{
    SQUARE [[ r 45 x 4 s 3 ]]
    SQUARE [[ b 0.2 x 4 s 3 ]]
    SQUARE [[ b 0.4 x 4 ]]
    SQUARE [[ b 0.7 ]]
	// Ordering a rotate before a
	// translate (x or y) causes the
	// translate to be rotated. This
	// saves
}
shape TranCircle
{
    Ellipse [[ x 4 r 45 s 3 ]]
    Ellipse [[ b 0.2 r 45 s 3 ]]
    Ellipse [[ b 0.4 s 3  ]]
    Ellipse [[ b 0.7 ]]
	// This happens to be the order
	// that CF uses when the transforms
	// are enclosed in curly braces.
}
shape TranTriangle
{
    TRIANGLE [[ s 3 x 4 r 45 ]]
    TRIANGLE [[ b 0.2 x 4 r 45 ]]
    TRIANGLE [[ b 0.4 r 45 ]]
    TRIANGLE [[ b 0.7 ]]
	// Putting the scale before the
	// translate scales the translate
	// as well
}
shape SquareLine
{
	SQUARE []
	SquareLine [[ y -0.5 s 0.75 y -0.5 ]]
	// Transforms can be specified
	// more than once and subsequent
	// transforms are modified by the
	// ones before them. In the above 
	// idiom the squares are always
	// just touching, even when you
	// change the scale amount.
}
shape Ellipse
{
	CIRCLE [ s 1 0.5 ]
}



shape CHAPTER8
 {
    ## COLOR ##
	// Coming soon.
}



## Utilities ##
import i_pix.cfdg
// The "include" statement reads
// in all the rules from another file.
// Any "startshape" in the included
// file is ignored.

shape TITLES
{
	TITLE5 [ x 0 y 8.5 ]
	TITLE6 [ x 10 y 8.5 ]
	TITLE7 [ x 0 y -1.5 ]
	TITLE8 [ x 10 y -1.5 ]
}
shape TITLE5
{
	F_5by5 [ x 0 ]
	I_5by5 [ x 1.2 ]
	V_5by5 [ x 2.4 ]
	E_5by5 [ x 3.6 ]
}
shape TITLE6
{
	S_5by5 [ x 0 ]
	I_5by5 [ x 1.2 ]
	X_5by5 [ x 2.4 ]
}
shape TITLE7
{
	S_5by5 [ x 0 ]
	E_5by5 [ x 1.2 ]
	V_5by5 [ x 2.4 ]
	E_5by5 [ x 3.6 ]
	N_5by5 [ x 4.8 ]
}
shape TITLE8
{
	E_5by5 [ x 0 ]
	I_5by5 [ x 1.2 ]
	G_5by5 [ x 2.4 ]
	H_5by5 [ x 3.6 ]
	T_5by5 [ x 4.8 ]
}