"bubbles"
Bootstrap 4.0.0 Snippet by mpmsameer

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
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<html>
<body>
<canvas id="mc" width="400" height="300" style="border:1px solid black">
</canvas>
<script>
var canvas;
var ctx;
var x=400;
var y=300;
var dx=2;
var dy=4;
var width=400;
var height=300;
function circle()
{
ctx.beginPath();
ctx.fillStyle="red";
ctx.arc(x,y,30,0,Math.PI*2,true);
ctx.fill();
ctx.closePath();
}
function Clear()
{
ctx.clearRect(0,0,width,height);
}
function init()
{
canvas=document.getElementById("mc");
ctx=canvas.getContext("2d");
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
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
var canvas;
var ctx;
var x=400;
var y=300;
var dx=2;
var dy=4;
var width=400;
var height=300;
function circle()
{
ctx.beginPath();
ctx.fillStyle="red";
ctx.arc(x,y,30,0,Math.PI*2,true);
ctx.fill();
ctx.closePath();
}
function Clear()
{
ctx.clearRect(0,0,width,height);
}
function init()
{
canvas=document.getElementById("mc");
ctx=canvas.getContext("2d");
return setInterval(draw, 15);
}
function draw()
{
Clear();
circle();
if (x > width || x < 0)
dx=-dx;
if(y>height||y<0)
dy= -dy;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: