<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20"
fill="hsl(40 90% 80%)"
class="sr-only icon"
>
<path
fill-rule="evenodd"
d="M10.868 2.884c-.321-.772-1.415-.772-1.736 0l-1.83 4.401-4.753.381c-.833.067-1.171 1.107-.536 1.651l3.62 3.102-1.106 4.637c-.194.813.691 1.456 1.405 1.02L10 15.591l4.069 2.485c.713.436 1.598-.207 1.404-1.02l-1.106-4.637 3.62-3.102c.635-.544.297-1.584-.536-1.65l-4.752-.382-1.831-4.401Z"
clip-rule="evenodd"
/>
</svg>
<h1>fancy.</h1>
<canvas></canvas>
<a
class="bear-link"
href="https://twitter.com/intent/follow?screen_name=jh3yy"
target="_blank"
rel="noreferrer noopener"
>
<svg
class="w-9"
viewBox="0 0 969 955"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<circle
cx="161.191"
cy="320.191"
r="133.191"
stroke="currentColor"
stroke-width="20"
></circle>
<circle
cx="806.809"
cy="320.191"
r="133.191"
stroke="currentColor"
stroke-width="20"
></circle>
<circle
cx="695.019"
cy="587.733"
r="31.4016"
fill="currentColor"
></circle>
<circle
cx="272.981"
cy="587.733"
r="31.4016"
fill="currentColor"
></circle>
<path
d="M564.388 712.083C564.388 743.994 526.035 779.911 483.372 779.911C440.709 779.911 402.356 743.994 402.356 712.083C402.356 680.173 440.709 664.353 483.372 664.353C526.035 664.353 564.388 680.173 564.388 712.083Z"
fill="currentColor"
></path>
<rect
x="310.42"
y="448.31"
width="343.468"
height="51.4986"
fill="#FF1E1E"
></rect>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M745.643 288.24C815.368 344.185 854.539 432.623 854.539 511.741H614.938V454.652C614.938 433.113 597.477 415.652 575.938 415.652H388.37C366.831 415.652 349.37 433.113 349.37 454.652V511.741L110.949 511.741C110.949 432.623 150.12 344.185 219.845 288.24C289.57 232.295 384.138 200.865 482.744 200.865C581.35 200.865 675.918 232.295 745.643 288.24Z"
fill="currentColor"
></path>
</svg>
</a>
@import 'normalize.css';
*,
*:after,
*:before {
box-sizing: border-box;
}
html {
color-scheme: dark only;
}
body {
display: grid;
place-items: center;
min-height: 100vh;
font-family: 'SF Pro Text', 'SF Pro Icons', 'AOS Icons', 'Helvetica Neue',
Helvetica, Arial, sans-serif, system-ui;
}
h1 {
font-size: clamp(2rem, 4vw + 1rem, 8rem);
}
h1::selection {
background: hsl(40 90% 60%);
}
canvas {
pointer-events: none;
position: fixed;
inset: 0;
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border-width: 0;
}
body::before {
--size: 45px;
--line: color-mix(in lch, canvasText, transparent 70%);
content: '';
height: 100vh;
width: 100vw;
position: fixed;
background: linear-gradient(
90deg,
var(--line) 1px,
transparent 1px var(--size)
)
50% 50% / var(--size) var(--size),
linear-gradient(var(--line) 1px, transparent 1px var(--size)) 50% 50% /
var(--size) var(--size);
mask: linear-gradient(-20deg, transparent 50%, white);
top: 0;
transform-style: flat;
pointer-events: none;
z-index: -1;
}
.bear-link {
color: canvasText;
position: fixed;
top: 1rem;
left: 1rem;
width: 48px;
aspect-ratio: 1;
display: grid;
place-items: center;
opacity: 0.8;
}
:where(.x-link, .bear-link):is(:hover, :focus-visible) {
opacity: 1;
}
.bear-link svg {
width: 75%;
}
div.tp-dfwv {
width: 280px;
}
import { Pane } from 'https://cdn.skypack.dev/tweakpane'
import { gsap } from 'https://cdn.skypack.dev/gsap@3.12.0'
const config = {
distance: 50,
glow: false,
}
const ctrl = new Pane({
title: 'Config',
expanded: true,
})
ctrl.addBinding(config, 'distance', {
min: 0,
max: 200,
step: 1,
label: 'Buffer (px)',
})
ctrl.addBinding(config, 'glow', {
label: 'Glow',
})
// Get the serialized SVG string
const canvas = document.querySelector('canvas')
const ctx = canvas.getContext('2d')
const icon = document.querySelector('.icon')
const svgData = new XMLSerializer().serializeToString(icon)
canvas.width = window.innerWidth * window.devicePixelRatio
canvas.height = window.innerHeight * window.devicePixelRatio
// Create a new Image object
const img = new Image()
// Create a Data URI for the SVG
const svgBlob = new Blob([svgData], { type: 'image/svg+xml;charset=utf-8' })
const url = URL.createObjectURL(svgBlob)
// When the image loads, draw it onto the canvas
img.onload = function () {
// ctx.drawImage(img, window.innerWidth * 0.5, window.innerHeight * 0.5, 20, 20)
// Release the object URL since it's no longer needed
URL.revokeObjectURL(url)
}
// Set the image source to the Data URI
img.src = url
let parts = []
let glows = []
const render = () => {
ctx.clearRect(
0,
0,
window.innerWidth * window.devicePixelRatio,
window.innerHeight * window.devicePixelRatio
)
for (const glow of glows) {
ctx.beginPath()
// Draw the circle
// arc(x, y, radius, startAngle, endAngle, anticlockwise)
ctx.arc(glow.x, glow.y, glow.size * glow.scale, 0, Math.PI * 2)
// Optional: set fill color
ctx.fillStyle = 'hsl(265 90% 80% / 0.2)'
// Fill the circle
ctx.fill()
}
for (const part of parts) {
ctx.save()
ctx.globalAlpha = part.alpha
// ctx.filter = `hue-rotate(${part.sy < 0 ? '150' : '0'}deg) brightness(${
// part.sy < 0 ? part.b - 0.5 : part.b
// })`
ctx.filter = `brightness(${part.sy < 0 ? part.b + 0.5 : part.b})`
// const x = part.x - part.size * 0.5
// const y = part.y - part.size * 0.5
const x = part.x
const y = part.y
// Rotate after translate
ctx.translate(x, y)
// Rotate the canvas by the specified angle (in radians)
ctx.rotate(part.r * (Math.PI / 180))
ctx.scale(1, part.sy)
ctx.drawImage(
img,
// part.size * -0.5,
// part.size * -0.5,
part.size * part.scale * -0.5,
part.size * part.scale * -0.5,
part.size * part.scale,
part.size * part.scale
)
ctx.restore()
}
}
let distance = 0
let lastPoint = []
const paint = ({ x, y }) => {
const last = lastPoint
const dist = Math.hypot(x - last[0], y - last[1])
lastPoint = [x, y]
if (!Number.isNaN(dist)) distance += dist
if (config.glow) {
const glow = {
id: `glow--${Date.now()}`,
size: 30,
scale: 1,
x,
y,
}
gsap.to(glow, {
onComplete: () => {
glows = glows.filter((g) => g.id !== glow.id)
},
duration: 0.2,
scale: 0,
})
glows.push(glow)
}
if (distance >= config.distance) {
distance = 0
const newPart = {
id: Date.now(),
x,
y,
sy: Math.random() > 0.5 ? 1 : -1,
b: gsap.utils.random(0.5, 1.5),
r: gsap.utils.random(0, 359, 1),
hue: gsap.utils.random(0, 359, 1),
size: gsap.utils.random(10, 40, 1),
scale: 1,
alpha: 1,
}
const spin = gsap.to(newPart, {
sy: newPart.sy < 0 ? 1 : -1,
duration: gsap.utils.random(0.1, 0.5),
repeat: gsap.utils.random(0, 10, 1),
})
gsap.to(newPart, {
onComplete: () => {
spin.kill()
parts = parts.filter((p) => p.id !== newPart.id)
},
duration: gsap.utils.random(0.5, 2.5),
r: newPart.r + gsap.utils.random(-45, 45, 1),
y: y + gsap.utils.random(50, 350, 1),
alpha: 0,
scale: 0,
})
parts.push(newPart)
}
}
document.body.addEventListener('pointermove', paint)
gsap.ticker.add(render)
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.