Blending, dither and halftone

Gradients, glows and shading in a fixed palette — and knitting them as jacquard.

A pixel canvas doesn't have to be painted pixel by pixel. Put ordinary layers inside it, like shapes, vectors, text and images with gradients and opacity, and the canvas draws them through its palette. A color between two palette colors becomes a pattern of those two colors, in proportion. That's how a four-color canvas can show glows, shaded spheres, fades and soft shadows, and still use nothing but its four colors.

Blend layers inside a pixel canvas · 0:05
Description

The Christmas tree knit sweater: its Stitches canvas in four yarns holds a glow, a lit tree, shaded baubles and a ribbon as gradient layers. Off-palette colors is Halftone, so every blend is a dot screen of two yarns. Switched to Dither, the same layers redraw as a fine ordered pattern; the ribbon is a shape with a linear gradient.

This page covers how that works, the settings that control it, and recipes for the common effects. It also covers carrying them into knitwear, where one pixel is one stitch.

Layers inside a pixel canvas

Anything except frames, sections and other canvases can live inside a pixel canvas: rectangles, ellipses, vectors, pen paths, text, images, brush strokes and groups. Drag a layer onto the canvas in the Layers panel to put it inside.

  • Layers draw over the canvas's painted pixels, bottom to top in their layer order, and stay live. Move a shape, edit a gradient stop or retype the text, and the pixels redraw.
  • The inspector counts them: "18 layers rendered as pixels".
  • The layer row beside the pixel timeline lists them too, and can show a layer in only some frames.
  • Merge into pixels bakes the layers into the frame's own pixels and removes them. It's useful once a design is final, or before hand-touching individual pixels.

So a design has two parts:

PartLives inGood for
Painted pixelsthe canvas's own cellsCrisp motifs drawn on purpose: outlines, small icons, borders, patterns, single dots
Layersshapes inside the canvasAnything soft or editable: gradients, glows, shading, type, logos, photos

Off-palette colors

In Indexed (palette) mode, or in RGBA with Snap layer colors to palette on, every layer color has to become a palette color. Off-palette colors in the inspector sets how:

SettingA color between two palette colors becomesTransparency becomesLooks like
Nearest colorthe single closest palette colora hard cut at 50%Flat posterized shapes
Ditheran ordered (8×8 Bayer) mix of the twoa thinning pattern of pixelsFine, even shading; the bird's-eye look of jacquard knitting
Halftonea 45° screen of round dots that grow with the amountthe same dots, getting smallerPrint and pop art; comic shading

Dot size (Halftone only, 2–64, default 6) is the distance between dots in pixels. Small dots read as texture, and large ones read as graphic dots.

The two colors are chosen as a pair. For each color the canvas looks for the two palette colors whose mix comes closest, not just the single nearest color. A light blue-grey over navy and white becomes navy and white in the right proportion, rather than snapping to some other color of about the same lightness. A pair only replaces a flat color when it's clearly closer, so solid fills stay solid and don't speckle.

Why four colors give far more than four

With a palette of n colors, every pair of them can mix:

PalettePairsWhat you can show
2 colors1A full ramp between the two
3 colors3Three ramps
4 colors6Six ramps: each color into each other one

Each ramp has many steps. An 8×8 Bayer pattern gives 64 levels between the two colors, and a halftone screen gives as many as its dot can grow through.

Transparency multiplies this again. A layer at 40% opacity, or a gradient that fades to transparent, is drawn as a density of its colors over whatever is beneath it. Stacking a fading layer over another blended layer puts one pattern over another. With four colors you get each pure color, each pair's ramp, and those ramps layered over each other.

Each pixel is still exactly one palette color. Nothing is invented, so the file prints, embroiders or knits in exactly the colors you chose.

Recipes

Each recipe is a layer inside the canvas. The colors named are fill or gradient stops; for "a color between X and Y", pick a color between them with the fill picker, and the canvas mixes X and Y.

Glow

An ellipse with a radial gradient in one palette color, its alpha fading from about 0.6 to 0 at the edge. In Dither it's a soft cloud. In Halftone it's a ring of shrinking dots.

For a halo that leaves the middle clear, use four stops: transparent at 0, faint near the middle, strongest at about 0.6 of the radius, transparent at 1. Put it under the subject in the layer order.

Shaded ball (baubles, planets, eyes)

An ellipse with a radial gradient whose center sits up and to the left (about 35% across, 30% down): a light color at 0, the body color at 0.35, and a color between the body and a dark palette color at 1. That gives a highlight, a body and a shadowed edge, from three palette colors.

Lit side

A linear gradient across a shape, running from a color between the shape's color and a light color on the lit side, to the shape's own color by about 40%. A tree or a building lit from one side.

Fade and ombré

A full-width rectangle with a vertical linear gradient from one palette color at alpha 0 to the same color at alpha 0.5–0.9. Use it to fade a ground into a border, add dusk over a skyline, or frost rising from a hem. Since it's a density, the painted pixels underneath still show through where it's thin.

Drop shadow

Duplicate a layer, nudge the copy 2–4 pixels down and right, fill it with a dark palette color, and move it underneath. It stays crisp because it's a flat palette color, so it's never blended.

Shaded lettering

Text or a logo with a vertical linear gradient: its color down to about half its height, then into a color between it and the ground color at the bottom. The letters stay solid where it matters and blend into the ground at their feet.

Folded ribbon

A rectangle band with notched tails behind it. Give the tails a linear gradient from their color into a color between it and a darker one, running away from the band, so they look folded back.

Choosing Dither or Halftone

  • Dither for anything that should look smooth or traditional, like knit shading, game sprites and subtle fades. Its pattern is the finest one a grid can hold.
  • Halftone for a graphic, printed look, like comics, posters and pop art. The dots are bigger than single pixels, so they survive coarse grids (stitches, beads, cross-stitch) and read from across a room.
  • The setting belongs to the canvas, not the layer, so switching it re-renders every layer at once. To mix both looks, use two canvases.

Knitwear: jacquard with a pixel canvas

Jacquard knitting is a pixel grid: one pixel is one stitch, and each stitch is one yarn. Knitters shade the same way a dithered canvas does. Two yarns alternate in a fine bird's-eye pattern, and bands fade from one color into another. So a pixel canvas in indexed mode, with its palette set to the yarns, is the knit chart.

The Popprint plugin builds and orders knitwear (Printful's jacquard sweaters and beanies) this way. The Apparel → Knitwear templates in New file are worked examples: every part of their design is a layer inside each panel's Stitches canvas. The snowflakes, stars, hearts, zigzags and borders are flat vector shapes in one yarn each, cut to whole stitches. The pop-art sunbursts, northern-lights curtains, lit trees, shaded baubles, ribbons and snowdrifts are gradient layers, screened with Halftone. The lettering is solid, with a solid outline or drop shadow. Only the trim rows are painted. Select a motif in the Layers panel to move it, recolor it, or delete it.

Rules a knit design has to follow:

  • The canvas size is the stitch grid. Popprint builds each panel at the product's exact grid (for example 511 × 675 for a 3XL crew-neck). Never scale a knit canvas; resize the design instead.
  • At most four yarns, including the base and trim. The palette is the yarns, so blends add shades without adding yarn.
  • Trim rows are knitted in the trim yarn (collar, cuffs, hem) whatever is drawn there. Templates mark them with locked Trim bands.
  • Lone stitches are expected with blending. Popprint reports lone stitches (a stitch with no neighbor of its own yarn), because in a flat design they're usually mistakes. In a dithered or halftoned area they're the pattern itself, and they knit exactly as drawn.
  • Halftone dot size 4–6 reads well on a sweater. Dither gives the finest shading the gauge allows.

In the file format

Agents, plugins and scripts set the same things on a PIXEL_GRID node:

FieldValuesMeaning
colorMode'INDEXED', 'RGBA', 'GRAYSCALE'How cells store color
palette['#rrggbbaa', …]The palette, in order
layerPaletteSnaptrue / falseSnap layer colors to the palette (always on in indexed mode)
layerBlend'SNAP', 'DITHER', 'HALFTONE'Off-palette colors: Nearest color, Dither, Halftone
layerHalftoneSize2–64Halftone dot size, in pixels
childIdsnode idsThe layers inside the canvas, bottom to top

Gradients are ordinary paints on those layers (GRADIENT_LINEAR or GRADIENT_RADIAL with gradientStops), so anything that can make a shape can make a blended pixel layer.