Communitygithub.com

rigkit

Make or change an animated vector character or prop with rigkit - from an idea or a generated reference image to clean vector parts drawn in code, published as a Rive file (.riv, the product; needs the user's own `rive login`), with an SVG kept only as an emergency fallback. Side-on characters (biped), top-down game characters (three views and a facing input) and props (chests, doors, coins). Use when adding a character or prop, redrawing one, adding a part, colour, outfit or expression, adding or changing an animation state, fixing joints or art glitches, or wiring one into a web page, game or app.

rigkit란 무엇인가요?

rigkit is a Codex agent skill that make or change an animated vector character or prop with rigkit - from an idea or a generated reference image to clean vector parts drawn in code, published as a Rive file (.riv, the product; needs the user's own `rive login`), with an SVG kept only as an emergency fallback. Side-on characters (biped), top-down game characters (three views and a facing input) and props (chests, doors, coins). Use when adding a character or prop, redrawing one, adding a part, colour, outfit or expression, adding or changing an animation state, fixing joints or art glitches, or wiring one into a web page, game or app.

지원 대상~Claude Code✓Codex CLI~Cursor✓Gemini CLI
npx skills add https://github.com/farhadi-erfan/rigkit/tree/HEAD/skill/rigkit

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

Animated vector characters with rigkit

rigkit turns a character drawn in Python into a Rive file (.riv). That is the product: what the app ships, what you test and what you demo. It also writes an animated SVG of the same poses, but only as an emergency fallback (a browser where Rive can't run, or a failed Rive load in production). The SVG is never a substitute for the .riv, and you never test on it.

Animation lives in one pose table (JavaScript) that moves named parts about named joints. Any character whose parts use those names plays every state.

reference image ─► draw.py (Python, rigkit) ─► <name>.rig.json ─► rigkit build ─┬─► <out>/<name>.riv (+ .riv.json)  THE PRODUCT (needs the user's `rive login`)
 front + side       --preview / --parts           parts tree, joints, art      ├─► <out>/<name>/scene.rml         the Rive source
 rigkit.config.js: states, poses, switches, inputs, characters ────────────────┘─► <out>/<name>.rigkit.js         metadata + SVG fallback
                                                            rigkit check ◄── every .riv up to date? (must pass)

Find rigkit first. It's either a dependency (node_modules/rigkit) or a folder next to the project. Its README has the full reference. rigkit.config.js in the project says which characters exist and which preset they use.

Ground rules

  • Original characters only. A style or genre is fine. A recreation of an existing character is not: no copied names, looks or model sheets.
  • Reference images stay out of git unless the user owns them. Commit the draw.py scripts, the config, and whatever the build writes that the app needs.
  • Rive is required, and signing in is the user's step. rigkit build publishes the .riv and needs the user's own rive login. Never sign in or enter credentials for them. If the build says the Rive CLI isn't signed in, stop. Tell the user to run rive login and then rigkit build, and do not report the work as done. Don't use --no-publish or --svg-only to get past it, and never offer the SVG as a substitute.
  • Done means rigkit check passes. It fails while any .riv is missing, unstamped or older than its rig or config. Run it before you say the art work is finished.
  • Test and demo against the .riv. Use the demo page or the app with riv set and strict: true, never the SVG.
  • A Free Rive plan puts a watermark splash on published files. Say so, and don't try to remove it.

0. Which kind

  • Side-on character (it stands on things and walks across the screen): the biped. Use rigkit init <name>, rigkit.biped, and the biped preset: a front view for acting, a side view for travel.
  • Top-down game character (an RPG or adventure view, seen from above at a slant): use rigkit init <name> --topdown, rigkit.topdown, and the topdown preset. It has three views (down, up, side) and a facing input (0 down, 1 up, 2 right, 3 left) that picks the view in every state, with a centre anchor. The reference needs a down view, an up (back) view and a side view facing right. In the up view the arms go behind the body (topdown.up(..., arms='front') to change that), give hands their own art (hand-l, u-hand-l, ...) so they can be hidden, put a cloak or coat over the arms with u-coat, and draw ears (ear-l, u-ear-l, s-ear-n/s-ear-f) with their roots well inside the head, which is drawn over them.
  • Something that turns to face where it's going (a car, a ship, a top-down shooter): one view; the app rotates it.
  • Prop (a chest, door, coin or plant): build the tree with Part directly and give its config entry its own states and poses, as examples/chest does (anim.js). Props usually take anchor: 'center'.

1. A reference

Ask the user for a turnaround: the character in a front view and a side view facing right. Both views should have the same proportions, flat colours, a bold even outline and a plain background, with the arms a little away from the body and the legs slightly apart.

Get the image one of these ways, and record it with rigkit source (or the editor's Source page), which keeps everything in <character>/source/source.json:

  1. A configured provider. Run rigkit source providers <dir> to see which providers have a key, and which one generate in rigkit.config.js names. If one is ready, use it:
    rigkit source generate characters/<name> --turnaround --prompt "<the user's description>"            # biped: front + side
    rigkit source generate characters/<name> --turnaround topdown --prompt "<description>"              # down, up, side
    rigkit source generate characters/<name> --prompt "<change>" --reference base                     # from the chosen image
    
    --turnaround turns a plain description into the model-sheet request the drawing step needs. Each image is a paid request on the user's account. Keep --count at 1 or 2, and ask before making more or before running several rounds.
  2. No provider ready. Ask the user which they'd like: openai (OPENAI_API_KEY), gemini (GEMINI_API_KEY), or neither. They set the key themselves, in their shell or in a git-ignored .env next to rigkit.config.js. Never ask them to paste a key into the chat, never write a key into any file, and never print one.
  3. No API at all. The user makes the image in any tool (ChatGPT, an image app, their own drawing), and you rigkit source import it. Or, if you have a browser and the user agrees, drive their own signed-in image tool for them. They sign in themselves; you never enter credentials.

Then:

  • import <dir> <image|video> [--time T | --frame N] and frame bring in an image or a video frame.
  • choose picks the base (image, frame:N or g1:2).
  • use --view front --stage WxH writes the fitted reference-<view>.png beside draw.py. Make one per view: crop each view out of the turnaround sheet first, or import each view separately.

Characters must be original: describe the user's character, never "like ". The turnaround prompt already asks for an original design.

Draw over the reference; don't trace it. Auto-tracing generated art gives lumpy outlines and parts that don't separate at the joints, so they tear when posed.

2. Draw the parts in code

Start a project with rigkit init <name>. It writes rigkit.config.js and a starter characters/<name>/draw.py. For a richer model, copy an example from rigkit's examples/.

Helpers live in rigkit.vec; all take absolute SVG path data in stage pixels:

  • capsule(x1, y1, x2, y2, r1, r2): a tapered limb with round ends. Use it for every arm and leg segment.
  • capsule_open(...): the same outline without the start cap.
  • ellipse, fill(d, colour, outline=True), line(d), band. Set the outline colour and width once with set_style(ink=..., line=...).
  • sample and poly_d work with shapely for geometry such as cutting a patch to an outline (see clip() in the examples).

Rules that keep the rig clean when it moves:

  1. Each moving piece is its own part. With the biped preset, use the art names listed at the top of rigkit/biped.py: head, torso, upper-arm-l, forearm-l, thigh-l, shin-l, eye-white-l, pupil-l, brow-l, mouth-smile|flat|o|pant, … and the side view's s- names, where -n/-f mark the near and far limb. Leaving a part out is fine; it comes out empty.

  2. Round joints. A child limb (forearm, shin) starts with an unoutlined round cap centred on its pivot, a hair narrower than the parent's end, and is drawn in front of it:

    [fill(capsule(*a, *b, r1, r2), COLOUR, False), line(capsule_open(*a, *b, r1, r2))]
    

    Hips sit under the thighs' caps. Then a bent elbow or knee shows no gap and no doubled outline.

  3. Joints at the cap centres. Pivots go in JOINTS / SIDE_JOINTS, in stage coordinates, at the centre of each round cap.

  4. Side view far limbs are the near ones shifted a little (FAR_DX) and a shade darker.

  5. Mirror, don't redraw. mx(x) mirrors about the centre line, so left and right stay identical.

  6. Expressions are alternatives that share a joint (the mouths). The preset shows one per state through the mouth switch.

The script ends by building the character:

ch = Character('name', box=(W, H), scale=RIG_UNITS / STAGE_PX, feet=(W / 2, H - 4), stroke_scale=2)
ch.view('front', biped.front(P, JOINTS), feet=(CX, 950), reference='reference-front.png')
ch.view('side', biped.side(S, SIDE_JOINTS), feet=(CX, 950), reference='reference-side.png')
ch.group('mouth', biped.groups()['mouth'])
ch.run()
  • box is the character's size as the app places it, in rig units.
  • scale maps the stage drawing into the box, for example (head top to sole in rig units) / (the same in stage px).
  • stroke_scale thickens outlines that would be too thin once small.

For a creature that isn't a biped (a snake, a bird), build the tree yourself with Part(name, pivot, [art and child Parts]) and write a pose table to match.

Check the drawing (needs pip install shapely pymupdf pillow):

  • python3 draw.py --preview writes preview-front.png and preview-side.png, each with the reference beside the drawing. Look at them with Read and compare silhouette, proportions and where the joints sit.
  • python3 draw.py --turn writes preview-turn.png: every view (side views also mirrored) at the stage size and at game size, open and blinking. Check it for things that change abruptly as the character turns: ears, eyes, hands, hats.
  • For eyes that should match across views, draw them all from one rigkit.eyes.Eye design (EYE.at(x, y) for front and near eyes, EYE.far(x, y, foreshorten=, occlude=[...]) for a three-quarter head's far eye) instead of separate ellipses per view. --turn warns when an eye is mostly covered by a hat or nose.
  • python3 draw.py --parts plus rigkit editor lets you look at parts over the reference in the browser, nudge them and edit points. Its edits go to parts/ only; carry any change you want to keep back into draw.py.

Repeat until it looks right.

3. Build

rigkit build

This has the Rive CLI check the markup, render <out>/<name>/build/<name>.png (look at it), and publish <out>/<name>.riv with its stamp <name>.riv.json. It also copies both to the character's riv path, if the config sets one, and writes scene.rml and the art module (metadata + SVG fallback).

If it fails with "the Rive CLI is not signed in": stop and ask the user to run rive login themselves, then build again. That is the whole fix. If the Rive CLI isn't installed, ask the user to install it.

rigkit demo

This opens a page that plays every character's .riv in every state, plus the inputs. A red banner means a .riv is missing or stale: fix that first. Use the browser pane: check the front view, the side view facing both ways (dir), gaze, a held paw, and the states that bend joints the most (climb, ex-overhead, scared). Leave the "SVG fallback" checkbox off; that copy isn't what ships.

rigkit check

This must pass (exit 0) before you call the work done. Put it in the project's tests or CI too.

To render one Rive state as an image, use the CLI's commands: viewport 400x400, fit contain, data state=<index> (the state's position in states), advance 400ms, screenshot out.png. Write advance in ms.

4. Animation (only when asked to change motion)

Everything is in the config, usually by spreading require('rigkit/presets/biped') and overriding parts of it:

  • states: {name: {view?, mouth?}}. The order is the number the state input takes, so add new states at the end.
  • poses(options): {state: {frames, loop, parts: {part: {rot, x, y, sx, sy, opacity}}}}, at 60 fps. Build values with swing, keys, repeat, pair and stride from rigkit/motion. Angles are in degrees, positive clockwise; offsets are in rig units from rest.
  • switches: groups of parts where a state shows one option.
  • inputs(options): blend (two poses, mixed by a number) or toggle (a pose switched on by a condition).
  • Per-character options in characters[]: look (pupil travel), headLimit (a wide head makes raised arms bend at the elbow) and simpleArms for the biped; stride and swing for the topdown preset.
  • A character can bring its own setup. states, poses, switches, inputs, margin and anchor on its characters[] entry replace the project's, so a prop and characters can share one project.
  • A views input ({type: 'number', views: [{view, mirror?}, ...]}) picks the view by number in every state. That's how top-down facing works.

5. Use it in an app

<script src="https://unpkg.com/@rive-app/[email protected]"></script>
<script src="rigkit/js/runtime/rigkit.js"></script>
<script src="rigkit-build/cat.rigkit.js"></script>
<div id="cat" style="width: 120px"></div>
<script>
  const cat = rigkit.puppet(document.getElementById('cat'), rigkit.art.cat, {
    riv: 'rigkit-build/cat.riv',  // always: the .riv is what ships
    strict: true,                 // in dev and tests: a Rive problem is an error, not a quiet switch to the SVG
  });
  cat.setState('walk'); cat.set('dir', -1); cat.set('lookX', 80); cat.set('holding', true);
</script>

The container sets the width; the character stands on its bottom edge. Ship the .riv and its stamp. In production, leave strict off so a failed load falls back to the SVG; fallback: true marks code that shows the SVG on purpose (a browser without Rive). Commit the build output the app loads, and say what you didn't check. If the .riv couldn't be published, say plainly that the work isn't finished until the user runs rive login and rigkit build.

관련 스킬