# 个人见到的processing(优质且全的教程,一定看原文)

2013-08-28

## 介绍

processing-java --output=/tmp/processing-xx --run --force --sketch=/home/ning/soft/processing-2.0b8/modes/java/examples/Demos/Graphics/

### 坐标

X軸是向右漸增, Y軸是向下漸增, Z軸是向外漸增

### 判断

< == > != >= <= && || !

Object & Class

### 3D

pushMatrix();
translate(width/2, height/2);
rotateX(1);
box(150);
popMatrix();

lights(); //在draw里面调用即可.

## 看教程

### Processing Tutorial 视频01-24 (7:29:00)

#### 循环

for (int i=0;i<20;i++) {
for (int j=0;j<20;j++) {
if (i<10) {
fill(255, 0, 0);
}else{
fill(255, 255, 0);
}

ellipse(i*20, j*20, 20, 20);

}
}

#### class

Ball myBall;
void setup() {
size(600, 600);
background(0);
myBall = new Ball(500, 100);
}

void draw()
{
myBall.display();
}

class Ball{
int x = 500;
int y = 500;

Ball(int x, int y){
this.x = x;
this.y = y;
}
void display(){
ellipse(x, y, 20, 20);
}
}

#### Ball bounce & gravity 跳跃和重力

void bounce() {
if (x>width || x < 0) {
speedX *= -1;
}
if (y >height || y<0) {
speedY *= -1;
}
}
void gravity(){
speedY += 0.2;
}

#### 数组

Ball[] balls = new Ball[20];

for (int i=0;i<balls.length;i++){
balls[i] = new Ball(random(0, width), random(0, height), 5, 5);
}

#### ArrayList

ArrayList myList;
mylist.size();
mylist.get(1);

#### External Libraries

http:///reference/libraries/

(ENV)ning@ning-laptop ~/idning/langtest/processing/sketchbook/libraries\$ ll
total 32K
5022553 drwx------ 5 ning ning 4.0K 2013-03-09 11:29 verletphysics
5022577 drwx------ 5 ning ning 4.0K 2013-03-09 11:29 volumeutils
5022429 drwx------ 5 ning ning 4.0K 2013-03-09 11:29 audioutils
5022441 drwx------ 5 ning ning 4.0K 2013-03-09 11:29 colorutils
5022457 drwx------ 5 ning ning 4.0K 2013-03-09 11:29 datautils
5022470 drwx------ 5 ning ning 4.0K 2013-03-09 11:29 simutils
5022505 drwx------ 5 ning ning 4.0K 2013-03-09 11:29 toxiclibscore
5022495 drwx------ 5 ning ning 4.0K 2013-03-09 11:29 toxiclibs_p5

##### toxiclib.Vec3d (11-12)

toxi 库里面的:

Vec3D loc = new Voc3D(0, 0, 0);
ellipse(loc.x, loc.y, 20, 20);

Vec3D speed = new Voc3D(1, 0, 0);

loc.normalize(); //变成1.
loc.scaleSelf(100); //乘以100.

Vec3D newVec = loc.add(speed) ; 不一样. 产生一个新的vec.

#### 3D

PeasyCam

##### camera()

camera(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ)

The default values are camera(width/2.0, height/2.0, (height/2.0) / tan(PI*30.0 / 180.0), width/2.0, height/2.0, 0, 0, 1, 0)

##### PeasyCam

A mouse driven camera-control library for 3D sketches.

#### 输出&输入

PrintWriter output;
output = createWrite("data/points.csv");

if (keyPressed) {
for (int i=0; i<cols; i++) {
for (int j=0; j<cols; j++) {
Vec3D loc = grid[i][j].loc;
output.println(loc.x + "," + loc.y + "," + loc.z);
}
}

output.flush();
output.close();
}

#### 例子

##### 实现Spring

verlet VerletParticle. 粒子. VerletSpring. 弹簧.

GravityBehavior()

#### Eclipse

proclipsing, 它是用java 来的:

package eclipseprocessingprj;
import processing.core.PApplet;

public class EclipseProcessingPrj extends PApplet {
public void setup() {
size(600, 600);

}

public void draw() {
background(0);
stroke(255, 0, 0);
fill(255);
ellipse(mouseX, mouseY, 15, 15);
}

public static void main(String _args[]) {
PApplet.main(new String[] { eclipseprocessingprj.EclipseProcessingPrj.class.getName() });
}
}

## example

### 3D Surface Spectogram Audio Visualizer in Processing

by FFT.

http://www./watch?v=rUuPBfEkiJs

http:///6239027

## 资料

### 视频

hello world Processing: http://www.tudou.com/programs/view/ilYm5UpnXMw/

### 书

processing 的下载包中包含了多本书的Demo:

- Getting STarted
- Nature of Code
- Processing Handbook
- Visualizing Data

### 范例网站

[Processing作品收集] http://www./ (closed) http://www.open/ [Processing範例搜尋] http://builtwith/browser/browse.php

0条评论