简体   繁体   English

如何将多个Processing(.pde)文件加载到HTML页面中?

[英]How do I load in multiple Processing (.pde) files into an HTML page?

So I know that with JS and a lot of JS frameworks you can simply do the following to put your sketch into html: 所以我知道使用JS和许多JS框架你可以简单地执行以下操作将草图放入html:

<script src="FirstScript.js"></script>
<script src="SecondScript.js"></script>

and so on. 等等。

But in Processing, you do the following: 但在Processing中,您可以执行以下操作:

<canvas id="your-id-here" data-processing-sources="Code.pde"></canvas>

Since it is inside the canvas, you can't add multiple files. 由于它位于画布内,因此无法添加多个文件。 I have looked around and haven't found a solution. 我环顾四周,没有找到解决方案。

If it matters, I am trying to link a sound file. 如果重要,我试图链接一个声音文件。 How can I do this? 我怎样才能做到这一点?

Also, I know I could just switch over to some other JS framework, like p5, but I would rather stay in Processing. 另外,我知道我可以切换到其他一些JS框架,比如p5,但我宁愿留在Processing。

In order to load multiple pde files in a webpage by using processing.js library, you can simply mention all the files inside the data-processing-sources tag. 要使用processing.js库在网页中加载多个pde文件,您只需提及data-processing-sources标记内的所有文件即可。

eg <canvas id="your-id-here" data-processing-sources="file1.pde file2.pde"></canvas> 例如<canvas id="your-id-here" data-processing-sources="file1.pde file2.pde"></canvas>

For playing sounds in processing.js you can use a java-to-javascript binding workaround: 要在processing.js中播放声音,您可以使用java-to-javascript绑定解决方法:

https://funprogramming.org/141-Processing-js-with-sound-audio-I.html https://funprogramming.org/142-Processing-js-with-sound-audio-II.html https://funprogramming.org/141-Processing-js-with-sound-audio-I.html https://funprogramming.org/142-Processing-js-with-sound-audio-II.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM