Skip to content

jdeboi/p5.anaglyph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

p5.anaglyph

p5.anaglyph is a p5.js library for creating 3D (anaglyph) scenes and images using red/cyan glasses. Uses Dubois anaglyph algorithm & color matrices.

Created by Jenna deBoisblanc.

banner

Examples

NOTE - for red/cyan glasses, the most common method is red on the left eye and blue on the right eye.

Sample Code

In the index.html:
NOTE - there may be issues with caching and jsdelivr depending upon if I've made changes recently; if something breaks, you can find the library p5.anaglyph.min.js in the dist folder.

<script src="https://cdn.statically.io/gh/jdeboi/p5.anaglyph/main/dist/p5.anaglyph.min.js"></script>

In the sketch.js:

let anaglyph;

function setup() {
  createCanvas(windowWidth, windowHeight, WEBGL);
  
  anaglyph = createAnaglyph(this); 
}

function draw() {
  anaglyph.draw(scene);
}

// this is the logic of the scene
// all usual methods from draw(), but call on the 
// pGraphics parameter pg
function scene(pg) {
  pg.background(0);
  pg.fill(255);
  pg.rotateY(frameCount / 200);
  pg.box(200);
}

Acknowledgments

Code adapted from:

Other links:

About

a p5.js library for creating 3D stereoscopic 3D scenes and images using red/cyan glasses.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published