-
Notifications
You must be signed in to change notification settings - Fork 0
/
lesson2.html
53 lines (44 loc) · 938 Bytes
/
lesson2.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
<HTML>
<head>
<style>
body {
background: #323232; /* Цвет фона */
}
</style>
</head>
<BODY>
<canvas id='lab02' width='700' height='400' style="border:1px solid">
</canvas>
<script>
var canvas = document.getElementById('lab02');
var ctx = canvas.getContext('2d');
var i = 50;
var j = 600;
var width = canvas.width;
var height = canvas.height;
var x = 50;
var y = 100;
function draw(imgData) {
for (var i = 1; i<100; i++) {
for (var j = 100; j>0; j--) {
var it = (i*width+j)*4;
imgData.data[it] = 255;
imgData.data[it+1] = 110;
imgData.data[it+2] = 0;
imgData.data[it+3] = 255;
// erase
it = (i*width+j -10 )*4;
imgData.data[it+3] = 0;
}
}
}
var imgData = ctx.getImageData(0, 0, width, height);
setInterval(function() {
draw(imgData)
x++;
y++
ctx.putImageData(imgData, x, y);
}, 10)
</script>
</BODY>
</HTML>