kramann.info
© Guido Kramann

Login: Passwort:










kramann.info
© Guido Kramann

Login: Passwort:




PDF-Export bei Processing

(EN google-translate)

(PL google-translate)

float dt = 0.8;
float t = 0.0;
float ddphi = 0.1;
float dphi = 0.0;
float phi = 0.0;
float a = 0.0;
float v = 5.0;
float dx = 0.0;
float dy = 0.0;
float x = 1.0;
float y = 1.0;
float x_alt = 0.0;
float y_alt = 0.0;

float rot   = 0.0;
float gruen = 0.0;
float blau  = 0.0;

void setup()
{
    size(500,500);
    stroke(0);
    fill(0);
    //frameRate(5);
}

void draw()
{
        translate(width/2,height/2);
        rot   = 127.0+127.0*sin(0.001*t);
        gruen = 127.0+127.0*sin(0.001*t+QUARTER_PI);
        blau  = 127.0+127.0*sin(0.001*t+HALF_PI);
  
        ddphi = sin(0.1*t);
  
        dphi += ddphi*dt;
        phi  += dphi*dt;

        a = cos(20000.0*t);
        v+=a*dt;
        
        dx = v*cos(phi);
        dy = v*sin(phi);
        
        x += dx*dt;
        y += dy*dt;

        stroke(rot,gruen,blau);
        line(x_alt,y_alt,x,y);

        x_alt = x;
        y_alt = y;
        
        t+=dt;              
}

Code 0-1: Beispiel für algorithmische Kunst auf der Basis von Differentialgeometrie.

Ergebnis

Bild 0-1: Ergebnis

Schreiben der Grafik in eine pdf-Datei:

import  processing.pdf.*;

float dt = 0.8;
float t = 0.0;
float ddphi = 0.1;
float dphi = 0.0;
float phi = 0.0;
float a = 0.0;
float v = 5.0;
float dx = 0.0;
float dy = 0.0;
float x = 1.0;
float y = 1.0;
float x_alt = 0.0;
float y_alt = 0.0;

float rot   = 0.0;
float gruen = 0.0;
float blau  = 0.0;

    size(500,500);
    stroke(0);
    fill(0);
    //frameRate(5);

beginRecord(PDF, "grafik.pdf"); 
    background(255,255,255);
    translate(width/2,height/2);
    for(int i=0;i<4700;i++)
    {
        rot   = 127.0+127.0*sin(0.001*t);
        gruen = 127.0+127.0*sin(0.001*t+QUARTER_PI);
        blau  = 127.0+127.0*sin(0.001*t+HALF_PI);
  
        ddphi = sin(0.1*t);
  
        dphi += ddphi*dt;
        phi  += dphi*dt;

        a = cos(20000.0*t);
        v+=a*dt;
        
        dx = v*cos(phi);
        dy = v*sin(phi);
        
        x += dx*dt;
        y += dy*dt;

        stroke(rot,gruen,blau);
        line(x_alt,y_alt,x,y);

        x_alt = x;
        y_alt = y;
        
        t+=dt;              
    }
endRecord();
Schreiben der Grafik in eine pdf-Datei.

#pdf
grafik.pdf

Code 0-2: Ergebnis: grafik.pdf (im aktuellen Sketch-Ordner).