Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/paper-design/shaders/llms.txt

Use this file to discover all available pages before exploring further.

Halftone CMYK is an image filter shader that simulates the traditional four-color printing process. It decomposes an input image into Cyan, Magenta, Yellow, and Black ink channels, each rendered as an angled halftone screen. Dot shape, ink colors, cell size, contrast, grain, and per-channel flood/gain controls are all exposed.
This is an image filter shader — it requires an image input. In React, pass a URL string to the image prop and it is loaded automatically. In vanilla JS, pass a fully loaded HTMLImageElement to u_image.

Usage

import { HalftoneCmyk } from '@paper-design/shaders-react';

export default function Example() {
  return (
    <HalftoneCmyk
      image="/my-photo.jpg"
      type="ink"
      size={0.2}
      contrast={1}
      softness={1}
      colorBack="#fbfaf5"
      colorC="#00b4ff"
      colorM="#fc519f"
      colorY="#ffd800"
      colorK="#231f20"
      gridNoise={0.2}
      floodC={0.15}
      gainC={0.3}
      gainY={0.2}
      style={{ width: 600, height: 400 }}
    />
  );
}

Props

image
string (React) | HTMLImageElement (vanilla JS)
required
The source image to apply the CMYK halftone effect to. In React, pass a URL string — the component loads it automatically. In vanilla JS, pass a fully loaded HTMLImageElement as u_image.
type
HalftoneCmykType
default:"'ink'"
Dot shape style. Use the HalftoneCmykTypes enum (vanilla JS) or string literal (React).
ValueDescription
dotsSeparate circular dots
inkJoined ink blobs
sharpHard-edge joined dots with direct pixel color sampling
size
number
default:"0.2"
Halftone cell size, controlling the density of the dot screen. Range: 0 to 1.
contrast
number
default:"1"
Image contrast adjustment applied before channel extraction. Range: 0 to 2.
softness
number
default:"1"
Edge softness of dots. 0 = hard, 1 = fully soft. Range: 0 to 1.
colorBack
string
default:"'#fbfaf5'"
Paper (background) color visible between dots.
colorC
string
default:"'#00b4ff'"
Cyan ink color.
colorM
string
default:"'#fc519f'"
Magenta ink color.
colorY
string
default:"'#ffd800'"
Yellow ink color.
colorK
string
default:"'#231f20'"
Black (key) ink color.
gridNoise
number
default:"0.2"
Strength of smooth noise applied to both dot positions and color sampling, producing an organic, hand-printed feel. Range: 0 to 1.
floodC
number
default:"0.15"
Flat cyan dot size adjustment applied uniformly across the image. Range: -1 to 1.
floodM
number
default:"0"
Flat magenta dot size adjustment. Range: -1 to 1.
floodY
number
default:"0"
Flat yellow dot size adjustment. Range: -1 to 1.
floodK
number
default:"0"
Flat black dot size adjustment. Range: -1 to 1.
gainC
number
default:"0.3"
Proportional cyan dot size gain — enhances existing dots proportionally. Range: -1 to 1.
gainM
number
default:"0"
Proportional magenta dot size gain. Range: -1 to 1.
gainY
number
default:"0.2"
Proportional yellow dot size gain. Range: -1 to 1.
gainK
number
default:"0"
Proportional black dot size gain. Range: -1 to 1.
grainSize
number
default:"0.5"
Scale of the grain texture applied to both dot edges and the overlay. Range: 0 to 1.
grainMixer
number
default:"0"
Strength of grain distortion affecting dot sizes. Range: 0 to 1.
grainOverlay
number
default:"0"
Post-processing black/white grain overlay strength. Range: 0 to 1.

Presets

The following presets are exported from @paper-design/shaders-react:
ExportNameDescription
defaultPresetDefaultInk type, tight grid, classic CMYK colors
dropsPresetDropsLarge ink drops with heavy grid noise
newspaperNewspaperFine dots, boosted contrast, monochrome inks
vintagePresetVintageSharp type, muted vintage CMYK palette
import { halftoneCmykPresets } from '@paper-design/shaders-react';

Enums

Import HalftoneCmykTypes from @paper-design/shaders when using the vanilla JS API:
import { HalftoneCmykTypes } from '@paper-design/shaders';

// HalftoneCmykTypes: dots | ink | sharp
The u_noiseTexture uniform is required by the vanilla JS API. Import and call getShaderNoiseTexture() from @paper-design/shaders to obtain the pre-built noise texture the CMYK shader depends on.