Skip to content

Instantly share code, notes, and snippets.

@raphaelschaad
Last active February 1, 2016 01:05
Show Gist options
  • Select an option

  • Save raphaelschaad/9d9fbc24c46e13d9b03e to your computer and use it in GitHub Desktop.

Select an option

Save raphaelschaad/9d9fbc24c46e13d9b03e to your computer and use it in GitHub Desktop.

Revisions

  1. raphaelschaad revised this gist Feb 1, 2016. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion processing_basics.pde
    Original file line number Diff line number Diff line change
    @@ -40,5 +40,8 @@ void setup() {

    // Code repeats
    void draw() {

    // 1..max int
    println(frameCount);
    // close to 60, if nothing stalls; can be changed with frameRate(float)
    println(frameRate);
    }
  2. raphaelschaad revised this gist Jan 25, 2016. 1 changed file with 12 additions and 6 deletions.
    18 changes: 12 additions & 6 deletions processing_basics.pde
    Original file line number Diff line number Diff line change
    @@ -12,9 +12,15 @@ final int x = 0;
    float[] y = {0.0, 1.0};
    String[][] z = {{"he", "ll", "o"}, {"wo", "rl", "d"}};

    // Starting with P3+, e.g. to set screen(w, h) with vars
    // Set size(w, h) or pixelDensity() with vars
    void settings() {

    // Must be first line in settings(), if used, otherwise first line in setup(). Defaults to 100,100 with a light gray background().
    size(300, 300);
    // System vars set by screen()
    println("canvas width: " + width + ", height: " + height);

    // Must be in settings(), if used. Enable retina (2x). Doesn't change displayed window size, just its resolution.
    pixelDensity(displayDensity());
    }

    // Code runs once
    @@ -25,14 +31,14 @@ void setup() {
    }
    }

    // Processing expects external resources in a per-sketch ./data folder
    // Processing expects external resources by default in a per-sketch ./data folder
    println(dataPath(""));
    // Only draw() once

    // Only draw() once. If used in setup(), should be final line. Revert with loop().
    noLoop();
    }

    // Code repeats
    void draw() {

    }
    }
  3. raphaelschaad revised this gist Jan 23, 2016. 1 changed file with 16 additions and 5 deletions.
    21 changes: 16 additions & 5 deletions processing_basics.pde
    Original file line number Diff line number Diff line change
    @@ -1,27 +1,38 @@
    //
    // processing_basics.pde
    //
    // Processing Sketch with a basic structure for learning purposes.
    // Processing sketch with a basic structure for learning purposes.
    //
    // Created by Raphael Schaad on 2016-01-23.
    // This is free and unencumbered software released into the public domain.
    //

    // define global vars (all typed), libs
    int x = 0;
    // Define global vars/consts (all typed), and import libs
    final int x = 0;
    float[] y = {0.0, 1.0};
    String[][] z = {{"he", "ll", "o"}, {"wo", "rl", "d"}};

    // code runs once
    // Starting with P3+, e.g. to set screen(w, h) with vars
    void settings() {

    }

    // Code runs once
    void setup() {
    for (int i = 0; i < z.length; i++) {
    for (int j = 0; j < z[i].length; j++) {
    println(z[i][j]);
    }
    }

    // Processing expects external resources in a per-sketch ./data folder
    println(dataPath(""));

    // Only draw() once
    noLoop();
    }

    // code repeats
    // Code repeats
    void draw() {

    }
  4. raphaelschaad revised this gist Jan 23, 2016. 1 changed file with 10 additions and 10 deletions.
    20 changes: 10 additions & 10 deletions processing_basics.pde
    Original file line number Diff line number Diff line change
    @@ -10,18 +10,18 @@
    // define global vars (all typed), libs
    int x = 0;
    float[] y = {0.0, 1.0};
    String[][] z = {{“he”, “ll”, “o”}, {“wo”, “rl”, “d”}};
    String[][] z = {{"he", "ll", "o"}, {"wo", "rl", "d"}};

    // code runs once
    setup() {
    for (int i = 0; i < string.length; i++) {
    for (int j = 0; j < string[i].length; j++) {
    println(z[i][j]);
    }
    }
    void setup() {
    for (int i = 0; i < z.length; i++) {
    for (int j = 0; j < z[i].length; j++) {
    println(z[i][j]);
    }
    }
    }

    // code repeats
    draw() {
    }
    void draw() {
    }
  5. raphaelschaad created this gist Jan 23, 2016.
    27 changes: 27 additions & 0 deletions processing_basics.pde
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    //
    // processing_basics.pde
    //
    // Processing Sketch with a basic structure for learning purposes.
    //
    // Created by Raphael Schaad on 2016-01-23.
    // This is free and unencumbered software released into the public domain.
    //

    // define global vars (all typed), libs
    int x = 0;
    float[] y = {0.0, 1.0};
    String[][] z = {{“he”, “ll”, “o”}, {“wo”, “rl”, “d”}};

    // code runs once
    setup() {
    for (int i = 0; i < string.length; i++) {
    for (int j = 0; j < string[i].length; j++) {
    println(z[i][j]);
    }
    }
    }

    // code repeats
    draw() {

    }