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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>P5.js Circle Sketch</title>
|
| 7 |
+
<meta name="description" content="A simple P5.js sketch that draws a circle">
|
| 8 |
+
<style>
|
| 9 |
+
* {
|
| 10 |
+
margin: 0;
|
| 11 |
+
padding: 0;
|
| 12 |
+
box-sizing: border-box;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
body {
|
| 16 |
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
| 17 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 18 |
+
min-height: 100vh;
|
| 19 |
+
display: flex;
|
| 20 |
+
flex-direction: column;
|
| 21 |
+
overflow: hidden;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
header {
|
| 25 |
+
background: rgba(255, 255, 255, 0.1);
|
| 26 |
+
backdrop-filter: blur(10px);
|
| 27 |
+
padding: 1rem 2rem;
|
| 28 |
+
border-bottom: 1px solid rgba(255, 255, 255, 0.2);
|
| 29 |
+
z-index: 1000;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
.header-content {
|
| 33 |
+
max-width: 1200px;
|
| 34 |
+
margin: 0 auto;
|
| 35 |
+
display: flex;
|
| 36 |
+
justify-content: space-between;
|
| 37 |
+
align-items: center;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
h1 {
|
| 41 |
+
color: white;
|
| 42 |
+
font-size: 1.5rem;
|
| 43 |
+
font-weight: 600;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
.credit {
|
| 47 |
+
color: white;
|
| 48 |
+
font-size: 0.9rem;
|
| 49 |
+
opacity: 0.9;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
.credit a {
|
| 53 |
+
color: white;
|
| 54 |
+
text-decoration: none;
|
| 55 |
+
font-weight: 500;
|
| 56 |
+
transition: opacity 0.3s ease;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
.credit a:hover {
|
| 60 |
+
opacity: 0.8;
|
| 61 |
+
text-decoration: underline;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
main {
|
| 65 |
+
flex: 1;
|
| 66 |
+
display: flex;
|
| 67 |
+
justify-content: center;
|
| 68 |
+
align-items: center;
|
| 69 |
+
padding: 2rem;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
#canvas-container {
|
| 73 |
+
background: white;
|
| 74 |
+
border-radius: 12px;
|
| 75 |
+
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
| 76 |
+
padding: 2rem;
|
| 77 |
+
max-width: 100%;
|
| 78 |
+
max-height: calc(100vh - 200px);
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
canvas {
|
| 82 |
+
display: block;
|
| 83 |
+
border-radius: 8px;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
.controls {
|
| 87 |
+
margin-top: 1.5rem;
|
| 88 |
+
display: flex;
|
| 89 |
+
gap: 1rem;
|
| 90 |
+
justify-content: center;
|
| 91 |
+
flex-wrap: wrap;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
button {
|
| 95 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 96 |
+
color: white;
|
| 97 |
+
border: none;
|
| 98 |
+
padding: 0.75rem 1.5rem;
|
| 99 |
+
border-radius: 6px;
|
| 100 |
+
font-size: 0.9rem;
|
| 101 |
+
font-weight: 500;
|
| 102 |
+
cursor: pointer;
|
| 103 |
+
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
button:hover {
|
| 107 |
+
transform: translateY(-2px);
|
| 108 |
+
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
button:active {
|
| 112 |
+
transform: translateY(0);
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
footer {
|
| 116 |
+
background: rgba(255, 255, 255, 0.1);
|
| 117 |
+
backdrop-filter: blur(10px);
|
| 118 |
+
padding: 1rem;
|
| 119 |
+
text-align: center;
|
| 120 |
+
color: white;
|
| 121 |
+
font-size: 0.85rem;
|
| 122 |
+
border-top: 1px solid rgba(255, 255, 255, 0.2);
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
@media (max-width: 768px) {
|
| 126 |
+
header {
|
| 127 |
+
padding: 1rem;
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
h1 {
|
| 131 |
+
font-size: 1.2rem;
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
.header-content {
|
| 135 |
+
flex-direction: column;
|
| 136 |
+
gap: 0.5rem;
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
#canvas-container {
|
| 140 |
+
padding: 1rem;
|
| 141 |
+
}
|
| 142 |
+
}
|
| 143 |
+
</style>
|
| 144 |
+
</head>
|
| 145 |
+
<body>
|
| 146 |
+
<header>
|
| 147 |
+
<div class="header-content">
|
| 148 |
+
<h1>P5.js Circle Sketch</h1>
|
| 149 |
+
<div class="credit">
|
| 150 |
+
Built with <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" rel="noopener">anycoder</a>
|
| 151 |
+
</div>
|
| 152 |
+
</div>
|
| 153 |
+
</header>
|
| 154 |
+
|
| 155 |
+
<main>
|
| 156 |
+
<div id="canvas-container">
|
| 157 |
+
<div id="sketch-holder"></div>
|
| 158 |
+
<div class="controls">
|
| 159 |
+
<button onclick="changeColor()">Change Color</button>
|
| 160 |
+
<button onclick="changeSize()">Change Size</button>
|
| 161 |
+
<button onclick="animateCircle()">Animate</button>
|
| 162 |
+
<button onclick="resetSketch()">Reset</button>
|
| 163 |
+
</div>
|
| 164 |
+
</div>
|
| 165 |
+
</main>
|
| 166 |
+
|
| 167 |
+
<footer>
|
| 168 |
+
<p>Interactive P5.js Circle • Click buttons to explore different effects</p>
|
| 169 |
+
</footer>
|
| 170 |
+
|
| 171 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.7.0/p5.min.js"></script>
|
| 172 |
+
<script>
|
| 173 |
+
let circleColor;
|
| 174 |
+
let circleSize;
|
| 175 |
+
let animating = false;
|
| 176 |
+
let animationAngle = 0;
|
| 177 |
+
let originalSize;
|
| 178 |
+
|
| 179 |
+
function setup() {
|
| 180 |
+
let canvas = createCanvas(600, 400);
|
| 181 |
+
canvas.parent('sketch-holder');
|
| 182 |
+
circleColor = color(102, 126, 234);
|
| 183 |
+
circleSize = 100;
|
| 184 |
+
originalSize = 100;
|
| 185 |
+
noStroke();
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
function draw() {
|
| 189 |
+
// Gradient background
|
| 190 |
+
for(let i = 0; i <= height; i++) {
|
| 191 |
+
let inter = map(i, 0, height, 0, 1);
|
| 192 |
+
let c = lerpColor(color(240, 240, 245), color(220, 220, 230), inter);
|
| 193 |
+
stroke(c);
|
| 194 |
+
line(0, i, width, i);
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
// Calculate position
|
| 198 |
+
let x = width / 2;
|
| 199 |
+
let y = height / 2;
|
| 200 |
+
|
| 201 |
+
// Apply animation if active
|
| 202 |
+
if (animating) {
|
| 203 |
+
animationAngle += 0.02;
|
| 204 |
+
x = width / 2 + cos(animationAngle) * 100;
|
| 205 |
+
y = height / 2 + sin(animationAngle) * 100;
|
| 206 |
+
circleSize = originalSize + sin(animationAngle * 2) * 30;
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
// Draw shadow
|
| 210 |
+
fill(0, 20);
|
| 211 |
+
ellipse(x + 5, y + 5, circleSize);
|
| 212 |
+
|
| 213 |
+
// Draw circle
|
| 214 |
+
fill(circleColor);
|
| 215 |
+
ellipse(x, y, circleSize);
|
| 216 |
+
|
| 217 |
+
// Draw highlight
|
| 218 |
+
fill(255, 100);
|
| 219 |
+
ellipse(x - circleSize/4, y - circleSize/4, circleSize/3);
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
function changeColor() {
|
| 223 |
+
let colors = [
|
| 224 |
+
color(102, 126, 234), // Blue
|
| 225 |
+
color(118, 75, 162), // Purple
|
| 226 |
+
color(237, 100, 166), // Pink
|
| 227 |
+
color(255, 193, 7), // Yellow
|
| 228 |
+
color(76, 175, 80), // Green
|
| 229 |
+
color(244, 67, 54) // Red
|
| 230 |
+
];
|
| 231 |
+
let currentIndex = -1;
|
| 232 |
+
for(let i = 0; i < colors.length; i++) {
|
| 233 |
+
if(red(circleColor) === red(colors[i]) &&
|
| 234 |
+
green(circleColor) === green(colors[i]) &&
|
| 235 |
+
blue(circleColor) === blue(colors[i])) {
|
| 236 |
+
currentIndex = i;
|
| 237 |
+
break;
|
| 238 |
+
}
|
| 239 |
+
}
|
| 240 |
+
circleColor = colors[(currentIndex + 1) % colors.length];
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
function changeSize() {
|
| 244 |
+
circleSize = random(50, 200);
|
| 245 |
+
originalSize = circleSize;
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
function animateCircle() {
|
| 249 |
+
animating = !animating;
|
| 250 |
+
if (!animating) {
|
| 251 |
+
animationAngle = 0;
|
| 252 |
+
circleSize = originalSize;
|
| 253 |
+
}
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
function resetSketch() {
|
| 257 |
+
circleColor = color(102, 126, 234);
|
| 258 |
+
circleSize = 100;
|
| 259 |
+
originalSize = 100;
|
| 260 |
+
animating = false;
|
| 261 |
+
animationAngle = 0;
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
// Handle window resize
|
| 265 |
+
function windowResized() {
|
| 266 |
+
let container = document.getElementById('canvas-container');
|
| 267 |
+
let maxWidth = container.clientWidth - 64; // Account for padding
|
| 268 |
+
if (maxWidth < 600) {
|
| 269 |
+
resizeCanvas(maxWidth, maxWidth * 0.67);
|
| 270 |
+
}
|
| 271 |
+
}
|
| 272 |
+
</script>
|
| 273 |
+
</body>
|
| 274 |
+
</html>
|