-
Notifications
You must be signed in to change notification settings - Fork 0
/
draw_tester.html
73 lines (60 loc) · 1.04 KB
/
draw_tester.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
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<html>
<head>
<title>Michelle Rittner</title>
</head>
<body>
<canvas id="myCanvas" width="820" height="800">
<!-- Insert fallback content here -->
Sorry, your browser doesn't support canvas technology
</canvas>
<script type="text/javascript">
var canvas;
var ctx;
var x = 400;
var y = 200;
var mx = 2;
var my = 0;
var WIDTH = 620;
var HEIGHT = 800;
var a = 300;
var b = 200;
function init() {
canvas = document.getElementById("myCanvas");
ctx = canvas.getContext("2d");
return setInterval(draw, 30);
}
init();
function square(x,y,s)
{
ctx.beginPath();
ctx.fillRect(x,y,s,s)
}
function draw() {
//circle(x, y, 5);
square(x, y, 5)
square(a, b, 5)
/*
if (x + mx > WIDTH || x + mx < 0)
mx = -mx;
if (y + my > HEIGHT || y + my < 0)
my = -my;
*/
if (x + mx >= WIDTH )
{
mx = 0;
my = 2;
}
if ( y + my >= HEIGHT)
{
mx =0;
my = 0;
}
a -= mx;
b += my;
x += mx;
y += my;
}
</script>
</body>
</html>