miwale

Trick or Treat — Game Art Style Spec

A glossy Halloween candy world: hard-candy shine, gummy jelly, matte marshmallow and chocolate on a melting chocolate floor.

Everything in this world is edible and rendered like a premium candy commercial. Each body part is a path filled with a radial gradient lit from the top-left, then given clipped "material passes": a saturated jelly edge, a warm inner glow, ribs or stripes, a lower-right rim light, and sharp white speculars. The finished sprite gets one soft cocoa-plum silhouette outline and nothing else. Below the characters lies a milk-chocolate bar floor with sunken caramel pools, pink strawberry sugar-sand, raised mint frosting with dripping glossy edges and dark cookie-crumb paths, all sprinkled with sprinkles. In the module's example cast the main character has a round hard-candy orange head on a licorice body; the creatures are two-layer gummy root bulbs, matte marshmallow floating sheets and a large dark-chocolate figure with glowing caramel cracks.

At a glance

PropertyValue
FamilyRendered Cartoon · Candy Gloss
Moodsweet, playful, glossy, festive, cheeky
Best forcute top-down action, casual arcade, character puzzle games, holiday events
RendererCanvas 2D, procedural, no image assets
Pixel artNo (smooth, sprites baked at 3–6 px per world unit)
Complexity6/10 – convincing gloss takes iterations; every new asset risks candy chaos
FontsChewy (numbers, titles), Sniglet 400/800 (labels, body)
Key colours#7e4c32 chocolate, #3a1424 cocoa outline, #ff8d1e candy orange, #ffe07a caramel glow, #9443d8 / #d83a8e / #5b52e0 gummies, #f4acc2 pink sugar, #a0dab8 mint

When to use it

Color palette

SwatchHexRole
Milk chocolate#7e4c32Ground base and 34-unit bar grid (~45% of the screen)
Choc groove#5d3825Grooves between chocolate bars (base × 0.74)
Caramel edge#ec9c3aCaramel pool edge band
Caramel deep#b25a1aCaramel pool interior
Strawberry sugar#f4acc2Pink sugar-sand meadows
Mint frosting#a0dab8Mint frosting meadows
Cookie crumb#543226Dark cookie-crumb paths
Cocoa outline#3a1424Every outline, HUD border, text outline; shadows use rgba(45,12,22,·)
Candy orange#ff8d1eMain character's round head, mid (light #ffd08a, dark #d24e0b)
Caramel glow#ffe07aGlow inside carved faces, cracks, halos
Licorice#2c1a2aMain character's body/limbs (light #6a4a66, dark #120810)
Mint scarf#3fd6c1Main character's accent, white-striped (dark #1fa596)
Gummy purple#9443d8Small gummy creature (hi #d9a2ff, dark #56168f)
Gummy pink#d83a8eSmall gummy creature (hi #ffa6d2, dark #86104f)
Gummy blue#5b52e0Small gummy creature (hi #b8b0ff, dark #262092)
Jelly leaf#55cc48Leaves (light #c9ff9e, dark #22852e)
Marshmallow#fbf5fbFast floating creature (white centre, edge #dccbe4)
Dark chocolate#55291aLarge creature (light #9a5e3e, dark #2a120a)
Hot pink#ff5c9eImpact-star outline, number stripes, accents
Sugar flash#fff3f8Flash tint

Sprinkle set (fixed): #ff4f8b #ffd23a #4fd6ff #7ee26a #b88cff #ff9a3a #ffffff.

Palette rules

Typography

Chewy (400) — HUD numbers, timer, titles, floating numbers, card names. https://fonts.google.com/specimen/Chewy Sniglet (400, 800) — labels, descriptions, hints. https://fonts.google.com/specimen/Sniglet Load: https://fonts.googleapis.com/css2?family=Chewy&family=Sniglet:wght@400;800&display=swap

.timer { font: 400 38px/1.1 'Chewy', cursive; letter-spacing: 2px; color: #fff;
  /* 16-direction cocoa outline (generated) + 2 px drop below */
  text-shadow: 2.5px 0 0 #3a1424, -2.5px 0 0 #3a1424, 0 2.5px 0 #3a1424, 0 -2.5px 0 #3a1424,
               1.8px 1.8px 0 #3a1424, -1.8px 1.8px 0 #3a1424, 1.8px -1.8px 0 #3a1424, -1.8px -1.8px 0 #3a1424,
               0 4.5px 0 #3a1424; }
.label { font: 800 12px/1 'Sniglet', sans-serif; letter-spacing: 1.6px; color: #fff3e0; text-shadow: 0 1px 0 rgba(120,30,0,.8); }
.title { font: 400 84px 'Chewy', cursive; letter-spacing: 3px; color: transparent;
  background: repeating-linear-gradient(-50deg, #fff 0 14px, #ff7ab0 14px 26px); -webkit-background-clip: text; background-clip: text;
  filter: drop-shadow(2.5px 0 0 #3a1424) drop-shadow(-2.5px 0 0 #3a1424) drop-shadow(0 2.5px 0 #3a1424) drop-shadow(0 -2.5px 0 #3a1424) drop-shadow(0 6px 0 #3a1424);
  transform: rotate(-3deg); }

Text effects: the module builds text-shadow from 16 offsets on a circle of radius w (tso(w, col, drop)), optionally plus 3 shadows pushed down by drop px for a 3-D "candy button" base. Titles are peppermint-striped (white/pink at −50°) via background-clip: text, tilted −2…−3°.

Floating numbers on canvas: Chewy at 9.5 units (large variant 13), fallback bold "Sniglet", "Arial Rounded MT Bold", sans-serif. Stroke cocoa at 0.42·size twice (second one offset 0.08·size down), then white stroke 0.2·size, then fill: small = white with pink stripes rgba(255,92,150,.85) at −0.7 rad (stripe 0.15·size, pitch 0.33·size); large = vertical gradient #fff27a → #ffbe2e → #ff7a1a with white stripes; finally a top gloss gradient (white 0.65 → 0). Pop scale 0.3 → 1.35 → 1.0, fade in the last 18%.

Rendering technique

  1. Units. The camera shows 360 world units vertically; S = screen px per unit. Sprite bake resolution K = clamp(round(S·1.25), 3, 6) px per unit.
  2. Bake at init (build(box, fn, opt)): create a canvas for the world-space box + 1-unit margin, scale(K), translate(-left, -top), round joins/caps, run the part-drawing function, then add the outline: make a solid copy tinted #3a1424 (source-atop), stamp it 12 times (16 if the outline is > 2.5 px) on a circle of radius ol·K px, draw the original on top. Default ol = 0.5 units.
  3. Per character: 4 walk frames × {normal, flash-tinted #fff3f8, mirrored, mirrored flash} (set4). The main character also has a 4-frame alternative-face set. Marshmallow figures get a destination-in gradient fade at the hem (alpha 1 at y = −8 → 0.35 at y = 1).
  4. Part drawing order inside a sprite (back to front): back accessories (scarf tail, leaves) → back arm → legs → body → front details → front arm → collar/scarf → head → face → speculars → leaf on top.
  5. Material passes per part: (a) gloss radial fill; (b) clipped passes (clipDo): jelly edge, inner glow, stripes, ribs, grooves; (c) rim lower-right light; (d) spec white ellipses.
  6. Ground: per-pixel material compositing into 256-unit chunks (generator, yields every few rows), max 2.5 px/unit; decals stamped afterwards at 4 px/unit.
  7. Per frame: ground chunks → ground overlay (wrapper decals) → collectibles → shadows → y-sorted props/creatures/main character → orbiting objects → projectiles → particles → numbers → world overlay (drifting sugar sparkles, additive) → screen overlay (vignette).
  8. All dynamic motion (squash, bob, tilt, flash) is applied at blit time through the transform; nothing is re-rendered per frame.

World and ground

The floor is computed per pixel from noise fields sampled on a 4-unit grid and bilinearly interpolated; each material layer is a signed field (positive = inside) whose value divided by its gradient gives a distance in pixels → perfectly antialiased edges plus distance-based shading. The ground stays mid-value and warm so the saturated figures pop.

Characters

All figures are chunky toy shapes built from glossy primitives; each part gets the gloss recipe and a material pass, and the whole sprite gets one soft cocoa outline (0.5 units). Faces either glow caramel (carved holes) or sparkle (glossy dark eyes with yellow and white catchlights). The material encodes the figure type.

Main character (sprite box −14…14 × −33…2 units, drawn at scale 1.06)

Small creature — two-layer gummy root bulb (box −13…13 × −31…1.5, scale ×0.92)

Fast floating creature — marshmallow sheet (outline 0.45 in #5a3a66)

Large creature — dark chocolate (box −28…28 × −67…2, outline 0.6)

Props

All props use the same gloss recipe (top-left radial, white specs, lower-right rim) with a 0.45-unit cocoa outline (lollipops and cupcake houses 0.55), a warm soft shadow sized per prop, and are y-sorted with the characters. They are chosen to match the ground material they stand on.

Effects and particles

All particles are baked sprites with the same outline rule; only sparkles are additive.

Atmosphere and lighting

UI

Candy-shop buttons: thick cocoa border (3–4 px), solid cocoa "base" drop of 4–5 px, a universal glossy overlay (GLOSS), peppermint stripes in dark chocolate troughs, an orange wrapped-candy timer badge with zig-zag cellophane ends (CSS clip-path), a pink pill counter with sprinkle dots, cards with a coloured candy top (pink/mint/yellow) on cream.

:root { --cocoa: #3a1424;
  --gloss: linear-gradient(180deg, rgba(255,255,255,.6) 0%, rgba(255,255,255,.12) 45%, rgba(255,255,255,0) 55%, rgba(60,0,30,.18) 100%); }
.bar { position: relative; width: 260px; height: 30px; background: linear-gradient(180deg, #3d1a14, #6a3624);
  border: 3px solid var(--cocoa); border-radius: 16px; box-shadow: 0 4px 0 var(--cocoa), inset 0 4px 6px rgba(0,0,0,.45); overflow: hidden; }
.bar > .fill { position: relative; height: 100%; border-radius: 0 13px 13px 0;
  background: var(--gloss), repeating-linear-gradient(-55deg, #ff2f55 0 12px, #fff5f7 12px 22px);
  box-shadow: inset 0 -3px 0 rgba(120,0,30,.25), inset -3px 0 0 rgba(255,255,255,.45); }
.bar > .fill::after { content: ''; position: absolute; left: 9px; right: 12px; top: 4px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.75); }
.bar.mint > .fill { background: var(--gloss), repeating-linear-gradient(-55deg, #35d0c0 0 11px, #effffb 11px 20px); }
.badge { padding: 4px 30px 8px; border-radius: 999px; border: 3px solid var(--cocoa);
  background: var(--gloss), radial-gradient(ellipse at 50% 120%, #ffb347 0%, #ff8a1a 45%, #e8590c 100%);
  box-shadow: 0 5px 0 var(--cocoa), inset 0 -4px 0 rgba(140,40,0,.25); }
.pill { border-radius: 999px; border: 4px solid #c98a4e; box-shadow: 0 0 0 3px var(--cocoa), 0 5px 0 3px var(--cocoa);
  background: var(--gloss), linear-gradient(180deg, #ffc3dc, #ff8fbf); }
.card { width: 236px; min-height: 306px; border: 4px solid var(--cocoa); border-radius: 30px; color: var(--cocoa);
  background: var(--gloss), linear-gradient(180deg, #ff8fbf 0, #ff5c9e 96px, #fff4ea 96px, #ffe6d2 100%);
  box-shadow: 0 0 0 5px #8a4a2a, 0 0 0 8px var(--cocoa), 0 12px 0 8px var(--cocoa), 0 24px 34px rgba(30,5,20,.45); }
.card .icon { border-radius: 50%; background: radial-gradient(circle, #fff9fc 0 54%, transparent 55%), repeating-conic-gradient(#fff 0 7deg, #ffd0e2 7deg 14deg);
  box-shadow: 0 0 0 4px var(--cocoa), 0 5px 0 4px var(--cocoa); }
@keyframes candyPop { from { transform: scale(.2) rotate(-14deg); } to { transform: scale(1) rotate(-3deg); } }
@keyframes candyWobble { 0%,100% { transform: none } 30% { transform: scale(1.06,.92) } 65% { transform: scale(.96,1.05) } }

Icons are drawn with the same canvas material functions on a 48×48 grid (glossy jelly heart, gummy lightning bolt, waffle basket of wrapped candies, pink soup bowl) and outlined with max(1.5, size/26) px cocoa. Card icon backgrounds use a pink/white peppermint sunburst.

Motion and animation

Do and don't

Do

Don't

Implementation recipe

  1. Set up a world of 360 units visible height; compute S = canvasHeight / 360 and K = clamp(round(S·1.25), 3, 6).
  2. Write the helpers: gloss, spec, softSpec, rim, clipDo, jelly, caramelHole, shape builders (E, CAP, roundPoly, blobPath, turnipPath/your silhouette, leafPath), and build() with the 12-stamp outline.
  3. Define materials as colour triples: hard candy, licorice, gummy (per variant hi/top/dk + edge + glow), marshmallow, chocolate, jelly leaf.
  4. Design the main character head-heavy: a big glossy head (≈ 22×18 units) on a small dark body (≈ 9 units) with bright accents (scarf, shoes). Draw back-to-front, finishing with speculars.
  5. Build each creature type from one material; give it 4 frames by moving feet/leaves slightly; bake normal, flash-tinted and mirrored sprites.
  6. Bake collectibles (wrapped candies), projectiles (candy seed + streak), particles (sprinkles, gummy chunks, puffs, impact star, sparkle) and the shadow sprite.
  7. Build the ground: chocolate base with bar grid, then noise-driven material regions (caramel sunken, sugar flat with grain, frosting raised with drips and gloss line, cookie paths). Cache in chunks; stamp decals with tiny shadows.
  8. Place props (lollipop trees, gumdrop bushes, fences, gravestones, cupcake houses) by material; y-sort them with the characters.
  9. Per frame: blit sprites with squash/stretch/tilt transforms, additive glows behind light sources, particles, floating numbers, ambient sparkles, plum vignette.
  10. Style the HUD with the CSS above: cocoa borders + base drop, gloss overlay, peppermint bars, Chewy numbers with the 16-direction outline.

Code

The snippets below are the core techniques from the module, standalone. A complete runnable kit (main character, small gummy creature, floating marshmallow creature, lollipop, wrapped candies, chocolate/caramel/sugar/mint/cookie ground, impact effect) is in starter.js; the full reference is ../../js/styles/candy.js.

// Material core: top-left lit radial fill, white specular, lower-right rim light.
const TAU = Math.PI * 2;
function rg(c, x0, y0, r0, x1, y1, r1, stops) { const g = c.createRadialGradient(x0, y0, r0, x1, y1, r1); for (const s of stops) g.addColorStop(s[0], s[1]); return g; }
function lg(c, x0, y0, x1, y1, stops) { const g = c.createLinearGradient(x0, y0, x1, y1); for (const s of stops) g.addColorStop(s[0], s[1]); return g; }
function gloss(c, path, cx, cy, r, light, mid, dark) {
  c.beginPath(); path(c);
  c.fillStyle = rg(c, cx - r * 0.38, cy - r * 0.45, r * 0.05, cx, cy, r * 1.18, [[0, light], [0.5, mid], [1, dark]]);
  c.fill();
}
function spec(c, x, y, rx, ry, rot, a = 0.9) {
  c.save(); c.globalAlpha = a; c.fillStyle = '#fff';
  c.beginPath(); c.ellipse(x, y, rx, ry, rot, 0, TAU); c.fill(); c.restore();
}
function clipDo(c, path, fn) { c.save(); c.beginPath(); path(c); c.clip(); fn(c); c.restore(); }
function rim(c, path, x0, y0, x1, y1, col, w) {          // stroke clipped inside the path
  clipDo(c, path, (k) => {
    k.lineWidth = w;
    k.strokeStyle = lg(k, x0, y0, x1, y1, [[0, 'rgba(255,255,255,0)'], [0.6, 'rgba(255,255,255,0)'], [1, col]]);
    k.beginPath(); path(k); k.stroke();
  });
}
// usage: a hard-candy ball r=10
// const p = (k) => k.arc(0, 0, 10, 0, TAU);
// gloss(ctx, p, 0, 0, 10, '#ffd08a', '#ff8d1e', '#d24e0b');
// rim(ctx, p, -10, -10, 10, 10, 'rgba(255,236,150,0.9)', 2.2);
// spec(ctx, -4, -4.5, 2.9, 1.35, -0.6, 0.92); spec(ctx, -1.2, -6.5, 0.75, 0.6, 0, 0.95);
// Gummy / jelly: milky core + saturated inner edge band + subsurface glow lower-right.
function jelly(c, path, cx, cy, r, edgeCol, glowCol) {
  clipDo(c, path, (k) => {
    k.fillStyle = rg(k, cx - r * 0.1, cy - r * 0.05, r * 0.1, cx, cy, r * 1.1,
      [[0, 'rgba(255,255,255,0.28)'], [0.55, 'rgba(255,255,255,0.06)'], [1, 'rgba(255,255,255,0)']]);
    k.fillRect(cx - r * 2, cy - r * 2, r * 4, r * 4);
    k.lineWidth = r * 0.42; k.strokeStyle = edgeCol;          // half of it is clipped away -> 0.21r band
    k.beginPath(); path(k); k.stroke();
    if (glowCol) {
      k.fillStyle = rg(k, cx + r * 0.42, cy + r * 0.45, 0, cx + r * 0.42, cy + r * 0.45, r * 0.7, [[0, glowCol], [1, 'rgba(255,255,255,0)']]);
      k.fillRect(cx - r * 2, cy - r * 2, r * 4, r * 4);
    }
  });
}
// purple gummy: gloss(c, body, 0, -12, 10.5, '#d9a2ff', '#9443d8', '#56168f');
//               jelly(c, body, 0, -12, 10.5, 'rgba(80,10,140,0.55)', 'rgba(255,170,255,0.55)');
// Carved face hole glowing with caramel: dark fill, then the same path shifted (0.2, 0.55) with the glow ramp.
function caramelHole(c, path, bx, by, br) {
  c.beginPath(); path(c); c.fillStyle = '#7a2406'; c.fill();
  clipDo(c, path, (k) => {
    k.translate(0.2, 0.55);
    k.beginPath(); path(k);
    k.fillStyle = rg(k, bx, by, 0, bx, by, br, [[0, '#fffbd6'], [0.35, '#ffe07a'], [0.75, '#ffa12a'], [1, '#e2650e']]);
    k.fill();
  });
}
// Bake a sprite at k px/unit and add the soft cocoa silhouette outline (12 stamped tinted copies).
function build(box, k, drawFn, ol = 0.5, olc = '#3a1424') {
  const m = 1, l = box[0] - m, t = box[1] - m;
  const c = document.createElement('canvas');
  c.width = Math.ceil((box[2] + m - l) * k); c.height = Math.ceil((box[3] + m - t) * k);
  const x = c.getContext('2d');
  x.scale(k, k); x.translate(-l, -t); x.lineJoin = 'round'; x.lineCap = 'round';
  drawFn(x);
  const tint = document.createElement('canvas'); tint.width = c.width; tint.height = c.height;
  const tx = tint.getContext('2d');
  tx.drawImage(c, 0, 0); tx.globalCompositeOperation = 'source-atop'; tx.fillStyle = olc; tx.fillRect(0, 0, c.width, c.height);
  const o = document.createElement('canvas'); o.width = c.width; o.height = c.height;
  const ox = o.getContext('2d'), w = ol * k, n = w > 2.5 ? 16 : 12;
  for (let i = 0; i < n; i++) { const a = (i / n) * TAU; ox.drawImage(tint, Math.cos(a) * w, Math.sin(a) * w); }
  ox.drawImage(c, 0, 0);
  return { c: o, ox: -l * k, oy: -t * k, k };   // anchor = world origin (feet)
}
function blit(ctx, s, x, y, sx = 1, sy = 1) {
  const q = 1 / s.k;
  ctx.drawImage(s.c, x - s.ox * q * sx, y - s.oy * q * sy, s.c.width * q * sx, s.c.height * q * sy);
}
// Main character hop-walk squash & stretch (applied at blit time, sprites stay baked).
function heroPose(anim, moving, t) {
  if (!moving) { const b = Math.sin(t * 3.2); return { frame: 0, lift: 0, sx: 1 - 0.022 * b, sy: 1 + 0.03 * b, rot: 0 }; }
  const ph = anim * 0.42, f = ph - Math.floor(ph), hop = Math.floor(ph), air = Math.sin(f * Math.PI);
  const contact = Math.max(0, 1 - Math.min(f, 1 - f) * 6);
  return { frame: contact > 0.25 ? (hop & 1 ? 1 : 3) : 2, lift: air * 3.2,
           sx: 1 - 0.04 * air + 0.12 * contact, sy: 1 + 0.07 * air - 0.13 * contact, rot: 0.07 * air };
}

Adapting it to your project

Performance notes

Copy-paste prompt

Use the Trick or Treat art style for my project (glossy candy world):
- Canvas 2D, procedural, no image assets; 360 world units of screen height; bake sprites at 3-6 px/unit.
- Everything is candy. Every shape: radial gradient lit from the TOP-LEFT (centre offset -0.38r,-0.45r; stops light / mid @0.5 / dark),
  then clipped material passes, then a lower-right rim light, then sharp white specular ellipses upper-left (alpha 0.9) + a tiny dot spec.
- Materials define figure types: hard candy (main character's round head, inner warm glow, ribs), licorice (#6a4a66/#2c1a2a/#120810),
  two-layer gummy for small creatures (coloured top over milky bottom, saturated inner edge band 0.42r, subsurface glow),
  matte marshmallow for floating creatures (no sharp spec), dark chocolate with glowing caramel cracks for large creatures.
- One soft cocoa-plum outline #3a1424, 0.5 units, around the whole sprite (stamp a tinted copy 12x); no inner ink lines, never black.
- Faces: carved holes glowing caramel (#7a2406 then ramp #fffbd6 > #ffe07a > #ffa12a > #e2650e), or glossy dark eyes with yellow+white catchlights.
- Ground: milk chocolate #7e4c32 with a 34-unit bar grid (dark groove, lit top-left bevel), sunken caramel pools (#ec9c3a > #b25a1a),
  pink sugar-sand #f4acc2 with sparkle grain, raised mint frosting #a0dab8 with drips and a white gloss line, cookie-crumb paths #543226, sprinkle decals.
- Props: lollipop trees, gumdrop bushes, candy-cane fences, cupcake houses – same gloss, 0.45 outline.
- Atmosphere: soft warm ellipse shadows rgba(45,12,22,.42), plum vignette, additive warm glows behind light sources, drifting sugar sparkles.
- Effects: sprinkles (#ff4f8b #ffd23a #4fd6ff #7ee26a #b88cff #ff9a3a #fff) on every impact and pop-out, white-pink impact stars, confetti.
- Motion: squash & stretch everywhere (hop-walk with 12% contact squash, jelly wobble, outElastic reveals, overshoot pops).
- UI: Chewy numbers with a 16-direction cocoa outline, Sniglet labels; 3px cocoa borders with a 5px solid drop, white gloss overlay,
  peppermint-striped bars in dark-chocolate troughs, orange wrapped-candy timer badge.