Skip to content

Instantly share code, notes, and snippets.

@KorySchneider
Last active August 14, 2018 04:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KorySchneider/2aefa092c5e10d2c2ec13317388465b9 to your computer and use it in GitHub Desktop.
Save KorySchneider/2aefa092c5e10d2c2ec13317388465b9 to your computer and use it in GitHub Desktop.
p5js sketch boilerplate, with a centered canvas
<html>
<head>
<title>title</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.1/p5.js"></script>
<style>
html, body {
height: 100%;
margin: 0;
}
canvas {
position: absolute;
top: 0;
left: 0;
z-index: 0;
width: 100%;
height: 100%;
display: block;
pointer-events: none;
}
</style>
</head>
<body></body>
<script>
function setup() {
createCanvas(window.innerWidth, window.innerHeight);
}
function draw() {
background(80, 80, 80);
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
}
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment