【发布时间】:2016-01-13 18:56:15
【问题描述】:
我是编码新手,我有一个问题。 我在处理过程中制作了这个简单的代码,我想知道是否可以使用它以及如何对 div 中的图像执行相同的操作。 这是代码:
<i>int x, y;
PImage img;
void setup () {
size(800, 739);
img = loadImage("1.jpg");
}
void draw () {
for (int i=0; i < mouseX/10; i ++) {
int x = (int) random(width);
int y = (int) random(height);
color cor = img.get(x, y);
float t = random(5, 25);
fill(cor, 30);
noStroke ();
ellipse(x, y, t, t);
}
}
</i>
【问题讨论】:
-
在 HTML 中你需要使用
<canvas>元素,而不是<div> -
<i>和</i>在 JavaScript 中无效。 -
关注processing.js tutorials/examples。显然你尝试的方式(通过将
processing代码直接扔到HTML)是行不通的。
标签: html css processing processing.js