-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
76 lines (67 loc) · 2.19 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Canvas tutorial</title>
<style type="text/css">
canvas { border: 3px solid black; }
</style>
</head>
<body onload="draw();">
<canvas id="malowanie" width="550" height="550"></canvas>
<script type="text/javascript">
function draw() {
var canvas = document.getElementById('malowanie');
if (canvas.getContext) {
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgb(200, 100, 0)';
ctx.fillRect(5,5,140,140);
ctx.clearRect(45,45,60,60);
ctx.strokeRect(50,50,50,50);
// Quadratric curves example
ctx.fillStyle = 'rgb(200, 0, 0)';
ctx.beginPath();
ctx.moveTo(75,40);
ctx.bezierCurveTo(75,37,70,25,50,25);
ctx.bezierCurveTo(20,25,20,62.5,20,62.5);
ctx.bezierCurveTo(20,80,40,102,75,120);
ctx.bezierCurveTo(110,102,130,80,130,62.5);
ctx.bezierCurveTo(130,62.5,130,25,100,25);
ctx.bezierCurveTo(85,25,75,37,75,40);
ctx.fill();
ctx.beginPath();
ctx.arc(75,75,50,0,Math.PI*2,true); // Outer circle
ctx.moveTo(110,75);
ctx.arc(75,75,35,0,Math.PI,false); // Mouth (clockwise)
ctx.moveTo(65,65);
ctx.arc(60,65,5,0,Math.PI*2,true); // Left eye
ctx.moveTo(95,65);
ctx.arc(90,65,5,0,Math.PI*2,true); // Right eye
ctx.stroke();
ctx.fillStyle = 'rgb(200, 0, 0)';
for(var i=0;i<6;i++){
for(var j=0;j<6;j++){
ctx.beginPath();
var x = 195+j*50; // x coordinate
var y = 165+i*50; // y coordinate
var radius = 20; // Arc radius
var startAngle = 0; // Starting point on circle
var endAngle = Math.PI+(Math.PI*j)/2; // End point on circle
var anticlockwise = i%2==0 ? false : true; // clockwise or anticlockwise
ctx.fillStyle = 'rgb(' + Math.floor(255 - 42.5 * i) + ', ' +
Math.floor(255 - 42.5 * j) + ', 0)';
ctx.strokeStyle = 'rgb(0, ' + Math.floor(255 - 42.5 * i) + ', ' +
Math.floor(255 - 42.5 * j) + ')';
ctx.arc(x, y, radius, startAngle, endAngle, anticlockwise);
if (i%2==1){
ctx.fill();
} else {
ctx.stroke();
}
}
}
}
}
</script>
</body>
</html>