PageRenderTime 10ms CodeModel.GetById 1ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/examples/cfdg/models/game1-turn6/source.scm

http://github.com/dharmatech/abstracting
Scheme | 90 lines | 59 code | 29 blank | 2 comment | 0 complexity | 0a0f955ef2252744577b4b63913ee6ba MD5 | raw file
 1
 2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 3
 4(define (f-triangles)
 5  
 6  (when (iterate?)
 7
 8        (block
 9         (lambda ()
10           (x 0.1)
11           (y 0.1)
12           (alpha -0.33)
13           (hue 20)
14           (saturation 0.7)
15           (brightness 0.80)
16           (triangle)))
17
18        (block (lambda () (hue 10) (saturation 0.9) (brightness 0.33) (triangle)))
19
20        (block
21         (lambda ()
22           (size 0.9)
23           (hue 10)
24           (saturation 0.5)
25           (brightness 1.00)
26           (triangle)))
27
28        (block (lambda () (size 0.8) (rotate 5) (f-triangles)))))
29
30(define (f-squares)
31
32  (when (iterate?)
33
34        (block
35         (lambda ()
36           (x 0.1)
37           (y 0.1)
38           (alpha -0.33)
39           (hue 250)
40           (saturation 0.70)
41           (brightness 0.80)
42           (square)))
43
44        (block (lambda () (hue 220) (saturation 0.90) (brightness 0.33) (square)))
45
46        (block
47         (lambda ()
48           (size 0.9)
49           (hue 220)
50           (saturation 0.25)
51           (brightness 1.00)
52           (square)))
53
54        (block (lambda () (size 0.8) (rotate 5) (f-squares)))))
55
56(define (spiral)
57
58  (when (iterate?)
59
60        (call-random-weighted
61
62         (vec
63
64          (vec 1 (lambda ()
65
66                   (block (lambda () (f-squares)))
67
68                   (block (lambda () (x 0.5) (y 0.5) (rotate 45) (f-triangles)))
69
70                   (block (lambda () (y 1.0) (rotate 25) (size 0.9) (spiral)))))
71
72          (vec 0.022 (lambda ()
73                       (block (lambda () (flip 90) (hue 50) (start)))))))))
74
75(define (start)
76  (block (lambda ()              (spiral)))
77  (block (lambda () (rotate 120) (spiral)))
78  (block (lambda () (rotate 240) (spiral))))
79
80(set! *background* (lambda () (hue 66) (saturation 0.4) (brightness 0.5)))
81
82(set! *viewport* (vec -5 10 -5 10))
83
84(set! *threshold* 0.001)
85
86(set! *start-shape* (lambda () (start)))
87
88;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
89
90(run-model)