Last active
February 1, 2016 01:05
-
-
Save raphaelschaad/9d9fbc24c46e13d9b03e to your computer and use it in GitHub Desktop.
Processing Sketch with a basic structure for learning purposes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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/consts (all typed), and import libs | |
final int x = 0; | |
float[] y = {0.0, 1.0}; | |
String[][] z = {{"he", "ll", "o"}, {"wo", "rl", "d"}}; | |
// 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 | |
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 by default in a per-sketch ./data folder | |
println(dataPath("")); | |
// Only draw() once. If used in setup(), should be final line. Revert with loop(). | |
noLoop(); | |
} | |
// Code repeats | |
void draw() { | |
// 1..max int | |
println(frameCount); | |
// close to 60, if nothing stalls; can be changed with frameRate(float) | |
println(frameRate); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment