Posts filed under 'Processing code'

Quelle der Codebeispiele

Alle in der Kategorie Processing code dargestellten Beispiele
kommen von der Quelle http://www.processing.org.

Add comment Februar 24, 2007

class

 

/*Declare and contruct two objects
(h1, h2) from the class HLine*/
HLine h1 = new HLine(20, 2.0);
HLine h2 = new HLine(50, 2.5); 

void setup()
{
  size(200, 200);
  framerate(30);
}

void draw() {
  background(204);
  h1.update();
  h2.update();
} 

class HLine {
  float ypos, speed;
  HLine (float y, float s) {
    ypos = y;
    speed = s;
  }
  void update() {
    ypos += speed;
    if (ypos > width) {
      ypos = 0;
    }
    line(0, ypos, width, ypos);
  }
}

Add comment Februar 4, 2007

Array

 

int[] numbers = new int[3];
numbers[0] = 90;
numbers[1] = 150;
numbers[2] = 30;
// Sets variable a to 240
int a = numbers[0] + numbers[1];
// Sets variable b to 180
int b = numbers[1] + numbers[2];

 

int[] numbers = { 90, 150, 30 };
// Sets variable a to 240
int a = numbers[0] + numbers[1];
// Sets variable b to 180
int b = numbers[1] + numbers[2];

 

int degrees = 360;
float[] cos_vals = new float[degrees];
for(int i=0; i < degrees; i++) {
  cos_vals[i] = cos(TWO_PI/degrees * i);
}

Add comment Januar 28, 2007

mouseReleased()

// Click within the image to change
// the value of the rectangle

int value = 0;

void draw() {
  fill(value);
  rect(25, 25, 50, 50);
}

void mouseReleased() {
  if(value == 0) {
    value = 255;
  } else {
    value = 0;
  }
}

Add comment Januar 24, 2007

Schrift

Beispielcode zum Hinzufügen von Fonts:

textFont(font A, 36);
textAlign(CENTER);
loadFont(„CourierNew36.rw“);

Add comment Januar 17, 2007

mousePressed()

// Click within the image to change
// the value of the rectangle

int value = 0;

void draw() {
  fill(value);
  rect(25, 25, 50, 50);
}

void mousePressed() {
  if(value == 0) {
    value = 255;
  } else {
    value = 0;
  }
}

Add comment Januar 1, 2007

frameRate()

void setup() {
  frameRate(4);
}
int pos = 0;
void draw() {
  background(204);
  pos++;
  line(pos, 20, pos, 80);
  if(pos > width) {
    pos = 0;
  }
}

Add comment Dezember 24, 2006

setup

void setup() {
  size(200, 200);
  background(0);
  noStroke();
  fill(102);
}

int a = 0;

void draw() {
  rect(a++%width, 10, 2, 80);
}

Add comment Dezember 24, 2006

String

String str1 = "CCCP";
char data[] = {'C', 'C', 'C', 'P'};
String str2 = new String(data);
println(str1);  // Prints "CCCP" to the console
println(str2);  // Prints "CCCP" to the console

Add comment November 24, 2006

Allgemein

//Hintergrundfarbe
backround();

// Formen abrunden
smooth();

Add comment November 14, 2006

Previous Posts


Kategorien

Archive

Links