【发布时间】:2018-09-10 23:18:06
【问题描述】:
所以我使用 processing.js 来制作一些看起来很抽象的排版(例如 this),并且我找到了某人的代码,我想将其用作我自己代码的基础。我尝试将其复制并粘贴到打开的处理中,用于处理的在线编辑器,当我尝试运行它时它给了我这个错误:drawing.$ensureContext(...).getImageData is not a function
here是代码:
PImage hm;
int xstep = 1;
int max_height = 60;
void setup() {
size(600, 400, P3D);
background(0);
fill(255);
textSize(128);
textAlign(CENTER);
text("LIGMA", width/2, height/2);
filter(BLUR, 8);
hm = get();
}
void draw() {
background(0);
strokeWeight(2);
stroke(255);
float b, z, px, pz;
translate(width/2, height/2,-20);
rotateY(map(mouseX,0,width,-PI,PI));
rotateX(map(mouseY,0,height,-PI,PI));
translate(-width/2, -height/2);
for (int y = 5; y < height; y+=10) {
px = -1;
pz = 0;
for (int x = 0; x < width; x+=xstep) {
b = brightnes(hm.get(x,y));
z = map(b, 0, 200, 0, max_height);
//stroke(color(b));
line(px, y, pz, x, y, z);
px = x;
pz = z;
}
}
}
在我的代码中找不到这个drawing.$ensureContext(...).getImageData。谁能解释为什么会发生这种情况以及如何解决?
【问题讨论】:
-
异常通常会告诉你文件和行
-
如果您打开开发者工具,您可以在控制台中看到完整的异常。它看起来像是源自处理库本身的错误。
-
@Jacob 有开发者工具在处理吗?
-
Processing.js 已经很老了,不再推荐用于新代码。另请注意,您的代码无法编译,因为您拼错了
brightness。 -
@mckuok 它没有
标签: javascript processing typography processing.js