p3nGu1nZz commited on
Commit
7a6ace8
1 Parent(s): d4a90dc

add center white circle to the canvas

Browse files
Files changed (3) hide show
  1. index.html +33 -78
  2. plasma-arc-01.jpg +0 -0
  3. style.css +21 -14
index.html CHANGED
@@ -3,98 +3,53 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Plasma Arc Project</title>
7
- <style>
8
- @import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@700&display=swap');
9
- body { margin: 0; padding: 0; overflow: hidden; background-color: black; }
10
- </style>
11
- <script type="module">
12
- const config = {
13
- backgroundColor: 'black', font: 'Orbitron, monospace', fontSize: '16px', fontColor: 'white', name: 'Plasma Arc Project', version: 'v1.0.0',
14
- fpsFontSize: '14px', versionFontSize: '10px', canvasId: 'plasma-arc-canvas', padding: 10
15
- };
16
-
17
- const state = {
18
- fpsX: config.padding * 7, fpsY: config.padding, nameX: null, nameY: null, versionY: null, lastFrameTime: 0, fps: 0, smoothFPS: 0
19
- };
20
-
21
- function lerp(start, end, amount) {
22
- return start + (end - start) * amount;
23
- }
24
-
25
- function createCanvas() {
26
- const canvas = document.createElement('canvas');
27
- canvas.id = config.canvasId;
28
- document.body.appendChild(canvas);
29
- return canvas;
30
- }
31
 
32
- function initializeCanvas(canvas, context) {
33
- resizeCanvas(canvas);
34
- fillCanvasWithColor(canvas, context);
35
- updateTextPositions(canvas);
36
- }
37
 
38
- function resizeCanvas(canvas) {
39
  canvas.width = window.innerWidth;
40
  canvas.height = window.innerHeight;
41
- }
42
-
43
- function fillCanvasWithColor(canvas, context) {
44
- context.fillStyle = config.backgroundColor;
45
  context.fillRect(0, 0, canvas.width, canvas.height);
46
  }
47
 
48
- function updateTextPositions(canvas) {
49
- state.nameX = canvas.width - config.padding;
50
- state.nameY = canvas.height - config.padding * 2;
51
- state.versionY = canvas.height - config.padding;
52
- }
53
 
54
- function drawText(context, text, x, y, fontSize, textAlign, textBaseline) {
55
- context.font = `${fontSize} ${config.font}`;
56
- context.fillStyle = config.fontColor;
57
- context.textAlign = textAlign;
58
- context.textBaseline = textBaseline;
59
- context.fillText(text, x, y);
60
  }
61
 
62
- function formatFPS(fps) {
63
- return Math.round(fps);
 
 
 
 
64
  }
65
 
66
- function main() {
67
- document.body.style.margin = 0;
68
- document.body.style.padding = 0;
69
-
70
- const canvas = createCanvas();
71
- const context = canvas.getContext('2d');
72
- initializeCanvas(canvas, context);
73
-
74
- function tick(currentTime) {
75
- const deltaTime = (currentTime - state.lastFrameTime) / 1000;
76
- state.lastFrameTime = currentTime;
77
- const currentFPS = 1 / deltaTime;
78
-
79
- state.smoothFPS = lerp(state.smoothFPS, currentFPS, 0.1);
80
-
81
- context.clearRect(0, 0, canvas.width, canvas.height);
82
- fillCanvasWithColor(canvas, context);
83
-
84
- drawText(context, `${formatFPS(state.smoothFPS)} fps`, state.fpsX, state.fpsY, config.fpsFontSize, 'right', 'top');
85
- drawText(context, config.name, state.nameX, state.nameY, config.fontSize, 'right', 'bottom');
86
- drawText(context, config.version, state.nameX, state.versionY, config.versionFontSize, 'right', 'bottom');
87
-
88
- requestAnimationFrame(tick);
89
- }
90
-
91
- window.addEventListener('resize', () => initializeCanvas(canvas, context));
92
- requestAnimationFrame(tick);
93
  }
94
 
95
- window.addEventListener('DOMContentLoaded', main);
 
 
96
  </script>
97
- </head>
98
- <body>
99
  </body>
100
  </html>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Minimalist White Circle</title>
7
+ <link rel="stylesheet" href="style.css">
8
+ </head>
9
+ <body>
10
+ <canvas id="canvas"></canvas>
11
+ <script>
12
+ const canvas = document.getElementById('canvas');
13
+ const context = canvas.getContext('2d');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
+ const versionText = 'v1.0.0';
 
 
 
 
16
 
17
+ function initializeCanvas() {
18
  canvas.width = window.innerWidth;
19
  canvas.height = window.innerHeight;
20
+ context.fillStyle = 'black';
 
 
 
21
  context.fillRect(0, 0, canvas.width, canvas.height);
22
  }
23
 
24
+ function drawWhiteCircle() {
25
+ const centerX = canvas.width / 2;
26
+ const centerY = canvas.height / 2;
27
+ const radius = Math.min(canvas.width, canvas.height) * 0.0125; // 1.25% of the smaller dimension
 
28
 
29
+ context.beginPath();
30
+ context.arc(centerX, centerY, radius, 0, 2 * Math.PI);
31
+ context.strokeStyle = 'white';
32
+ context.lineWidth = 0.25 * parseFloat(getComputedStyle(document.documentElement).fontSize); // 0.25em stroke
33
+ context.stroke();
 
34
  }
35
 
36
+ function drawVersionText() {
37
+ context.font = '1em Arial';
38
+ context.fillStyle = 'white';
39
+ context.textAlign = 'right';
40
+ context.textBaseline = 'bottom';
41
+ context.fillText(versionText, canvas.width - 10, canvas.height - 10);
42
  }
43
 
44
+ function draw() {
45
+ initializeCanvas();
46
+ drawWhiteCircle();
47
+ drawVersionText();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  }
49
 
50
+ draw();
51
+
52
+ window.addEventListener('resize', draw);
53
  </script>
 
 
54
  </body>
55
  </html>
plasma-arc-01.jpg ADDED
style.css CHANGED
@@ -1,28 +1,35 @@
1
  body {
2
- padding: 2rem;
3
- font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
 
4
  }
5
 
6
  h1 {
7
- font-size: 16px;
8
- margin-top: 0;
9
  }
10
 
11
  p {
12
- color: rgb(107, 114, 128);
13
- font-size: 15px;
14
- margin-bottom: 10px;
15
- margin-top: 5px;
16
  }
17
 
18
  .card {
19
- max-width: 620px;
20
- margin: 0 auto;
21
- padding: 16px;
22
- border: 1px solid lightgray;
23
- border-radius: 16px;
24
  }
25
 
26
  .card p:last-child {
27
- margin-bottom: 0;
 
 
 
 
 
 
28
  }
 
1
  body {
2
+ padding: 0;
3
+ margin: 0;
4
+ font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
5
  }
6
 
7
  h1 {
8
+ font-size: 10em;
9
+ margin-top: 0;
10
  }
11
 
12
  p {
13
+ color: rgb(107, 114, 128);
14
+ font-size: 1em;
15
+ margin-bottom: 10px;
16
+ margin-top: 5px;
17
  }
18
 
19
  .card {
20
+ max-width: 620px;
21
+ margin: 0 auto;
22
+ padding: 16px;
23
+ border: 1px solid lightgray;
24
+ border-radius: 16px;
25
  }
26
 
27
  .card p:last-child {
28
+ margin-bottom: 0;
29
+ }
30
+
31
+ canvas {
32
+ display: block;
33
+ margin: 0 auto;
34
+ background-color: black;
35
  }