]> gitweb.factorcode.org Git - factor.git/blob - unmaintained/cfdg/models/lesson/lesson.factor
tools.test: Make the flag public. Finish porting tester changes to fuzzer.
[factor.git] / unmaintained / cfdg / models / lesson / lesson.factor
1
2 USING: kernel namespaces math opengl.gl opengl.glu ui ui.gadgets.slate
3        random-weighted cfdg ;
4
5 IN: cfdg.models.lesson
6
7 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
8
9 : shapes ( -- )
10 [            square ]   do
11 [ 0.3 b      circle ]   do
12 [ 0.5 b      triangle ] do
13 [ 0.7 b 60 r triangle ] do ;
14
15 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16
17 : chapter-1 ( -- )
18 [ 2 x 5 y 3 size square ] do
19 [ 6 x 5 y 3 size circle ] do
20 [ 4 x 2 y 3 size triangle ] do
21 [     1 y 3 size shapes ] do ;
22
23 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
24
25 : foursquare ( -- )
26 [ 0 x 0 y 5 3 size* square ] do
27 [ 0 x 5 y 2 4 size* square ] do
28 [ 5 x 5 y   3 size  square ] do
29 [ 5 x 0 y   2 size  square ] do ;
30
31 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
32
33 : chapter-2 ( -- )
34 [ square ] do
35 [ 3 x 7 y square ] do
36 [ 5 x 7 y 30 r square ] do
37 [ 3 x 5 y 0.75 size square ] do
38 [ 5 x 5 y 0.5 b square ] do
39 [ 7 x 6 y 45 r 0.7 size 0.7 b square ] do
40 [ 5 x 1 y 10 r 0.2 size foursquare ] do ;
41
42 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
43
44 : spiral ( -- )
45 iterate? [
46   [ 0.5 size circle ] do
47   [ 0.2 y -3 r 0.995 size spiral ] do
48 ] when ;
49
50 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
51
52 : chapter-3 ( -- ) [ 0 x 3 y spiral ] do ;
53
54 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
55
56 DEFER: tree
57
58 : branch-left ( -- )
59 { { 1 [ 20 r tree ] }
60   { 1 [ 30 r tree ] }
61   { 1 [ 40 r tree ] }
62   { 1 [ ] } } random-weighted* do ;
63
64 : branch-right ( -- )
65 { { 1 [ -20 r tree ] }
66   { 1 [ -30 r tree ] }
67   { 1 [ -40 r tree ] }
68   { 1 [ ] } } random-weighted* do ;
69
70 : branch ( -- ) branch-left branch-right ;
71
72 : tree ( -- )
73 iterate? [
74   { 
75     { 20  [ [ 0.25 size circle ] do
76             [ 0.1 y 0.97 size tree ] do ] }
77     { 1.5 [ branch ] }
78   } random-weighted* do
79 ] when ;
80
81 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
82
83 : chapter-4 ( -- )
84 [ 1 x 0 y tree ] do
85 [ 6 x 0 y tree ] do
86 [ 1 x 4 y tree ] do
87 [ 6 x 4 y tree ] do ;
88
89 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
90
91 : toc ( -- )
92 [ 0  x   0 y chapter-1 ] do
93 [ 10 x   0 y chapter-2 ] do
94 [ 0  x -10 y chapter-3 ] do
95 [ 10 x -10 y chapter-4 ] do ;
96
97 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
98
99 : init ( -- )
100   [ ]              >background
101   { -5 25 -15 25 } >viewport
102   0.03             >threshold
103   [ toc ]          >start-shape ;
104
105 : run ( -- ) [ init ] cfdg-window. ;
106
107 MAIN: run
108