-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
144 lines (133 loc) · 4.73 KB
/
index.html
File metadata and controls
144 lines (133 loc) · 4.73 KB
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Base is for...</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@800&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Inter', sans-serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
background-color: white;
color: black;
}
h1 {
font-size: 48px;
font-weight: 800;
margin-bottom: 20px;
}
input {
font-size: 24px;
padding: 10px;
margin-bottom: 20px;
border: 2px solid black;
background-color: white;
color: black;
text-align: center;
font-weight: 800;
}
button {
font-size: 24px;
padding: 10px 20px;
background-color: white;
color: black;
border: 2px solid black;
cursor: pointer;
font-weight: 800;
}
button:hover {
background-color: #e0e0e0;
}
canvas {
margin-top: 20px;
}
a {
font-size: 24px;
color: #007bff;
text-decoration: none;
margin-top: 20px;
font-weight: 800;
}
a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<h1>Base is for...</h1>
<input type="text" id="customWord" placeholder="Enter a word">
<button onclick="generateImage()">Generate</button>
<canvas id="canvas" width="600" height="400"></canvas>
<a id="downloadLink" style="display: none;">Download</a>
<script>
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
const customWordInput = document.getElementById('customWord');
const downloadLink = document.getElementById('downloadLink');
function drawImage(word) {
// Clear the canvas
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Set background to white
ctx.fillStyle = 'white';
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Draw the text "Base is for"
ctx.font = '800 60px Inter, sans-serif';
ctx.fillStyle = 'black';
ctx.textAlign = 'center';
ctx.fillText('Base', canvas.width / 2, 150);
ctx.fillText('is for', canvas.width / 2, 220);
// Draw the custom word
const customWord = word.toLowerCase();
ctx.fillText(customWord, canvas.width / 2, 290);
// Draw the hand-drawn blue circle around the custom word with dynamic sizing
const textMetrics = ctx.measureText(customWord);
const textWidth = textMetrics.width;
const padding = 20;
const xRadius = textWidth / 2 + padding; // Dynamic horizontal radius
const yRadius = 40; // Fixed vertical radius
// Draw multiple slightly offset ellipses to create a hand-drawn effect
for (let i = 0; i < 3; i++) {
ctx.beginPath();
ctx.strokeStyle = `rgba(0, 123, 255, ${0.5 - i * 0.1})`; // Vary opacity for depth
ctx.lineWidth = 5;
// Add small random offsets to make it look hand-drawn
const offsetX = (Math.random() - 0.5) * 5;
const offsetY = (Math.random() - 0.5) * 5;
ctx.ellipse(
canvas.width / 2 + offsetX,
280 + offsetY,
xRadius + (Math.random() - 0.5) * 3, // Slight variation in radius
yRadius + (Math.random() - 0.5) * 3,
0,
0,
2 * Math.PI
);
ctx.stroke();
}
}
function generateImage() {
const word = customWordInput.value.trim();
if (!word) {
alert('Please enter a word!');
return;
}
// Draw the image with the custom word
drawImage(word);
// Enable download
const dataURL = canvas.toDataURL('image/png');
downloadLink.href = dataURL;
downloadLink.download = `base-is-for-${word}.png`;
downloadLink.style.display = 'block';
downloadLink.textContent = 'Download';
}
// Draw initial image with a default word
drawImage('tokens');
</script>
</body>
</html>