简体   繁体   English

在网页上使用外部库发布处理草图

[英]publish processing sketch using external libraries on a web page

I wish to learn how to run a Processing sketch using external libraries like HYPE and MINIM on a web page.我希望学习如何在网页上使用 HYPE 和 MINIM 等外部库运行处理草图。 I am able to run a sketch that does not use an external library successfully after reading the basic tutorial.阅读基本教程后,我能够成功运行未使用外部库的草图。 But not with external libraries.但不是外部库。

Short answer: you can't.简短的回答:你不能。

It sounds like you're using Processing in Java mode and then using Processing.js to deploy as JavaScript.听起来您在 Java 模式下使用 Processing,然后使用 Processing.js 部署为 JavaScript。

This will work for simple sketches that don't contain any Java-specific code, and don't contain any Processing 3 code.这适用于不包含任何 Java 特定代码且不包含任何处理 3 代码的简单草图。 This is because your Processing code is converted to JavaScript, but that conversion can't be done on arbitrary Java code.这是因为您的处理代码已转换为 JavaScript,但无法在任意 Java 代码上完成该转换。 This also means you can't use Java libraries like Minim.这也意味着您不能使用像 Minim 这样的 Java 库。 And Processing.js has not been updated in several years, so you also can't use newer Processing 3 features.而且 Processing.js 已经好几年没有更新了,所以你也不能使用新的 Processing 3 特性。

So at this point you have a few options:所以此时你有几个选择:

  • You can eliminate the libraries altogether.您可以完全消除库。
  • You can find JavaScript versions of the libraries to use instead.您可以找到要使用的库的 JavaScript 版本。 Google "Processing.js minim" for a ton of results.谷歌“Processing.js minim”获得大量结果。
  • You can deploy as a Java application instead of embedding in a website.您可以部署为 Java 应用程序,而不是嵌入到网站中。
  • You can rewrite the whole thing in P5.js.您可以在 P5.js 中重写整个内容。

Shameless self-promotion: here is a tutorial on using Processing.js.无耻的自我推销:这里是使用 Processing.js 的教程。

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

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