Halftone CMYK
Free
Prints an image as four overlapping CMYK halftone screens with ink colors, flood, gain, and grain for each channel. Adapted from Halftone CMYK by Paper Shaders (shaders.paper.design) under the Apache 2.0 license.
Code
Usage
<ShaderHalftoneCmyk
blackInkColor="#231f20"
cyanInkColor="#00b4ff"
magentaInkColor="#fc519f"
paperColor="#fbfaf5"
yellowInkColor="#ffd800"
dotStyle="ink"
imageSrc="https://images.unsplash.com/photo-1507525428034-b723cf961d3e?w=1600&h=1200&fit=crop"
blackFlood={0}
blackGain={0}
imageContrast={1}
cyanFlood={0.15}
cyanGain={0.3}
dotSoftness={1}
edgeGrain={0}
grainOverlay={0}
grainSize={0.5}
gridNoise={0.2}
gridSize={0.2}
magentaFlood={0}
magentaGain={0}
yellowFlood={0}
yellowGain={0.2}
graphicScale={1}
graphicRotation={0}
graphicOffsetX={0}
graphicOffsetY={0}
/>Props
| prop | type | default | description |
|---|---|---|---|
imageSrc | string | required | Image URL. The URL must be same-origin or served with CORS headers. |
imageAlt | string | required | Alternative text for the image. Pass an empty string for a decorative image. |
imageWidth | number | 1600 | Image width in pixels. Sets the aspect ratio with imageHeight. Defaults to 1600. |
imageHeight | number | 1200 | Image height in pixels. Sets the aspect ratio with imageWidth. Defaults to 1200. |
paperColor | string | #fbfaf5 | Paper color behind the ink. Accepts any CSS color. |
cyanInkColor | string | #00b4ff | Cyan ink color. Accepts any CSS color. |
magentaInkColor | string | #fc519f | Magenta ink color. Accepts any CSS color. |
yellowInkColor | string | #ffd800 | Yellow ink color. Accepts any CSS color. |
blackInkColor | string | #231f20 | Black ink color. Accepts any CSS color. |
gridSize | number | 0.2 | Size of the halftone grid. Range 0 to 1. |
gridNoise | number | 0.2 | Moves dot positions and sample points. More of the paper shows through. Range 0 to 1. |
dotStyle | "dots" | "ink" | "sharp" | ink | Style of each dot. |
dotSoftness | number | 1 | Softness of the dot edges. Range 0 to 1. |
imageContrast | number | 1 | Contrast of the source image. Range 0 to 2. |
cyanFlood | number | 0.15 | Even cyan added to every dot. Range 0 to 1. |
magentaFlood | number | 0 | Even magenta added to every dot. Range 0 to 1. |
yellowFlood | number | 0 | Even yellow added to every dot. Range 0 to 1. |
blackFlood | number | 0 | Even black added to every dot. Range 0 to 1. |
cyanGain | number | 0.3 | Makes existing cyan dots larger or smaller. Range -1 to 1. |
magentaGain | number | 0 | Makes existing magenta dots larger or smaller. Range -1 to 1. |
yellowGain | number | 0.2 | Makes existing yellow dots larger or smaller. Range -1 to 1. |
blackGain | number | 0 | Makes existing black dots larger or smaller. Range -1 to 1. |
grainSize | number | 0.5 | Size of the edge grain and the grain overlay. Range 0 to 1. |
edgeGrain | number | 0 | Grain that breaks up the dot edges. Range 0 to 1. |
grainOverlay | number | 0 | Black and white grain added over the result. Range 0 to 1. |
graphicScale | number | 1 | Overall zoom level of the graphic. |
graphicRotation | number | 0 | Rotation of the graphic in degrees. |
graphicOffsetX | number | 0 | Horizontal offset of the graphic center. |
graphicOffsetY | number | 0 | Vertical offset of the graphic center. |
graphicFit | "none" | "contain" | "cover" | cover | How the graphic fits the box. |
opacity | number | 1 | Sets the opacity of the whole block, including the fallback image. |
maxDpr | number | 1.5 | Caps device pixel ratio for sharper output without runaway GPU cost. |
