Teil der Processing-Serie / Coding

Processing Setup – Meine Einstellungen/Settings für Sketche

Für meine Processing-Sketche habe ich mir über die Zeit ein kleines Framework aufgebaut, um schnelle kreative Ergebnisse zu bekommen. Mein Framework spart Zeit, weil es wiederkehrende Aufgaben und Einstellungen bereits mitbringt. So bietet jedes meiner Projekte z.B. die Funktion Videos zu genrieren oder z.B. zu jedem Zeitpunkt einen hochwertigen Screenshot des aktuellen Fensters bzw. Frames zu machen.

a_setup.pde – Mein Standard Processing-Setup

Die .pde-Datei erhält am Anfang ein a, damit das Setup im zweiten Tab des Editors erscheint.

// Benennung von Videos und und Screenshots
String caption_title = "Lines";
String caption_music = "Musik | mosonic | »«";
String filename = caption_title + "-" + year() + "-" + month() + "-" + day();

import com.hamoid.*;     // Video library importieren
VideoExport videoExport; // Neues VideoExport-object anlegen
Boolean record = false;  // Aufnahme starten nicht starten

void setup() {
  size(1080, 1080);      // Instagram Carousel and Square Post Size
  //size(1920, 1080);    // Full HD
  //size(1080, 1350);    // Instagram Max Post Size
  //size(4000, 4000);    // Cover Artwork
  currentCol = white;    // benötigt colors.pde
  stroke(white);         // benötigt colors.pde
  background(bg);        // benötigt colors.pde
  smooth();
  frameRate(30);
  videoExport = new VideoExport(this, filename + ".mp4");
  videoExport.setFrameRate(30);
  videoExport.setQuality(90, 192); // video quality and audio quality
  videoExport.startMovie();
} // setup

void recording () {
  if ( record == true ) {
    videoExport.saveFrame();
  }
} // recording

colors.pde – Standard Farbpalette

int   alpha           = 20;                           // legt Standard Transparenz fest
color white           = color (255, 255, 255, alpha);
color red             = color (255, 65, 13, alpha);
color orange          = color (255, 178, 13, alpha);
color dark_turqoise   = color (38, 127, 181, alpha);
color grey_blue       = color (116, 138, 166, alpha);
color light_grey_blue = color (174, 194, 224, alpha);
color bg              = color (20,25,31, alpha);

keyPressed.pde – Tastaturbefehle für Sketche

void keyPressed() {
  // Start Video Recording
  if (key == 'r') {
    record = true;
  }
  // Stop Video Recording
  if (key == 'q') {
    videoExport.endMovie();
    exit();
  }
  // Save Image as PNG
  if (key == 's') {
    saveFrame(int(random(1000))  + "-" + year() + "-" + month() + "-" + day() + "-" + width + "x" + height + ".png");
  }
} // keyPressed

$  

Teil der Processing-Serie