draw() function of Processing in Javascript

draw() function of Processing in Javascript

本文关键字:Processing in Javascript of function draw      更新时间:2023-10-26

是否可以在Javascript中翻译Processing中的自动调用函数draw()?如何在JS中模拟这种行为?

Javascript本身是没有办法的,但如果您下载jQuery(https://jquery.com/)您可以在处理过程中执行与draw函数非常相似的操作。

通过使用类似的代码,你应该能够得到一个非常好的结果:

setInterval(function() { 
  draw();
}, 1); //So it waits one millisecond untill calling the draw function 
function draw() {
  //Your code goes in here
}

我希望这对你有用!