【发布时间】:2020-09-02 09:59:38
【问题描述】:
我正在尝试将 Processing(一种图形编程语言)集成到我的网站中,但代码似乎不起作用。 好像没有注册处理代码...
有什么想法吗?
<!doctype html>
<html lang="en">
<head>
<script type="text/javascript" src="js/processing.js"></script>
</head>
<body>
<script type= "text/processing">
int ranges = 100;
void setup() {
fullScreen();
background(0);
}
void draw() {
background(0);
noFill();
strokeWeight(1);
for (int i = 1; i < ranges; i++) {
float paint = map(i, 0, ranges, 1, 105);
stroke(paint);
beginShape();
for (int x = -100; x < width + 11; x += 20) {
float n = noise(x * 0.001, i * 0.01, frameCount * 0.01);
float y = map(n, 0.1, 1, mouseY, height);
vertex(x, y);
}
endShape();
}
}
</script>
<canvas id="sketch" style="border: 1px solid black;"></canvas>
</body>
</html>
【问题讨论】:
-
在你的草图中,setup 或 draw 方法永远不会被调用,也没有对 canvas 元素的引用
-
Processing js 似乎无论如何都被放弃了,所以我建议你寻找一个不同的库。也许 WebGL 适合你:get.webgl.org
-
谢谢。好的,你能建议我如何把我的草图放到我的网站上吗?草图:openprocessing.org/sketch/950912#
标签: javascript html processing