-
Notifications
You must be signed in to change notification settings - Fork 22
/
40-canvas-point-simple.html
90 lines (74 loc) · 1.84 KB
/
40-canvas-point-simple.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
#canvas {
}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<script type="text/javascript" src="../../js/mapv.js"></script>
<script type="text/javascript">
var canvas = document.querySelector('#canvas');
canvas.width = document.body.offsetWidth;
canvas.height = document.body.offsetHeight;
var ctx = canvas.getContext('2d');
var data = [
{
geometry: {
type: 'Point',
coordinates: [ctx.canvas.width * Math.random(), ctx.canvas.height * Math.random()]
},
fillStyle: 'red',
size: 30
},
{
geometry: {
type: 'Point',
coordinates: [ctx.canvas.width * Math.random(), ctx.canvas.height * Math.random()]
},
fillStyle: 'blue',
size: 20
},
{
geometry: {
type: 'Point',
coordinates: [ctx.canvas.width * Math.random(), ctx.canvas.height * Math.random()]
},
fillStyle: 'rgba(255, 255, 50, 0.5)',
size: 90
}
];
var randomCount = 300;
while (randomCount--) {
data.push({
geometry: {
type: 'Point',
coordinates: [ctx.canvas.width * Math.random(), ctx.canvas.height * Math.random()]
},
fillStyle: 'rgba(' + ~~(Math.random() * 255) + ', ' + ~~(Math.random() * 255) + ', ' + ~~(Math.random() * 255) + ', 0.8)',
size: Math.random() * 30 + 5
});
}
var dataSet = new mapv.DataSet(data);
var options = {
fillStyle: 'rgba(55, 50, 250, 0.3)',
shadowColor: 'rgba(55, 50, 250, 0.8)',
shadowBlur: 10,
draw: 'simple'
}
mapv.canvasResolutionScale(ctx);
mapv.canvasDrawSimple.draw(ctx, dataSet, options);
</script>
</body>
</html>