Image Dithering

Click to change the sample image

Installation

npm i @paper-design/shaders-react

Code

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

<ImageDithering
  style={{ height: 500 }}
  colorBack="#000c38"
  colorFront="#94ffaf"
  colorHighlight="#eaff94"
  originalColors={false}
  type="8x8"
  pxSize={2}
  colorSteps={2}
  scale={1}
  fit="cover"
/>

Props

NameDescriptionTypeValues
colorBackBackground colorstringHex, RGB, or HSL color
colorFrontThe main foreground colorstringHex, RGB, or HSL color
colorHighlightThe secondary foreground color (set it same as colorFront to get a classic 2-color dithering)stringHex, RGB, or HSL color
originalColorsUse the original colors of the imageboolean
| true | false
typeDithering typeenum
| "random" | "2x2" | "4x4" | "8x8"
pxSizePixel size of dithering gridnumber0.5 to 20
colorStepsNumber of colors to use (applies to both color modes)number1 to 7 (integer)
scaleOverall zoom level of the graphicsnumber0.5 to 10
fitHow the image fits the canvasenum
| "contain" | "cover"

Description

A dithering image filter with support for 4 dithering modes and multiple color palettes (2-color, 3-color, and multicolor options, using either predefined colors or ones sampled directly from the original image).