hello,
I need to put my sketch (voxel_view_canvas3.js) in a div (id=“canvas_voxel_colors”) where is write CANVAS, but the sketch doesn’t show. What am I doing wrong?
link to the project (p5.js Web Editor)
hello,
I need to put my sketch (voxel_view_canvas3.js) in a div (id=“canvas_voxel_colors”) where is write CANVAS, but the sketch doesn’t show. What am I doing wrong?
link to the project (p5.js Web Editor)
For that you simply invoke method p5.Element::parent() over the p5.Renderer object returned by p5::createCanvas():
sketch.setup = function() {
sketch.createCanvas(200, 200).parent('canvas_voxel_colors');
Alternatively you can instead pass the id attribute to the p5’s constructor as its 2nd argument:
var myp5_3 = new p5(s3, 'canvas_voxel_colors');
However you’ve got much more bugs than that:
<script>
tags are incompatible w/ the p5.js Web Editor, b/c they attempt to load libraries as if they were local instead of using some CDN remote link.thank you so much, I fixed the problem with the canvas position and the class. now it’s working properly.