东岳网络工作室技术分享
Processing is a flexible software sketchbook and a language for learning how to code within the context of the visual arts. Since 2001, Processing has promoted software literacy within the visual arts and visual literacy within technology.
void setup() {
size(480, 120);
}
void draw() {
if (mousePressed) {
fill(0);
} else {
fill(255);
}
ellipse(mouseX, mouseY, 80, 80);
}
void setup() {
size(640, 360, P3D);
}
void draw() {
background(0);
camera(mouseX, height/2,
(height/2) / tan(PI/6), width/2, height/2, 0, 0, 1, 0);
translate(width/2, height/2, -100);
stroke(255);
noFill();
box(200);
}
settings <- function() {
size(500, 500, P3D)
}
setup <- function() {
colorMode(RGB, 1)
frameRate(24)
}
draw <- function() {
frames <- 24 * 3
t <- frameCount/frames
background(1)
perspective(0.5, 1, 0.01, 100)
camera(0, 0, 25 + sin(PI * 2 * t) * 3, 0, 0, 0, 0, 1, 0)
rotateX(-0.5 - 0.05 * sin(PI * 4 * t))
rotateY(-0.5 - 0.05 * cos(PI * 2 * t))
columns <- 8
for (ix in 1:columns - 1) {
x <- ix - 0.5 * columns + 0.5
for (iy in 1:columns - 1) {
y <- iy - 0.5 * columns + 0.5
for (iz in 1:columns - 1) {
z <- iz - 0.5 * columns + 0.5
d <- sqrt(x * x + y * y + z * z)
s <- abs(sin(d - t * 4 * PI))
pushMatrix()
translate(x, z, y)
box(s)
popMatrix()
}
}
}
}