Skip to content

Instantly share code, notes, and snippets.

@shiffman
Last active August 29, 2015 14:27
Show Gist options
  • Select an option

  • Save shiffman/22bb21705ce2829207b1 to your computer and use it in GitHub Desktop.

Select an option

Save shiffman/22bb21705ce2829207b1 to your computer and use it in GitHub Desktop.
Move a sketch into a div after it runs
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script language="javascript" src="../../lib/p5.js"></script>
<script language="javascript" src="sketch.js"></script>
<script language="javascript">
//$(document).ready(function() {
window.onload = function() {
$('#defaultCanvas').appendTo("#container");
};
//});
</script>
<style>
#container {
background-color: #0000FF;
margin: 24px;
padding: 54px;
width: 300px;
height: 300px;
}
</style>
</head>
<body>
<div id ="container"></div>
</body>
</html>
function setup() {
createCanvas(200,200);
}
function draw() {
background(255,0,0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment