User guide

Try the two demos, then use the effect with your own images.

What's included

  • single/: one photo with one spectacles lens.
  • multi/: variations with several images.

Try it

  1. Download the ZIP and unzip it.
  2. Serve the folder with any web server, for example php -S localhost:8000 or npx serve. The demo files end in .php but contain only HTML and JavaScript.
  3. Open single/index.php and move the mouse, or drag a finger, over the photo.

Use your own images

  1. Set the src of #myimage to the photo people see normally.
  2. Set its data-img attribute to the image shown through the lenses.
  3. To change the glasses, replace the lens shape (img/black.png, used as a CSS mask) and the frame artwork (the SVG background).

Something unclear or missing? Tell us.