-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
61 lines (49 loc) · 1.76 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<!-- <link rel="stylesheet" href="style.css"> -->
<script src="compiled.js" defer=""></script>
</head>
<body>
<canvas id="canvas" width="256px" height="256px" style="width:512px; height:512px;"></canvas>
<textarea id="code" style="width:512px; height:512px;">
: if ( test q1 q2 -- ) ? call ;
: - ( x y -- x-y ) -1 * + ;
: 2drop ( x y -- ) drop drop ;
: over ( x y -- x y x ) [ dup ] dip swap ;
: -rot ( x y z -- z x y ) rot rot ;
: 2dup ( x y - x y x y ) over over ;
: 3dup ( x y z - x y z x y z ) [ 2dup ] dip dup [ -rot ] dip ;
: 2dip ( x y q -- x y ) swap [ dip ] dip ;
: 3dip swap [ 2dip ] dip ;
: keep ( x q -- qresult x ) [ dup ] dip dip ;
: 2keep [ 2dup ] dip 2dip ;
: 3keep [ 3dup ] dip 3dip ;
: bi ( x q1 q2 -- ) [ keep ] dip call ;
: 2bi ( x y q1 q2 -- ) [ 2keep ] dip call ;
: 3bi ( x y z q1 q2 -- ) [ 3keep ] dip call ;
: rotate-x ( angle y x - x ) -rot over cos * -rot sin * - ;
: rotate-y ( angle y x - x ) -rot over sin * -rot cos * + ;
: grey ( g - r g b ) dup dup ;
: bi@ ( x.. y.. q -- x y ) dup dip dip ;
: scale ( x -- x' ) 255 * ;
: slower ( x -- x' ) 0.01 * ;
: cycle ( x -- x' ) 255 mod ;
: draw ( t y x -- r g b ) * * 0.00001 * sin 255 * grey ;
(
: draw rot rotate swap dup slower cycle rotate grey ;
)
: draw [ slower ] 2dip [ rotate-x ] [ drop swap drop ] 3bi xor grey ;
: draw [ slower ] 2dip [ rotate-x ] [ rotate-y ] 3bi xor grey ;
: loop 2dup [ call ] 3dip [ swap rot ] dip [ 2drop ] if ;
: draw
[ slower ] 2dip ( time )
[ slower sin scale ] dip ( y )
slower cos scale ( x )
[ rotate-x ] [ rotate-y ] 3bi xor grey ;
</textarea>
<div id="output"></div>
</body>
</html>