Build a cursor-following portrait with Flora and Codex
I made a black-and-white bitmap portrait of myself in Flora, then asked Codex what we could do with it. We landed on a photo that looks toward your cursor. Click it and I pull up my hoodie and wink. Try it at the top of my homepage.
The whole interaction uses six still images: front, left, right, up, down, and the wink. The browser chooses which one to show. Here’s how we built it.
- Pick the base portrait. I already had a bitmap version I liked in Flora. We removed the colored background accents and used the clean, front-facing cutout as the reference. This is the image the other poses needed to match.
- Generate the looking directions. I had Codex operate Flora in Chrome using computer use. It made image-edit nodes for the different poses, using the front portrait as the reference. We started with left and right, then added up and down. The up/down generations used GPT Image 2 at High quality, 4:3, and 2k. The prompts asked for small changes to the head and eyes while preserving my face, smile, hair, hoodie, lighting, crop, and position in the frame.
- Make a separate click reaction. For the wink, Codex used the same front-facing reference and asked for the hood of my existing hoodie to be up, with one eye closed. No raised hands or new outfit. Keeping the face and shoulders in the same position made it possible to switch to this image without the whole portrait jumping.
- Remove the backgrounds and export the set. Codex used Flora’s Remove background tool, with BiRefNet General Use (Light), then downloaded the PNGs. It checked the files for real transparency; a visible checkerboard is not enough to prove the background is transparent. We ended up with six 2304 × 1728 images, named front.png, left.png, right.png, up.png, down.png, and wink.png.
- Try the interaction in a local preview. Codex built a small HTML, CSS, and JavaScript page with the images stacked in the same spot. Moving the pointer around the portrait changes the visible pose. A small neutral area keeps it looking forward when the cursor is near the face; a short delay and some tolerance around diagonal movements keep it from flickering between directions. Clicking shows the hood-up wink for 900 milliseconds, then returns to the current direction.
- Put the version I liked into the actual page. Once I’d tried the preview, Codex moved it into a small React component in my Next.js app. We placed it between my name and bio and removed the preview controls. The component serves smaller images with next/image, works with keyboard activation and taps, respects reduced-motion settings, and resets when it scrolls offscreen. Codex checked desktop and mobile, ran the app’s tests and build, and deployed it to Vercel after I approved it.
I could stay focused on the parts I cared about: whether it looked like me, which expressions were fun, and where it belonged on the page. Codex handled the repeated Flora setup, exports, and interaction code. Once the images are generated, moving the cursor doesn’t call an AI model. It just switches between saved pictures.
Below are the original up-glance and wink prompts, an adapted build prompt, and the component and CSS running on this site. To use the code in your own Next.js app, put your six PNGs in public/portraits/claire/ or change the image path, save the two source files together, and update the accessible button label for your own portrait.
# Generate matching portrait frames in Flora
Setup used for the up-glance and wink frames: GPT Image 2, High quality, 4:3, 2k, quantity 1. Connect the finished front-facing portrait as the image input for each generation.
The two prompts below are copied verbatim from the Flora nodes used for this portrait. Replace the person-specific details when using your own photo.
## Upward glance — original prompt
Edit this exact finished black-and-white bitmap cutout into ONE matching animation frame. Preserve this same woman and her identity, facial proportions, warm toothy smile, hairstyle, black hoodie, precise 1990s monochrome dithering, shoulders, torso, and crop. Keep the 4:3 canvas, subject scale, head center, body position and lighting exactly aligned to the reference. Do not shift, mirror, zoom, or change camera position. Keep the surroundings completely empty with REAL transparent alpha: no checkerboard, colored graphics, symbols, text, scenery, props or shadows outside the person. The ONLY change: tilt her head slightly upward about 10 degrees and direct both eyes toward the TOP EDGE of the image, as if following a cursor just above her. This is a gentle upward glance, not looking at the ceiling. Keep the entire head and hair inside the existing crop.
## Hood-up wink — original prompt
Edit this exact finished black-and-white bitmap cutout into ONE matching animation frame. Preserve this same woman and her identity, facial proportions, warm toothy smile, hairstyle, black hoodie, precise 1990s monochrome dithering, shoulders, torso, and crop. Keep the 4:3 canvas, subject scale, head center, body position and lighting exactly aligned to the reference. Do not shift, mirror, zoom, or change camera position. Keep the surroundings completely empty with REAL transparent alpha: no checkerboard, colored graphics, symbols, text, scenery, props or shadows outside the person. Make a playful click-reaction frame: she faces straight ahead in exactly the original pose, has pulled the hood of the SAME black hoodie over her head, and gives a friendly wink with her right eye (the eye on the LEFT side of the image) fully closed while the other eye remains open. Keep the same warm toothy smile and preserve visible hair framing her face beneath the hood. No hands or arms raised. The hood is plain black fabric with the same bitmap shading, not a hat, costume or helmet. Keep her face center and shoulders in exactly the reference position.
## Complete the set
For left, right, and down, use the same front-facing reference and alignment constraints, changing only the requested head and eye direction. These instructions summarize the workflow; they are not verbatim copies of those three prompts.
Use Flora's Remove background tool on the outputs. We used BiRefNet General Use (Light). Check that the downloaded PNGs have real transparency, rather than a checkerboard painted into the image.
Keep all six canvases the same size and keep the subject aligned. Export front.png, left.png, right.png, up.png, down.png, and wink.png. Our final PNGs were 2304 × 1728.
# Build a cursor-following portrait
Adapted from the implementation we built with Codex; not an original transcript.
I have six aligned, transparent PNGs: front.png, left.png, right.png, up.png, down.png, and wink.png. The wink frame is a special click reaction. Use these existing images without regenerating them.
First build a small local HTML/CSS/JavaScript preview. Stack the images in one fixed-size box so changing frames cannot move the surrounding layout. Show front by default, and switch among the four directional poses based on the pointer's position relative to the portrait. Keep a neutral area around the face and return to front when the pointer moves far away.
Keep direction changes from twitching: use a short settling delay and retain the previous direction near diagonal boundaries. Clicking, tapping, or activating the portrait with the keyboard should show the wink for about 900ms, then return to the current direction.
Check every frame before showing it so loading never produces a blank portrait. Disable automatic cursor following for reduced-motion preferences and touch pointers. Reset when the portrait scrolls offscreen or the browser tab becomes hidden. Clean up timers and event listeners.
Once the preview feels right, add it to the existing Next.js homepage as a small client component. Keep the rest of the page server-rendered. Place it between my name and short bio, aligned with the text, without the preview's pose controls. Use next/image to serve appropriately sized versions of the PNGs.
Check desktop and mobile layouts, all looking directions, the click/tap reaction, keyboard activation, and image loading. Run the project's checks. Show me the local result before deploying.