Spaces:
Running

hugging-space / README.md
Chunte's picture
Chunte HF Staff
Restore the default Space header
6b37846 verified
|
Raw History Blame Contribute Delete
3 kB
metadata
title: Hugging Space
emoji: 🤗
colorFrom: yellow
colorTo: pink
sdk: static
app_build_command: npm run build
app_file: dist/index.html
pinned: true

Hugging Space

Drag a partner logo (SVG) next to Huggy and Huggy hugs it: the round body squishes softly into the logo's empty pockets, the right hand settles on the nearest edge and the left hand reaches out to grip the logo. Export the result as SVG or PNG.

Develop

npm install
npm run dev

How it works

  • src/logo.ts rasterises the uploaded SVG once, then derives an opacity mask, the "pockets" (transparent pixels inside the logo's convex hull), distance fields and grippable boundary points.
  • src/body.ts models Huggy's body as a ring of radial springs. Each ray decides whether it may bulge into a pocket just beyond the logo stroke; the bulge size comes from the area the logo overlaps (area in = bulge out).
  • src/warp.ts squishes the logo back: the section of the logo's outer edge that faces Huggy and sits inside the body (from ~0.15R inside the rim) bows inward, strongest around the hug direction. Where Huggy swells into a pocket, the pocket walls give way too; limits keep strokes from getting too thin and stop two bows from fighting over one stroke. Warps the logo's own vector paths (src/pathdata.ts turns any shape into cubic Béziers), so the SVG export stays vector. Past a freeze depth the squish shape stops changing (no distortion when the logo is pushed very deep). tools/refcheck compares it to the Figma frames.
  • Global squish rule: how deep the logo reaches inside Huggy sets one squish level that drives Huggy's swell and both logo bows, so everything squishes harder the further the logo is pushed in, up to the set maximums. The sidebar's "Squish tuning" panel (src/tuner.ts) edits every setting live and records / exports "sweet spots" as JSON.
  • src/versions.ts lists every stage of the squish (v1 Figma bend … v9 one press arc, the current one; v10 was tried and reverted) with a short description; the sidebar's Version dropdown switches between them (engine, defaults and relevant sliders) for quick comparison. v6 (push field, reverted) lives in src/warpField.ts.
  • src/hands.ts keeps the right hand near home (small snap to the nearest edge) and lets the left hand pick the best grip point on the logo's far edges.
  • src/main.ts wires the scene, interaction and export.

Agent API (MCP)

Agents can hug a logo without the UI: the public Space Chunte/hugging-space-mcp runs this app headlessly (Playwright) behind Gradio with an MCP server. Tools: hug_logo → transparent PNG (default), hug_logo_svg → SVG; inputs svg (markup or URL), size, rotation. MCP URL: https://chunte-hugging-space-mcp.hf.space/gradio_api/mcp/sse (no token needed). Code in agent/, deployed with tools/deploy-agent.sh. The app side is window.hugApi.hug() in src/main.ts.