On this page

← All documentation

Writing a skin

How a skin is built, from its folder and defineSkin to the three layers of the playfield, images, sounds, live changes and the errors you will see.

A skin is a folder with a TypeScript script, skin.ts, and the images, sounds and fonts it names. The game runs the script at every map launch. setup(play) describes the native playfield (where the lanes sit, how big the notes are, colors, images, lights) and places the HUD elements that mods provide. Handlers registered in setup can change the playfield while the map plays.

The playfield is drawn by the game itself, at the speed of the notes. A skin never draws frames; it only gives values. For the HUD, see HUD elements. If you want a first working skin in a few minutes, start with your first skin and come back for the rules.

A complete skin

This skin uses colors only: no image to ship.

// Ember: a warm skin made of colors only, no image. Copy this folder into your skins folder,
// change `id` and `name`, and press Reload on the Skins page.
//
// A skin is one script. The game runs it at every map launch: `setup` describes the playfield
// (sizes are fractions of the screen height) and places the HUD elements of the mods. Handlers
// registered in `setup` may change the playfield during the play.

/** Share of the screen height all the lanes together fill, whatever the number of keys. */
const FIELD = 0.42;
const FLASH = "#ffb36b";

export default defineSkin({
  id: "ember",
  name: "Ember",
  version: "1.0.0",
  apiVersion: 2,
  author: "Prism docs",
  description: "A warm skin made of colors only.",
  uses: { "pvng.combo": "^1" },
  setup(play: PlayContext) {
    // Narrower lanes when there are more keys: the field keeps about the same width.
    const laneWidth = Math.min(0.1, FIELD / play.columns);
    playfield.set({
      laneWidth,
      laneGap: 0.004,
      receptorY: 0.86,
      scroll: "down",
      laneColor: "#241616c8",
      noteColor: "#ff8a3d",
      receptorColor: "#ffd2a8",
      pressedColor: "#fff2e0",
      holdBodyColor: "#c2531b",
      holdEndColor: "#ff8a3d",
      holdMatchNoteWidth: true,
      keyLightFadeMs: 80,
      judgementLine: true,
      judgementLineColor: FLASH,
      judgementLineThickness: 0.002,
      measureLines: true,
      measureLineOpacity: 0.2,
      borderWidth: 0.004,
      borderColor: "#ffb36b00",
    });
    // The two outer lanes a little lighter than the others.
    for (const column of [0, play.columns - 1]) {
      lanes.set({ column, lane: { laneColor: "#3a2020d0" } });
    }
    // The HUD is made of mods: the skin only places their elements.
    if (ctx.has("pvng.combo")) {
      ctx.element("pvng.combo/combo").configure({ x: 0.5, y: 0.2, anchor: "top", size: 0.05 });
    }
    // Every 100 combo the frame around the lanes lights up, then fades over 600 ms.
    ctx.on("game.judgement", (judgement: JudgementEvent) => {
      if (judgement.combo === 0 || judgement.combo % 100 !== 0) return;
      playfield.update({ patch: { borderColor: FLASH } });
      playfield.update({ patch: { borderColor: "#ffb36b00" }, transitionMs: 600, easing: "easeOut" });
    });
  },
});
  • defineSkin is the only thing the script exports. It is called once, at the top level.
  • setup(play) runs at every launch. play.columns is the number of keys, so the same script fits 4K to 16K.
  • playfield.set gives values for the whole playfield. lanes.set gives values for one lane.
  • ctx.on("game.judgement", …) registers a handler. During the play, playfield.update changes values, here with a transition.
  • The two uses and ctx.has lines place the combo counter, which is a mod.

The second example below adds images. Every value that can be set is in the field reference.

Folder and package

A skin is a folder. The folder name is the skin's id on this machine: 1 to 64 characters, valid as a Windows folder name, not starting with a dot.

Where Folder
Skins of the game skins\ next to prism.exe (content/skins/ in the repository). Read from disk like any other skin: none is built into the binary.
Skins of the player %LOCALAPPDATA%\Prism\PrismNG\data\skins\<id>\, or the folder named by the PRISM_SKINS_DIR environment variable (it only replaces this player folder).

The list takes the skins of the game first, then the player's. When two folders have the same id, the first one wins and a message says so. A folder without skin.ts is not a skin; the Skins page reports it. With no skin at all, the engine plays with its own values (white rectangles, no image) and shows one notice: No skin found: put a skin folder in skins/.

Inside the folder, every file is named by a path relative to it: notes/red.png. A path uses /, has no .., is at most 200 characters and 8 levels deep, and is not a Windows reserved name. A symbolic link or a junction that leaves the folder is refused.

File Rule
skin.ts Required, a single script without import, at most 1 MiB.
.png images At most 4 MiB and 2048 px per side.
.ttf, .otf fonts At most 8 MiB each.
.wav, .ogg, .flac, .mp3 sounds At most 1 MiB; only the first second is used.
preview.png Optional. The picture of the skin on the Skins page (the list falls back to left.png).

To share a skin as a .zip and the limits an archive is checked against, see the skin package format.

defineSkin

declare function defineSkin(input: SkinDefinition): SkinManifest;

Every field is checked when the script loads. An unknown field is refused (unknown field …, expected one of …).

Field Rule
id Required. 1 to 64 characters among a-z 0-9 . - _, starting and ending with a letter or digit. Keep it equal to the folder name. It must not be the id of a mod.
name Required. 1 to 64 characters. Shown on the Skins page.
version Required. A semantic version, 1.0.0.
apiVersion Required. Must be the game's, 2.
author Optional, 1 to 64 characters.
description Optional, at most 1024 characters.
homepage Optional. An http:// or https:// address, at most 256 characters.
fonts Optional. Fonts the skin bundles: name to .ttf or .otf path. See fonts.
uses Optional. The mods whose elements the skin places, like a mod's uses.
provides Optional. Elements other packages may configure, like a mod's provides.
permissions Optional. ["stage"] for native drawing.
images Optional. PNG files that handlers put on the playfield or the stage during the play, at most 64. See images.
setup Optional function, setup(play: PlayContext).

setup receives the context of the launch. Name the parameter play, not ctx: ctx is the global that holds ctx.on.

play. Content
mode, layout The mode and the layout of the map (an entry of the mode catalogue).
layoutSkin How the layout looks, for example 4k.
columns The number of lanes.
screenWidth, screenHeight The window in pixels.
song The map: title, artist, difficulty, timing (tempo points) and more.
judgements The judgement tiers of the play.

The script is loaded fresh at every launch: nothing carries over from one play to the next, and you can edit it between two plays without restarting the game. playfield.set and lanes.set work in setup; elsewhere they work only in handlers during a play, see changing the playfield during a play.

The playfield values

playfield.set(spec) merges spec into the description of the playfield: the fields you give replace those of earlier calls, the others stay. lanes.set({ column, lane }) merges a lane description into lane column (from 0, at most 32 lanes). A value you never give keeps the engine's default look, so a skin with no playfield.set draws the historical playfield.

Two rules explain most of the numbers:

  • Positions are fractions of the screen (x of its width, y of its height). Sizes and offsets are fractions of the screen height, so the playfield keeps its proportions at any resolution.
  • A note travels 0.8 screen heights during the scroll time the player chooses.

The field reference lists all 116 fields with kind, bounds and a note each. The defaults most skins start from:

Value Default
x, y, anchor 0.5, 0.5, center
laneWidth, laneGap, laneHeight 0.085, 0.003, 0.9
receptorY 0.85 (notes scrolling down), 0.15 (up)
noteSize, receptorSize 0.0725 × 0.0725, 0.0775 × 0.0775
laneColor #454d61
backgroundTint #818181 (the map background at 22 %)

Without values, the lanes take in turn the arrows left, down, up, right of the default skin, with its key, hold body and hold end images. Those key images are 198 × 566 px, so give a receptorSize 2.86 times taller than wide if you rely on them, as content/skins/default/skin.ts does.

A few things the reference does not repeat:

  • Hold ends. holdEnd is written like a note: its tip, the bottom of the image, aims at the receptors when notes fall. The game flips it so it points away from the receptors, whatever the zoom and rotation. holdMatchNoteWidth makes the body as wide as the note and the end as wide as the body, so a bigger note grows them together.
  • Visual offsets. noteOffsetY, holdEndOffset, receptorOffsetX/Y and the other offsets move images along the scroll without touching judging, hold timing, score or replays.
  • Lane cover, measure lines, beat lines and note snap colors are native and off by default, including in the default skin. A skin turns them on with laneCover: true, measureLines: true, noteSnapColors: true; a map script can too, and the player in the editor. They are visual only.
  • Missed holds (holdMissedStyle) are dimmed, not hidden, unless you ask for hide.
  • Hit light. hitLightOn is all or off. There is no mode for long notes only.
  • Key light, stage light, hit light, hold light are four separate mechanisms with their own fields; the reference lists them.
  • Colors are #rgb, #rgba, #rrggbb or #rrggbbaa. A tint multiplies its image in the shader; a color without an image tints a white rectangle.

The three layers

A value is resolved in three layers. The highest layer that gives the value wins, value by value:

  1. the skin (setup of skin.ts, and its handlers),
  2. the map script of the map being played, if any,
  3. the player's configuration for this skin (skinConfig[skinId], set in the in-game skin editor).

Inside one layer, a lane's value beats the playfield value: lanes[column], then the playfield's, then the engine's default. The player's layer also beats a playfield.update in progress, live.

The layers do not check the same bounds:

Value Skin and map script Player
x, y 0 to 1 −1 to 2
zoom 0 to 4 0.25 to 4
rotation (degrees, clockwise) −3600 to 3600 −180 to 180

Other bounds are the same for all layers: laneWidth 0.005 to 0.5, laneGap 0 to 0.1, sizes 0 to 2, visual offsets −0.5 to 0.5, lane offsetX/Y −2 to 2, transitionMs 0 to 10000. A few fields are for scripts only and not in the player's editor: anchor, width (the total width, which wins over laneWidth of the same layer) and lanes itself.

Images and frames

An image is a .png file of the skin folder, named by its relative path. The name must end in .png and the content must really be a PNG: anything else is an error.

  • Limits. 4 MiB and 2048 px per side at most. Images are reduced to 640 px on their longest side and packed into one atlas of 2048 × 4096 px, with at most 256 images per layer. An image that does not fit is ignored and a white rectangle is drawn. No mipmaps: bilinear sampling is fine down to about half size.
  • Filtering. textureFilter: "linear" (default) keeps scaled sprites smooth; "nearest" keeps pixels sharp, for pixel art.
  • Loaded before the play. Every image is decoded at launch; nothing is decoded while playing. The images are those setup names in playfield.set and lanes.set, plus those defineSkin({ images: [...] }) declares (64 at most). A handler that names any other image throws [...] were not loaded when the play started: name them in `setup` or declare them in `images` .
  • Animations. hitLight and holdLight take a pattern with the token {n}, replaced by 0, 1, 2… for each frame (fx/spark-{n}.png), and hitLightFrames / holdLightFrames give the count, 1 to 32. The default rate is 60 frames per second (…Fps, 1 to 240), in real time. A pattern needs {n} when it has more than one frame; a single frame needs no token. A missing frame is reported and the animation is shorter.
  • Player images. The player may import PNG, JPEG or WebP files (4 MiB, 2048 px, 64 per skin) and name them player:<file> in the editor. Your skin never has to handle them.

A complete skin with images:

// Sparks: a skin with images. The notes are blue gems, every hit plays a four-frame ring
// (`fx/spark-0.png` to `fx/spark-3.png`) on its lane in the color of the judgement, and the
// notes turn gold during the first 25 combo of every 100.
//
// An image a handler puts on the playfield during the play must be loaded before it starts:
// `images` declares `notes/gold.png`, which `setup` itself never names.

const GOLD = "notes/gold.png";
const BLUE = "notes/note.png";

export default defineSkin({
  id: "sparks",
  name: "Sparks",
  version: "1.0.0",
  apiVersion: 2,
  author: "Prism docs",
  description: "Blue gems and a ring of light on every hit.",
  images: [GOLD],
  setup(play: PlayContext) {
    const laneWidth = Math.min(0.09, 0.4 / play.columns);
    playfield.set({
      laneWidth,
      laneGap: 0.002,
      noteSize: { width: laneWidth, height: laneWidth },
      receptorSize: { width: laneWidth, height: laneWidth },
      note: BLUE,
      laneColor: "#10182ac8",
      // `{n}` is replaced by 0, 1, 2, 3: one file per frame, 30 frames per second. No size is
      // given: the ring is twice the width of the lane and its height follows the image.
      hitLight: "fx/spark-{n}.png",
      hitLightFrames: 4,
      hitLightFps: 30,
      hitLightFollowJudgement: true,
      keyLightFadeMs: 60,
      textureFilter: "linear",
    });
    let gold = false;
    ctx.on("game.judgement", (judgement: JudgementEvent) => {
      const now = judgement.combo >= 100 && judgement.combo % 100 < 25;
      if (now === gold) return;
      gold = now;
      playfield.update({ patch: { note: gold ? GOLD : BLUE } });
    });
  },
});

notes/gold.png appears only in a handler, so images declares it. The ring frames are named in setup, so they need no declaration.

Sounds

hitSound names a sound file of the skin: .wav, .ogg (Vorbis), .flac or .mp3. It plays when the player presses the key of the lane, if Settings, Audio, key sounds is on (off by default). Set it for the whole playfield or per lane:

playfield.set({ hitSound: "sounds/tap.wav" });
lanes.set({ column: 2, lane: { hitSound: "sounds/kick.wav" } });

The path follows the rules of images. A file over 1 MiB, unreadable or missing plays the game's sound instead and writes a line in the log. An unknown extension is reported at launch: "<path>" must be a .wav, .ogg, .flac or .mp3 sound. Only the first second is used, ended by a short fade, decoded before the play. The sound is read once at launch: a playfield.update does not change it during the play. A skin without hitSound imposes none.

Fonts

fonts maps a name to a .ttf or .otf file of the folder: fonts: { title: "fonts/title.ttf" }. Names have 1 to 64 characters among letters, digits, space, -, _ and ., at most 8 fonts, 8 MiB each: the game loads at most that, and a larger font, although the import accepts it, does not load. As with a mod, the font is published as the family <skin id>/<name>, and a font option of an element takes that full name (font: "demo-fonts/cantarell"); a bare name is read in the fonts of the mod that owns the element. The native playfield does not draw text: fonts are for the HUD. The example content/skins/demo-fonts uses Cantarell (SIL Open Font License 1.1), whose licence text is in a comment at the end of skin.ts.

One skin for each key count

There are two things that go by this name.

Inside one skin, read play.columns (4 to 9, and 10, 12, 14 or 16 for a double play) and give each layout its own values, as the default skin does: columns of 62 px at 4K and 58, 54, 50, 46 and 42 px for 5K to 9K on a virtual screen of 480, different key images for the odd layouts. In ember, the lane width is computed from play.columns.

Across skins, the player may pick a skin for each key count: Skins page, Actions menu, Skin per key count, one card per layout of the game (4K to 16K). Each launch loads the skin assigned to its key count, and the global skin serves the counts with no choice. A skin that is no longer installed falls back to the first available one, with a warning. The choice is not exported with the settings. It is off in safe mode and when the game is started with --skin. The element options in Settings and the skin editor follow the global skin.

The default skins

The game ships two skins, in content/skins/. They are plain folders: copy one under another name to start your own.

Skin What it is
default ("Prism Default") The default. The osu! skin "PRISM // arrow (cap ends)" by april, converted by hand for 4K to 9K: columns of 62 px at 4K and 58, 54, 50, 46, 42 px for 5K to 9K on a 480 px screen, dark columns #07090f96, arrows and lit keys, hold bodies and caps, stage light and hit and hold light animations (fx/explosion-{n}.png, fx/holdlight-{n}.png). About 518 KiB in 40 files.
default-circle ("Default Circle") The 4K layout of the osu! skin by tekkito2, extended to 5K to 9K: round notes (an outer circle on the edge columns, an inner one elsewhere), columns of 72 px (66 px at 8K, 58 px at 9K), the judgement line on, a lighter scratch column at 8K. 7 files, about 33 KiB.

Both turn on holdMatchNoteWidth, place the HUD with ctx.element(…).configure({ … }), and keep their HUD code in a separate section of skin.ts. The folder of a shipped skin stays under 900 KiB.

The player's configuration and the skin editor

Every skin has its own player configuration, Settings.skinConfig[skinId] (64 skins at most): a playfield part and the options of the HUD elements the skin places. It never edits the skin's files; it is a separate layer on top.

The player reaches it from the Skins page: Customize skin on the card of the skin in use. The editor runs a frozen demo under the overlay; clicking the playfield, a lane, a hold end or a HUD element selects it and shows its values. The panel lists the catalogue of the field reference: a Simple / Advanced switch (simple lists the marked fields only), tabs, collapsible sections, a Modified filter and a search over the whole catalogue. Per lane, offsetX and offsetY place each lane freely. A customized skin shows a badge on the Skins page, and Reset customizations removes its configuration.

The catalogue comes from the game, not from the skin: every skin, even a minimal one, gets the lane cover, measure lines and the other native groups, off by default.

Live preview. The top bar of the editor has Live preview: a real map from the library, by default the selected one, plays in Auto behind the editor with the real clock, lights and HUD. It has no effect on score, replays, profile or settings. The sound is off by default and the map loops. A lab at the bottom offers an imperfect autobot (Human, Chaos) to see every judgement tier on your skin, slow motion, freezing on an event and a table of the windows. The protocol and its limits are not part of what a skin author needs.

Changing the playfield during a play

From a handler (game.judgement, game.tick, game.beat, game.pause…) a skin can change any field of the playfield, colors and images included:

ctx.on("game.judgement", (judgement: JudgementEvent) => {
  lanes.set({ column: judgement.column, lane: { receptorColor: judgement.tier.color }, transitionMs: 0 });
  if (judgement.combo % 100 === 0) {
    playfield.update({ patch: { note: "notes/gold.png", laneWidth: 0.09 }, transitionMs: 300, easing: "easeOut" });
  }
});
  • playfield.update({ patch, transitionMs?, easing? }): patch is a partial PlayfieldSpec (lanes included). lanes.set({ column, lane, transitionMs?, easing? }) does the same for one lane.
  • transitionMs is 0 to 10000 (absent or 0: at once). easing is linear (default), easeIn, easeOut or easeInOut.
  • Numbers and colors animate from the displayed value to the new one. Images, the anchor and the scroll direction change at once. Each value has its own transition: a change only interrupts the transitions of the values it changes. The transition follows the song clock, so a pause freezes it.
  • These calls only work in setup and, in a handler, between game.songStart and game.songEnd. Anywhere else they throw the playfield only changes while a chart plays: call it from a handler between `game.songStart` and `game.songEnd` .
  • Each call is checked (bounds, colors, paths, lane under 32) and throws in your script on a mistake. The number of lanes does not change, and judging is untouched: these changes are visual.
  • Changes of one step of the mod thread with the same transition are merged into one (the last values win); those with different transitions stay apart, in order, at most 8 per step. They go through a queue of 64 that the mod thread fills without ever waiting; when it is full they are kept for the next step. Light the lane, then bring it back in one handler: two calls with two transitions.
  • The game.playfield() entity of mods stays the layout of the launch.

Because every handler runs on the mod thread with a budget (30 ms per call, see budgets), start transitions on beats or judgements and let the renderer animate; do not move things frame by frame.

Native drawing with stage

A skin that declares permissions: ["stage"] can also draw in the native renderer with stage.*: sprites, rectangles, text, particle emitters and triggers, in step with the notes. Without the permission every stage.* call throws. A sprite or an emitter can only name an image declared in defineSkin({ images }); those images are decoded with the playfield's, in the same atlas. Like the rest of the script, the skin's stage elements start from zero at every launch. The functions and their limits are in native drawing.

Loading without slowing the game

map launch (main thread)
  └─ helper thread
       one queue of playfield changes per layer (skin, map script)
       prepare_play ──> mod thread: skin.ts loaded fresh, setup(play),
                        then the map script, loaded fresh, setup(play)
       waits for the two PlayfieldSpec and the image lists (1 s at most)
       skin::prepare: validation, PNG decoding, one atlas
  └─ main thread: the prepared playfield, then the start
render thread: one texture upload before the first frame;
               each frame: pending changes, transitions, drawing

The render thread never reads a file or decodes an image. A frame with no change and no transition reads one slot of a queue and allocates nothing. If the mod thread does not answer in 1 second, the play starts with the engine's default look.

Errors you will see

Nothing invalid stops the play. Each problem is reported in the mods log during setup, as a banner at launch, and on the Skins page, where the skin in use lists the problems of its last launch.

What went wrong What the game does
Number out of bounds in setup, playfield.set The value is brought into the bounds: laneWidth: 0.9 is outside [0.005, 0.5]; 0.5 is used. Not finite: the default is used.
Invalid color or path The next value of the chain (lane, playfield, default) is used.
Image missing, unreadable, not a PNG, over 4 MiB or over 2048 px A white rectangle: "<path>" is 4096×4096 pixels; the limit is 2048×2048.
Too many lanes lanes: 40 lanes; the limit is 32, the extra ones are ignored.
More than 256 images used in a layer N images are used; the limit is 256, for the others a white rectangle is used.
defineSkin invalid, skin.ts throws, setup over budget The play uses the engine's plain defaults, and the error is reported.
The chosen skin folder is missing The first available skin is played, and the loss is reported.
Nothing from the mod thread in 1 s The play starts with the engine's look.

In a handler during the play, the same mistakes are not corrected: the call throws, in your script, with these messages.

Message Cause
<field>: <v> is outside [min, max], <v> is not a finite number A number out of bounds or not finite.
lane N does not exist: there are at most 32 lanes A column of 32 or more.
<name>Frames: N is outside [1, 32] A frame count out of range.
"<pattern>" needs the {n} token that each frame number replaces A multi-frame light pattern with no {n}.
"<path>" must be a .png image An image that is not a .png path.
transitionMs: … A transition outside 0 to 10000.
[...] were not loaded when the play started: name them in `setup` or declare them in `images` An image the play did not load.
`playfield.set` is only available to skins and map scripts The call is made from a mod.
`<fn>` only works in the skin's `setup` and in its handlers during a play The call is made at the top level or from an event outside a play.
`images` declares N images; the limit is 64 and image "<p>" must be a .png file A bad images list in defineSkin.
the skin already uses the id … The id is also a mod's.
the skin has no `defineSkin` declaration skin.ts never called defineSkin.

A mistake the type checker catches before the game does, because hitLightOn has only two values:

playfield.set({ hitLightOn: "holds" });

Managing skins

The Skins page (Esc menu) lists skins with preview, name, version, author, the skin in use and its problems. Its buttons: Use, Export, Delete (to the recycle bin), Import, Open folder, Reload. Changing the skin restarts the mod host (outside a play) and applies from the next launch. The files of a skin are re-read at every map launch, so a change shows after the next launch without a reload; Reload only refreshes the list.

  • The skin setting holds the folder name (default by default). An invalid name becomes default; a missing folder is reported and the first available skin is used. prism.exe --skin <id> picks any skin, for a benchmark or a smoke test.
  • Delete removes a skin of the player's folder and its skinConfig[<id>]. It never removes a skin shipped with the game, nor the skin in use, nor during a play.
  • Export writes <id>.zip, without hidden files. Every other file must be .ts, .png, .ttf, .otf, .wav, .ogg, .flac or .mp3.
  • Import installs a .zip as a new folder and never replaces an existing skin: the folder name comes from the root folder of the archive, with -2, -3… added if needed. The whole archive is checked before anything is written; see the skin package format.
  • Safe mode plays default with no player configuration and no map script.
  • The Actions menu also offers Convert an osu! skin, see importing an osu! skin.

Pitfalls

  • Calling playfield.set at the top level, outside setup: it throws.
  • A handler that names an image setup and images do not know.
  • Moving things on every game.tick: 30 ms per call is a hard budget, and three overruns disable the script. Start a transition instead.
  • Expecting a holds value for hitLightOn: there are all and off only.
  • Giving the skin a different id and folder name: the player's configuration and the skin selection follow the folder name.
  • Putting a .zip in the skins folder: it is not a skin until imported.
  • Forgetting that the player's layer wins: if a value you set seems ignored, the player may have set it in the editor, within other bounds than yours.

See also

Source in the game repository: docs/skins.md,crates/skin/src/spec.rs,crates/skin/src/prepare.rs,crates/skin/src/player.rs,crates/skin/src/package.rs,crates/skin/src/paths.rs,crates/modding/src/manifest.rs,crates/modding/src/api.rs,crates/modding/src/play.rs,content/skins/default/skin.ts