This repository has been archived by the owner on Aug 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.flashit
178 lines (170 loc) · 2.44 KB
/
example.flashit
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
;;caculate distance
(begin
(define square_sum
(lambda (x y)
(+ (* x x) (* y y))))
(define distance
(lambda (x y)
(sqrt
(square_sum
(- (px x) (px y))
(- (py x) (py y))))))
(print
(distance
(p 1 1)
(p 0 0)))
)
;;recursive
(begin
(define fact-sum
(lambda (x)
(if (= x 1)
1
(+ (self (- x 1))
((lambda (y)
(if (= y 1)
1
(* y (self (- y 1))))) x)))))
(print
(fact-sum 5))
)
;;list
(begin
(define foo
(list 1 2))
(print (++ foo foo 3))
)
;;looper
(define loop
(lambda (n f)
(if (= n 0)
1
(begin
(f)
(self (- n 1) f))))
)
;;static drawing
(begin
(place
(arc
(p 10 10)
15
0
PI)
(p 25 25))
(place
(line
(p 10 10)
(p 60 60))
(p 10 10))
(place
(circle
(p 10 10)
15)
(p 5 5))
(draw)
)
;;anime
(begin
(define loop
(lambda (n f)
(if (= n 0)
1
(begin
(f)
(self (- n 1) f)))))
(define futiao
(g
(line (p 10 10) (p 80 80))
(line (p 10 80) (p 80 10))))
(define kuang
(circle (p 45 45) 50))
(define lunzi
(g futiao kuang))
(place lunzi (p 10 10))
(loop 60
(lambda ()
(begin
(rotate futiao (* PI 0.02))
(shift lunzi (p 2 0))
(draw))))
)
;;another example
(begin
(define loop
(lambda (n f)
(if (= n 0)
1
(begin
(f)
(self (- n 1) f)))))
(define x
(g
(line (p 10 10) (p 80 80))
(line (p 10 80) (p 80 10))))
(place x (p 10 10))
(loop 60
(lambda ()
(begin
(rotate x (* PI 0.02) (p 10 10))
(draw))))
)
;;one more
(begin
(define rectangle
(lambda (a b x y)
(g
(line (p x y)
(p (+ x a) y))
(line (p x (+ y b))
(p (+ x a) (+ y b)))
(line (p x y)
(p x (+ y b)))
(line (p (+ x a) y)
(p (+ x a) (+ y b))))))
(define loop
(lambda (n f)
(if (= n 0)
1
(begin
(f)
(self (- n 1) f)))))
(define left
(rectangle 20 20 20 20))
(define right
(rectangle 20 20 50 20))
(define both
(g left right))
(place both (p 0 0))
(draw)
(loop 20
(lambda ()
(begin
(shift left (p 0 1))
(shift right (p 1 0))
(draw))))
(erase both)
(draw)
)
;;a cross shifting
(begin
(define cross
(g
(line (p 0 0)
(p 50 50))
(line (p 50 0)
(p 0 50))
(circle (p 25 25) (* 25 (sqrt 2)))))
(define loop
(lambda (n f)
(if (= n 0)
1
(begin
(f)
(draw)
(self (- n 1) f)))))
(place cross (p 0 0))
(loop 100 (lambda () (shift cross (p 1 1))))
(erase cross)
(draw)
)