-
Notifications
You must be signed in to change notification settings - Fork 0
/
program.ee
47 lines (47 loc) · 1.28 KB
/
program.ee
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
[
getNumber <- | message: String | -> Number [
n <- 0,
valid <- false,
while valid = false do [
number <- input message,
if (isNumber number) & (toNumber number) > 0 then [
valid <- true,
n <- toNumber number
] else print "Please try again."
],
eval n
],
maxIterations <- getNumber("Please enter the maximum number of iterations."),
width <- getNumber("Please enter the width of the render."),
height <- getNumber("Please enter the height of the render."),
py <- 0,
while py < height do [
line <- "",
px <- 0,
yScaled <- py / height * 2 - 1,
while px < width do [
xScaled <- px / width * 3.5 - 2.5,
x <- 0,
y <- 0,
i <- 0,
while i < maxIterations & x ^ 2 + y ^ 2 <= 2 ^ 2 do [
xTemp <- x ^ 2 - y ^ 2 + xScaled,
y <- 2 * x * y + yScaled,
x <- xTemp,
i <- i + 1
],
part <- maxIterations / 8,
if i > part * 7 then [ line <- line + "@" ]
else if i > part * 6 then [ line <- line + "#" ]
else if i > part * 5 then [ line <- line + "O" ]
else if i > part * 4 then [ line <- line + "!" ]
else if i > part * 3 then [ line <- line + ";" ]
else if i > part * 2 then [ line <- line + ":" ]
else if i > part then [ line <- line + "," ]
else [ line <- line + "." ],
px <- px + 1
],
print line,
py <- py + 1
]
]