Компьютерная графика. Введение в Processing

  • Published on
    20-Jul-2015

  • View
    351

  • Download
    17

Embed Size (px)

Transcript

  • Processing

    Jordi Linares i PellicerEscola Politcnica Superior dAlcoiDep. de Sistemes Informtics i Computacijlinares@dsic.upv.eshttp://www.dsic.upv.es/~jlinares

    Escola Politcnica Superior dAlcoiDep. de Sistemes Informtics i ComputaciDep. de Sistemes Informtics i Computaci

    : (robofreak.ru), .2011

  • processing ? Processing - Java,

    ,

    Processing - , ,

    Java (Mac OS, Linux, Windows ..) 2001 MIT,

    . Design By Numbers

    http://processing.org -> processing

  • processing ? , ...

    IDE ( ) , OpenGL + GLUT

    , .

    , .

    Java Java. Java processing.

  • processing? 3 : ,

    -

    ( , )

    ( C)

    - ( Java) ,

    Java (eclipse, netbeans) processing

  • processing ?

    : Mac OS, Linux and Windows processing

    ( Java-)

    (http://mobile.processing.org)

    Arduino Wiring(http://hardware.processing.org)

  • . :

    3D Core Graphics System. ACM SIGGRAPH (1977) GKS (Graphical Kernel System). 2D. ISO-ANSI (1985) GKS-3D (1988) PHIGS (Programmers Hierarchical Interactive Graphics System). 3D.

    (1988) SRGP SPHIGS (Foley)

    OpenGL XWindows, Microsoft Windows, Mac OS ... VRML, X3D (-) POV-Ray, Renderman Java2D, Java3D DirectX (Direct-3D) .

  • processing IDE Processing IDE (Integrated

    Development Environment), Java

    . . eclipse .

    PDE (processing development environment)

  • processing IDE ,

    . , .pde

    64 , .

    (). .pde , .java ( Java).

    ( setup)

    ,

    , .pde (, .pde )

  • processing IDE

    Run Stop Export . Export

    Application Mac OS, Linux Windows. application

    Sketchbook - . .

  • processing IDE :

    Import Library. .

    Add File. - , : data. , (., loadImage ). data , .

    Create font , -.

    Help processing - , .

  • processing processing Java 1.4.2 (

    ) 1.5 ,

    ( Java- processing )

    t: http://java.sun.com/j2se/1.4.2/docs/api/index.html

    processing C( , ). -(Java- )

  • processing processing

    (.pde)

    Java-(.java)

    (.class)

    JVM(Java Virtual Machine)

    (processing)

    (javac)

  • type name;

    byte, short, int(178), long (8864L), float (37.266F), double (37.266/26.77e3), char (c), boolean(true/false)

    byte[ ] array;

    type name = value;

    final type variable = value;

    processing

  • +,-,*,/,%,++,-- >,>=,
  • : { ; } while

    while ( expr ) { instructions } do { instructions } while ( expr )

    for for ( begin; end; inc ) {instructions }

    /if ( expr ) {instructions } if ( expr ) {instructions } else { instructions }

    switch ( var ) { case val: instructions default: }

    : break, continue, return

    processing

  • :// /* - */

    :returned_type functionName(list of parameters) processing, setup()

    processing

  • :void setup() // {

    size(100, 100);drawLine(5);

    }void drawLine(int x) // {

    line(x, 0, x, 99);}

    processing

  • : String message = hello; String message = hello + bye;

    : length() : charAt() substring() :

    concat(),replace(),trim(),toLowerCase(), : indexOf(), lastIndexOf(), . : startsWith(), endsWith(),

    compareTo(), ..

    :String message = hello+ bye; int len = message.length(); int len = hello.length();

    processing

  • processing (Java) : length :int[] vector; // vector null vector = new int[3]; // 3 int len = vector.length; // = 3int item = vector[2]; //

    int [][] matrix = new int[4][4];matrix[0][0] = 12; //

    processing

  • processing Java? processing

    : ,

    , C,

    ,

    ; Java-

    C- , ; ( )

    processing

  • (I)// processingline(0,0,50,50);

    (II)// ...int i;background(0); // stroke(255); // for (i = 0; i

  • C- :// , // setup()void setup(){ size(100,100); // noFill(); // }

    void draw() // { drawRandomCircle();}

    void drawRandomCircle(){ int r = int(random(50)); // stroke(random(255), random(255), random(255)); // (, , , ) ellipse(random(100), random(100), r, r);}

    processing

  • void setup(){ size(100,100); // noFill(); }

    void draw() // { Circle c = new Circle(); c.draw();}// class Circle{ // int r = int(random(50)); int x = int(random(100)); int y = int(random(100)); color c = color(random(255), random(255), random(255)); // void draw() { stroke(c); ellipse(x, y, r, r); }}

    processing

  • 1-1 , n . , poligon

    : ( ), () ()

    : setup ,

    , size(500,500), poligon

    poligon : sin() cos(),

    line(x1, y1, x2, y2)

    (x1, y1) (x2, y2) (0,0) , x

    , y PI TWO_PI

  • 1-2 , ,

    ( ) , - . .

    , gradient : 6 ; 3 - RGB- ( 0 255), 3 RGB-

    : setup ,

    , size(500,500) ,

    gradient : line(x1, y1, x2, y2),

    (x1, y1) (x2, y2) width height

    stroke ,

    ( ), 3 - RGB-

    gradient

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

Recommended

View more >