-
Notifications
You must be signed in to change notification settings - Fork 0
/
sketch.js
113 lines (96 loc) · 2.93 KB
/
sketch.js
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
const canvasSketch = require("canvas-sketch");
// For good results make width from (height * 2.1) to (height * 2.3)
const settings = {
dimensions: [720, 300],
orientation: "landscape",
units: "px",
pixelsPerInch: 300
};
const sketch = () => {
return ({ context, width, height }) => {
context.fillStyle = "green";
// Pitch
context.fillRect(0, 0, width, height);
context.fill();
context.lineWidth = width * 0.004;
context.strokeStyle = "white";
context.stroke();
// Outer Penalty line (left)
context.moveTo(0, height / 5);
context.lineTo(width * 0.122, height / 5);
context.lineTo(width * 0.122, (4 * height) / 5);
context.lineTo(0, (4 * height) / 5);
// Inner Penalty line (left)
context.moveTo(0, (1.5 * height) / 5);
context.lineTo(width * 0.073242, (1.5 * height) / 5);
context.lineTo(width * 0.073242, ((4 - 0.5) * height) / 5);
context.lineTo(0, ((4 - 0.5) * height) / 5);
// Outer Penalty line (right)
context.moveTo(width, height / 5);
context.lineTo(width - width * 0.122, height / 5);
context.lineTo(width - width * 0.122, (4 * height) / 5);
context.lineTo(width, (4 * height) / 5);
context.stroke();
// Inner Penalty line (right)
context.moveTo(width, (1.5 * height) / 5);
context.lineTo(width - width * 0.073242, (1.5 * height) / 5);
context.lineTo(width - width * 0.073242, ((4 - 0.5) * height) / 5);
context.lineTo(width, ((4 - 0.5) * height) / 5);
context.stroke();
// Big center circle
context.beginPath();
context.arc(width / 2, height / 2, height / 5, 0, Math.PI * 2, true);
context.stroke();
// Small center circle
context.beginPath();
context.arc(width / 2, height / 2, width * 0.0048828, 0, Math.PI * 2, true);
context.stroke();
// Center line
context.moveTo(width / 2, 0);
context.lineTo(width / 2, height);
context.stroke();
// Penalty half circle (left)
context.beginPath();
context.arc(
width * 0.122,
height / 2,
(0.5 * height) / 5,
Math.PI / 2,
Math.PI * 1.5,
true
);
context.stroke();
// Penalty half circle (left)
context.beginPath();
context.arc(
width - width * 0.122,
height / 2,
(0.5 * height) / 5,
Math.PI / 2,
Math.PI * 1.5,
false
);
context.stroke();
// Out line
context.moveTo(0, 0);
context.lineTo(0, height);
context.lineTo(width, height);
context.lineTo(width, 0);
context.closePath();
context.stroke();
context.font = `${width * 0.014648}px Helvetica`;
context.fillStyle = "white";
context.fillText(
"By: Abdullah Ahmed",
width - width * 0.17,
height - height * 0.0555
);
context.font = `${width * 0.008789}px Helvetica`;
context.fillText(
"https://github.com/abdullahahmeda",
width - width * 0.17,
height - height * 0.0333
);
};
};
canvasSketch(sketch, settings);