halftone dots

A halftone-dot image filter for comic, risograph, and newsprint treatments. Mix-and-match dot styles, hex or square grids, and custom palettes.

Preview

live
Click the preview to load a random sample image.

Install

npm
npm i @devmischief/shaders-svelte

Code

import { HalftoneDots } from '@devmischief/shaders-svelte';

<HalftoneDots
  width={1280}
  height={720}
  image="/assets/flowers.webp"
  colorBack="#f2f1e8"
  colorFront="#2b2b2b"
  originalColors={false}
  inverted={false}
  type="gooey"
  grid="hex"
  size={0.5}
  radius={1.25}
  contrast={0.4}
  grainMixer={0.2}
  grainOverlay={0.2}
  grainSize={0.5}
  scale={1}
  rotation={0}
  offsetX={0}
  offsetY={0}
  fit="cover"
/>
			
			

Shader Props

14
namedescriptiontypevalues
imageSource image processed into halftone dots.stringurl
colorBackBackground color shown behind the dots.stringhex / rgba
colorFrontDot color (ignored when originalColors is enabled).stringhex / rgb
originalColorsSample dot colors from the image instead of using colorFront.booleantrue · false
invertedInvert the image's luminance. Has no effect at zero contrast.booleantrue · false
typeDot rendering style.stringclassic · gooey · holes · soft
gridUnderlying lattice the dots are placed on.stringsquare · hex
sizeGrid cell size relative to the image.number0 → 1
radiusMaximum dot size relative to its grid cell. Values above 1 let dots overflow into neighbors.number0 → 2
contrastContrast applied to the sampled image.number0 → 1
grainMixerGrain distortion applied to dot edges.number0 → 1
grainOverlayPost-process black/white grain overlay.number0 → 1
grainSizeScale of the grain distortion and overlay.number0 → 1
fitHow the source image is fit into the canvas.stringcover · contain

Common Props

9
namedescriptiontypevalues
scaleOverall zoom level of the graphics.number0.01 → 4
rotationOverall rotation angle of the graphics.number0 → 360
offsetXHorizontal offset of the graphics.number−1 → 1
offsetYVertical offset of the graphics.number−1 → 1
originXReference point for positioning width in the canvas.number0 → 1
originYReference point for positioning height in the canvas.number0 → 1
speedAnimation speed for time-based grain motion.number
minPixelRatioMinimum pixel ratio used when rendering the shader (default 2).number
maxPixelCountMaximum pixel count the shader may process.number

built with mischief by devmischief

@devmischief/shaders-svelte