1 / 6

Processing - Einführung

Processing - Einführung. www.processing.org. Grundaufbau. import processing.core.PApplet ; public class Proc_Minimal extends PApplet { public void setup (){ size (1024, 768); frameRate(60.0f); } public void draw () { background (255); fill (255,0,0); rectMode ( CENTER);

esma
Download Presentation

Processing - Einführung

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Processing - Einführung www.processing.org

  2. Grundaufbau • importprocessing.core.PApplet; • public class Proc_Minimal extends PApplet { • publicvoidsetup(){ • size(1024, 768); • frameRate(60.0f); • } • publicvoiddraw() • { • background(255); • fill(255,0,0); • rectMode(CENTER); • rect(mouseX, mouseY, 50, 50); • } • static public void main(String args[]) { • //PApplet.main(new String[] { "--present", "Proc_Minimal" }); • PApplet.main(new String[] {"Proc_Minimal" }); • } • } Von Papplet ableiten Initialisierung Loop-Methode Create a Window

  3. Wichtige Methoden/Attribute Größe d. Fensters + Renderer • size(width, height) • optional (width, height, Renderer) • z.B. size(1024, 768, OPENGL) • mouseX, mouseY • pMouseX, pMouseY Aktuelle Mouseposition Mouseposition des letzten Frames

  4. Zeichnen • ellipse(x, y, width, height) • auch: rect, triangle, line • fill(grey) • fill(r,g,b) • fill(r,g,b,a); • noFill() • stroke(grey) // 0-255 • stroke(r,g,b) • stroke(r,g,b,a) • noStroke() • strokeWeigth(pixel) • colorMode(mode, range) • colorMode(HSB. 255) //usehsv • colorMode(HSB, hRange, sRange, vRange) background(128); fill(204, 102, 0); rect(30, 20, 55, 55); background(128); stroke(204, 102, 0); rect(30, 20, 55, 55); noStroke(); colorMode(HSB, 100); for (int i = 0; i < 100; i++) { for (int j = 0; j < 100; j++) { stroke(i, j, 100); point(i, j); } }

  5. Transformationen • transform(x, y) • rotate(radiants) • Useradiants(degree) toconverttoradiants • scale(factor)

  6. Transformationen Why ? Becausesometimesit‘seasier! voidsetup() { size(400, 100); background(255); for (int i = 10; i < 350; i = i + 50) { house(i, 20); } } voidhouse(int x, int y) { pushMatrix(); translate(x, y); triangle(15, 0, 0, 15, 30, 15); rect(0, 15, 30, 30); rect(12, 30, 10, 15); popMatrix(); } voidhouse(int x, int y) { triangle(x + 15, y, x, y + 15, x + 30, y + 15); rect(x, y + 15, 30, 30); rect(x + 12, y + 30, 10, 15); } vs.

More Related