Loading video...

Video Failed to Load

Go Home

spritesheets are, and always will be, a fun trick! ⚡ translate with css based on pointer position grace note™ blink included ♪

154,132 views • 1 month ago •via X (Twitter)

55 Comments

Peter Petrash's profile picture
Peter Petrash1 month ago

spritesheeted myself for my site ☺️ it has a mood system underneath including easter egg behaviors (eg. try hypnotizing it with your mouse)

jhey ʕ•ᴥ•ʔ's profile picture
jhey ʕ•ᴥ•ʔ1 month ago

haha 😅 that's real good i think where this one wins is because it doesn't try to be the "centerpiece", it's one of those where you've lined it up to be discovered easily, but then lets the user feel like they discovered it 👏

Peter Petrash's profile picture
Peter Petrash1 month ago

appreciate it Jhey 👊

Boyd's profile picture
Boyd1 month ago

I did something similar to this but for my dog.

jhey ʕ•ᴥ•ʔ's profile picture
jhey ʕ•ᴥ•ʔ1 month ago

love it - that's so good! 🐶

Boyd's profile picture
Boyd1 month ago

Least I could do for him. He was a huge personality in our house.

jhey ʕ•ᴥ•ʔ's profile picture
jhey ʕ•ᴥ•ʔ1 month ago

i have no doubts from the pictures 🥲 such a lovely tribute 🫶

jhey ʕ•ᴥ•ʔ's profile picture
jhey ʕ•ᴥ•ʔ1 month ago

and of course, sorry for your loss Boyd, never quite know what the right words are 🙏 but, the "love it – it's so good" were definitely in regards to how well you have delivered that tribute 🫶

Boyd's profile picture
Boyd1 month ago

Thanks! We miss him as a family but time has healed the immediate loss. Appreciate the kind words both about Pi and the project.

jhey ʕ•ᴥ•ʔ's profile picture
jhey ʕ•ᴥ•ʔ1 month ago

i didn't bookmark the post i saw doing the rounds for this the other day 🤦‍♂️ but saw a bunch of 'em so if someone has it to reference 🙏

Chauve Camille's profile picture
Chauve Camille1 month ago

😮

jhey ʕ•ᴥ•ʔ's profile picture
jhey ʕ•ᴥ•ʔ1 month ago

that's the one i was looking for to QT 🙏 different technique but the same concept 💯

oil-oil's profile picture
oil-oil1 month ago

I also implemented a similar effect on my website,

jhey ʕ•ᴥ•ʔ's profile picture
jhey ʕ•ᴥ•ʔ1 month ago

had a few questions about this one 🤙 - quick way: generate a video based on a character map and use ffmpeg etc. to split frames and create the sprite (you don't need a 3mb sprite file! compress!) - smoothing: track pointer pos + eased pos. the eased pos plays catch up, use that

Joel Stransky ✨'s profile picture
Joel Stransky ✨1 month ago

I did this in 2005 in Flash.

jhey ʕ•ᴥ•ʔ's profile picture
jhey ʕ•ᴥ•ʔ1 month ago

never got to play with flash 🥲

Joel Stransky ✨'s profile picture
Joel Stransky ✨1 month ago

You would have been the best of us.

jhey ʕ•ᴥ•ʔ's profile picture
jhey ʕ•ᴥ•ʔ1 month ago

ha 😅 i highly doubt that but from what i understand, that was an incredibly fun/creative era

Hurricane Zane's profile picture
Hurricane Zane1 month ago

where is beaver demo? my son is requesting access

Techies Reviews's profile picture
Techies Reviews1 month ago

Wohoo sprites are back baby!

dennys dionigi's profile picture
dennys dionigi1 month ago

Fun trick also here 😆

Geryy's profile picture
Geryy1 month ago

Back in my times we used sprite sheets for button hover states.... 🧓

mr.tipton's profile picture
mr.tipton1 month ago

I love sprite sheets. I built a native utility app with sprite sheets being the UI. Haha This one is so good! Love the look and smoothness

jhey ʕ•ᴥ•ʔ's profile picture
jhey ʕ•ᴥ•ʔ1 month ago

sprites are always fun! i did put a little "smoothing" slider in there to try help things out on it 😁

mr.tipton's profile picture
mr.tipton1 month ago

Looks great man

Jimmy Lee's profile picture
Jimmy Lee1 month ago

This is so good, the future of avatars

Brayan's profile picture
Brayan1 month ago

Any tips on smooth sprite animations?

jhey ʕ•ᴥ•ʔ's profile picture
jhey ʕ•ᴥ•ʔ1 month ago

in this case, keep the pointer position as "the target" then lerp/ease a separate value towards it on every frame and use that eased value to drive the spritesheet frame you’re smoothing the input, not the sprite itself 🤙

Ismael's profile picture
Ismael1 month ago

Wait, I need this for my website

Ahmed Dahbi's profile picture
Ahmed Dahbi1 month ago

wow super cool! love the blink 😉

Occam’s Orange's profile picture
Occam’s Orange1 month ago

How did you generate the sprite in the first place? When i tried using gpt image or gemini, it keep duplicating the same image.

jhey ʕ•ᴥ•ʔ's profile picture
jhey ʕ•ᴥ•ʔ1 month ago

the skill with ai is prepping the journey 1. base image for your character 2. character map for your character 3. gaze rig for your character if you try jumping to 3, that's the issue, you need good reference material, and a good model Krea + GPT 2.0 for this one 🤙

Occam’s Orange's profile picture
Occam’s Orange1 month ago

Thank you 🙏 I'm trying to make one for

jhey ʕ•ᴥ•ʔ's profile picture
jhey ʕ•ᴥ•ʔ1 month ago

ahh yes - you should be able to generate one for that little character 💯 try prompting for the prompts too my gaze rig prompt would start something like: 9x9 spritesheet head-rotation gaze rig for this character (map + basic images attached) and then i'll detail the angles

Occam’s Orange's profile picture
Occam’s Orange1 month ago

Got it. Thanks a ton! The character is my son. Gotta pay him royalist

808's profile picture
8081 month ago

Damn thats clean! I love the double blink, adds so much depth. Will this be added sooner or later to the /index?

Mane's profile picture
Mane1 month ago

Didn’t know you vibes with beavers like that

jhey ʕ•ᴥ•ʔ's profile picture
jhey ʕ•ᴥ•ʔ1 month ago

it's a gopher 🥲

John Cotterell's profile picture
John Cotterell1 month ago

The blinking is a really nice touch. I did something similar with this character. It is quite painstaking work doing it with a spritesheet.

Deepak's profile picture
Deepak1 month ago

If I could follow one fucking person on X it'll be you man, you're the fucking goat

jhey ʕ•ᴥ•ʔ's profile picture
jhey ʕ•ᴥ•ʔ1 month ago

whoah - appreciate that 💯🙏 doin' what i can to try and post a little more again. i've been trying to collect/curate all my work over the years into one spot on my site, it's been takin' a minute 🙇‍♂️

Deepak's profile picture
Deepak1 month ago

There's so much alpha in what you post, it's just an endless sea of knowledge. Thank you for your posts

yann · minimal design's profile picture
yann · minimal design1 month ago

Is that on Codepen somewhere? 😍

Allie Speers's profile picture
Allie Speers1 month ago

omg who is lil fella

jhey ʕ•ᴥ•ʔ's profile picture
jhey ʕ•ᴥ•ʔ1 month ago

a little mascot i'm toying with for a project 😁

Simon's profile picture
Simon1 month ago

really cool

Crownz | AI & Design's profile picture
Crownz | AI & Design1 month ago

It does look fun

Joshua Ress, BSc's profile picture
Joshua Ress, BSc1 month ago

I LOVE playing with spritesheets. Such a simple and effective trick

IGGYsosa's profile picture
IGGYsosa1 month ago

Very very clever 👏 well done

Shubhu's profile picture
Shubhu1 month ago

how many images you generated for this one?

Nattu's profile picture
Nattu1 month ago

Thats some neat sprite management.

Anshuman's profile picture
Anshuman1 month ago

The explanation on this one is superb!!! 🤯🙌

Dzmitry Drynau's profile picture
Dzmitry Drynau1 month ago

Hmm, interesting and cool! I should try to do something like that on our platform.

Joseph Miclaus's profile picture
Joseph Miclaus1 month ago

This is way too good... waaay too good.

Massdx's profile picture
Massdx1 month ago

how ? can you share a tutorial ?

Related Videos

CSS Trick 🧲 You can create magnetic links with the power of custom properties and some JavaScript 💪 a { translate: calc(clamp(-1, var(--x), 1) * var(--pad-x)) ...; transition: translate var(--s, 1s) var(--ease, var(--elastic)); } a:hover { --s: 0s; } The trick here is to pad out the list items wrapping your links and use that as a translation limit 🛑 Start by using some JavaScript to calculate a value between -1 and 1 for both the x/y axis on pointermove for each list item, not the link! 🔗 If your pointer was at the center of the item, you'd get [0,0]. If it was in the top right, you'd get [1,-1] ☝️ It's worth checking out the JavaScript snippet to see how the mapping function works. Essentially, you create a function that when given a value between two bounds, will give you a mapped value back 🤙 const mapX = mapRange( item.offsetWidth * -0.5, item.offsetWidth * 0.5, 1, -1 ) Then, on pointermove, you plug the pointer position in to get the value back out and pass that into your CSS const x = mapX(item.centerX - event.x) document​.documentElement​.style.setProperty(--x, x) When the pointer leaves the list item, you make sure to reset these values back to 0 ✨ Once CSS has your values, it's the trick of updating the translation of each part You know that in each axis, you only want to translate the link by the padding amount li a { translate: calc(clamp(-1, var(--x), 1) * var(--pad-x)) calc(clamp(-1, var(--y), 1) * var(--pad-y)); transition: translate var(--speed, 1s) var(--ease, var(--elastic)); } This will translate the link within the list item by the desired amount. The cool part here is that you can set an offset for the text inside the link and have that move at a different rate ⭐️ By only updating the --pad-x/y custom properties for the inside the link, you can control how much it moves nav a span { --pad-x: 0.25rem; --pad-y: 0.25rem; } And the last piece, how do you update the behavior for transition speeds? And so it springs back like that? Again, use custom properties ✨ a:hover { --s: 0s; } a { transition: translate var(--s, 1s) var(--ease, var(--elastic)); } By default, a link will use --elastic easing via linear() and have a transition-duration of 1s. When a link is hovered that speed becomes 0s because you want the link to magnetise to your pointer. How about that little gap between when your pointer enters the item but hasn't hovered the link? Set a different transition so it transitions to being hovered 🫶 nav li:hover a { --ease: ease-out; --speed: 0.1s; } That's kinda it! 🙌 Use JavaScript (~40 loc) to get the information and then let CSS do all the lifting for you 💪 Any questions or suggestions, let me know 🙏 If you want a walkthrough video, also let me know please 🙏 CodePen.IO link below 👇

jhey ʕ•ᴥ•ʔ

164,863 views • 2 years ago