Skip to content

(3rd edition) A multi-canvas p5.js extension that adds MIDI binding and gesture controls, CLI tooling, devlogging, and more

License

Notifications You must be signed in to change notification settings

oznewman/layers.p5

Repository files navigation

Layers.p5

A multi-canvas p5.js extension that adds MIDI binding and gesture controls, CLI tooling, and more




Features

Organize and stack code across multiple responsive Layers, files, and URLs

Edit variables by right clicking on a Layer's pixels and map them to MIDI

Right click to download stacks of Layers as GIFs and videos

Use via CDN or npm or clone the library directly to take advantage of the CLI




Why Layers.p5

Coming soon

Getting Started

Coming soon

Normally with p5.js you have one setup() and draw()

<script>
let canvas
  
function setup () {
  canvas = createCanvas(width, height)
  canvas.parent('#target-container')
  textAlign(CENTER)
}

function draw () {
  background(0)
  stroke(255)
  text('Hello world', width/2, height/2)
}
</script>

But with Layers.p5 you can split your code across many

<script>
// Create a new managed canvas
new Layer({
  // (Optional) Reference this Layer with Layers[id]
  id: 'hello',
  
  // (Optional) Defaults to same size as .target (fullscreen if no .target)
  width: 250,
  height: 250,

  // (Optional) Goes at the end of <body> by default
  target: '#target-container',
  
  // (Optional) A new canvas is automatically created
  setup () {
    // p5 methods automatically point to this.canvas
    textAlign(CENTER)
  },
  
  draw () {
    background(0)
    text('Hello world', width/2, height/2)
  }
})
</script>

More info coming soon




Install

Either with HTML

<script src="https://unpkg.com/[email protected]/lib/p5.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/ozramos/[email protected]/dist/layers.p5.js"></script>

or with NPM

From command line:

npm i p5 @ozramos/layers.p5

Inside your app.js:

import 'p5'
import Layers from '@ozramos/Layers.p5'

Add Layers.p5 to your Libraries: https://cdn.jsdelivr.net/gh/ozramos/[email protected]/dist/layers.p5.js




Acknowledgements

About

(3rd edition) A multi-canvas p5.js extension that adds MIDI binding and gesture controls, CLI tooling, devlogging, and more

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published