p5.j​​s中的错误:“ pushmatrix()未使用,请参见push();

发布于 2025-01-28 04:44:02 字数 1186 浏览 3 评论 0 原文

每次我运行代码时,都会给我一个错误:

p5.js说:一个错误的错误“未使用pushmatrix()未使用,请参见push()”在p5JS库内发生pushmatrix时(在sketch.js [/sketch.js:175:13中的175行)时发生了错误。 ])

如果没有另行说明,则可能是传递给PushMatrix的参数的问题。 ( http://p5js.org/reference/#/p5/p5/p5/pushmatrix ))))) /p>

( , pushmatrix()在我的代码中不存在。 当我尝试通过用 push() pushmatrix()替换 push()来修复它时,它给了我相同的错误:

p5.js说:一个错误的错误“未使用pushmatrix()未使用,请参见push()”在p5JS库内发生pushmatrix时(在sketch.js [/sketch.js:175:13中的175行)时发生了错误。 ])

如果没有另行说明,则可能是传递给PushMatrix的参数的问题。 ( http://p5js.org/reference/#/p5/p5/p5/pushmatrix ))))) /p>

http://p5js.org/reference/#/p5/p5/pushmatrix 代码: https://pastebin.com/gmxwvjla 这么大)

Every time I run my code, it gives me an error:

p5.js says: An error with message "pushMatrix() not used, see push()" occured inside the p5js library when pushMatrix was called (on line 175 in sketch.js [/sketch.js:175:13])

If not stated otherwise, it might be an issue with the arguments passed to pushMatrix. (http://p5js.org/reference/#/p5/pushMatrix)

However, pushMatrix() does not exist in my code.
When I try to fix it by replacing push() with pushMatrix(), it gives me the same error:

p5.js says: An error with message "pushMatrix() not used, see push()" occured inside the p5js library when pushMatrix was called (on line 175 in sketch.js [/sketch.js:175:13])

If not stated otherwise, it might be an issue with the arguments passed to pushMatrix. (http://p5js.org/reference/#/p5/pushMatrix)

My code: https://pastebin.com/gMxwvJLA (StackOverflow wouldn't let me post the question because the code was so large)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

调妓 2025-02-04 04:44:02

简而言之: pushmatrix()不是 p5 中的有效功能。它不存在。您想用 push() popmatrix() with pop()

通过这些替换,您的代码无需任何错误就可以运行,我看到平方在画布的中心旋转。

错误消息并不特别有用,但是请查看澄清了很多事情。

/**
 * @for p5
 * @requires core
 * These are functions that are part of the Processing API but are not part of
 * the p5.js API. In some cases they have a new name, in others, they are
 * removed completely. Not all unsupported Processing functions are listed here
 * but we try to include ones that a user coming from Processing might likely
 * call.
 */

import p5 from './main';

p5.prototype.pushStyle = function() {
  throw new Error('pushStyle() not used, see push()');
};

p5.prototype.popStyle = function() {
  throw new Error('popStyle() not used, see pop()');
};

p5.prototype.popMatrix = function() {
  throw new Error('popMatrix() not used, see pop()');
};

p5.prototype.pushMatrix = function() {
  throw new Error('pushMatrix() not used, see push()');
};

export default p5;

In short: pushMatrix() is not a valid function in p5. It doesn't exist. You want to find and replace all usages of pushMatrix() with push() and popMatrix() with pop().

With those replacements your code runs without any errors and I see a square spinning around in the center of the canvas.

The error message is not particularly helpful, but looking at the source code clarifies things a lot.

/**
 * @for p5
 * @requires core
 * These are functions that are part of the Processing API but are not part of
 * the p5.js API. In some cases they have a new name, in others, they are
 * removed completely. Not all unsupported Processing functions are listed here
 * but we try to include ones that a user coming from Processing might likely
 * call.
 */

import p5 from './main';

p5.prototype.pushStyle = function() {
  throw new Error('pushStyle() not used, see push()');
};

p5.prototype.popStyle = function() {
  throw new Error('popStyle() not used, see pop()');
};

p5.prototype.popMatrix = function() {
  throw new Error('popMatrix() not used, see pop()');
};

p5.prototype.pushMatrix = function() {
  throw new Error('pushMatrix() not used, see push()');
};

export default p5;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文