Created
January 28, 2021 13:47
Create canvas with container's dimension in p5js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// HTML index.html | |
// <div id="myCanvasContainer"></div> | |
// JS sketch.js | |
// Inside setup() function | |
let canvasDiv = document.getElementById('myCanvasContainer'); | |
let width = canvasDiv.offsetWidth; | |
let height = canvasDiv.offsetHeight; | |
let sketchCanvas = createCanvas(width,height); | |
sketchCanvas.parent("myCanvasContainer"); | |
sketchCanvas.id('myCanvas'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment