forked from PencilCode/jquery-turtle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfern.html
More file actions
45 lines (42 loc) · 818 Bytes
/
fern.html
File metadata and controls
45 lines (42 loc) · 818 Bytes
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
<script src="lib/qunit.js"></script>
<link href="lib/qunit.css" rel="stylesheet">
<script src="lib/jquery.js"></script>
<script src="../jquery-turtle.js"></script>
<body>
<div id="qunit"></div>
<script>
eval($.turtle());
$.turtle.hangtime = Infinity; // Allow for slow CPUs.
module("Fern test.");
asyncTest("Draws a fractal and verifies its shape.", function() {
speed(Infinity);
function fern(x) {
if (x > 1) {
fd(x);
rt(95);
fern(x * .4);
lt(190);
fern(x * .4);
rt(100);
fern(x * .8);
lt(5);
bk(x);
}
}
bk(100);
pen(green);
fern(50);
pen(null);
ok(touches(green));
fd(200);
ok(touches(green));
fd(10);
ok(!touches(green));
rt(90);
fd(70);
ok(touches(green));
fd(5);
ok(!touches(green));
done(start);
});
</script>