
H hides the panel · Space replays · S scrubs
Use these settings
Save this as settings.json next to your component, then pass it as the settings prop.
{
"mode": 1,
"ink": "#161616",
"paper": "#efeadf",
"paperOpacity": 1,
"cell": 3.1,
"angle": 45,
"lo": 0.02,
"hi": 0.72,
"gamma": 1.12,
"gain": 0.08,
"soft": 1.2,
"rough": 0.35,
"roughScale": 1.4,
"grain": 0.1,
"mottle": 0.04,
"specks": 0,
"misreg": 0.2,
"settle": 0,
"sweepMs": 370,
"printMs": 460,
"mergeMs": 440,
"fadeStyle": 0
}
Then print a photo with them
import { NewspaperImage } from 'newspaper-image'
import settings from './settings.json'
<NewspaperImage
src="/your-photo.jpg"
alt="Describe your photo"
settings={settings}
/>
How to use it
Install
npm install newspaper-imageThe smallest use
<NewspaperImage src alt /> shows the default print, standing still. Give it the photo's address in src and a description of the photo in alt.
Props you will reach for
settings: the object you copied above. Any single setting, such ascellorink, also works as its own prop and overridessettings.fromSrcandreveal:fromSrcis a second photo, andreveal(0 to 1, default 1) prints from it tosrc.fade: 0 to 1, default 0. At 1 the clean photo shows.printIn: starts as blank paper that prints in when the page loads.printInMssets how long (default 600).respectReducedMotionskips the print-in for readers who ask their device for reduced motion.fitandposition:fitis'cover'(default) or'fill'.positionis[x, y], each 0 to 1 (default[0.5, 0.5]), and picks which part of a cropped photo stays in view.
Two things to know
- A photo from another site needs that site to allow it (CORS) and
crossOrigin="anonymous"on the component. Without both, the plain photo shows. - Without WebGL2 or JavaScript, readers see the plain photo.
Fade on scroll
Here fade follows the scroll position.
