class Shape包含两个方法drawCircle()和drawTriangle()。每个 函数都有不同的参数集。目前,我通过直接调用pde文件来调用这个 。如果我必须控制传递给 draw函数的参数,如何直接从 HTML文件传递这些参数? 1)example.html的有(当前版本)如何将动态参数传递给.pde文件
<script src="processing-1.0.0.min.js"></script>
<canvas data-processing-sources="example.pde"></canvas>
2)Example.pde具有
class Shape {
void drawCircle(intx, int y, int radius) {
ellipse(x, y, radius, radius);
}
void drawTriangle(int x1, int y1, int x2, int y2, int x3, int
y3) {
rect(x1, y1, x2, y2, x3, y3);
}
}
Shape shape = new Shape();
shape.drawCircle(10, 40, 70);
我希望做这样的事情在我的HTML文件,让我可以 动所有功能集成到一个单独的文件,并呼吁他们与 不同的参数绘制不同的形状(很多类似于你 会怎么做在Java中) A.html
使用Example2.pde 0B.html
<script>
Shape shape = new Shape();
shape.drawTriangle(30, 75, 58, 20, 86, 75);
</script>
2)IAM的具有
void setup() {
size(200,200);
background(125);
fill(255);
}
void rectangle(int x1, int y1, int x2, int y2) {
rect(x1, y1, x2, y2);
}
我Example2.html具有
变种processingInstance; processingInstance.rectangle(30,20,55,55);但这是行不通的。如何从html动态传递这些参数。
这可能是值得说明的前期您使用processing.js:
你可以通过调用访问您的草图这个数据 – maxedison 2011-02-15 19:56:42