javascript - The picture I draw is invisible after I reset the width and height of the canvas -


in js file:

function main_part2() {     var canvas = document.getelementbyid("viewport");     var context = canvas.getcontext("2d");     var eye = new vector(0.5, 0.5, -0.5);      raycasting(context, eye, part2); } function change_size() {     var canvas = document.getelementbyid("viewport");     var width = document.getelementbyid("width").value;     var height = document.getelementbyid("height").value;     canvas.width = width;     canvas.height = height;     main_part2(); } 

in html file:

<body onload="main_part2();"> <canvas id="viewport" width="512" height="512" style="background-color: black"></canvas><br><br> <label for="width">width: </label><input id="width" type="number"><br><br> <label for="height">height: </label><input id="height" type="number"><br><br> <button type="submit" onclick="change_size()">change</button> 

i try reset width , height of canvas through 2 inputs , draw new picture according new canvas. however, when click button, canvas resized, raycasting function, draw picture, makes no effect. how make work?


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -