Code Snippets Processing

Short texts Processing 🧑‍💻 Code snippets Processing ✍️ Reading lists Processing 👀

Pressure sensor w/ Arduino + Processing

Video demo and explanation here: https://youtu.be/CYUlLaxY4Xs const int analogInPin = A0; // Analog input pin that the potentiometer is attached to int sensorValue = 0; // value read from the sensor int outputValue = 0; // value output to the serial line void setup() { // initialize serial communications at 9600 bps: Serial.begin(9600); } void […]

wonky_grid.pde

int cellSize = 10; int numberOfLines = 50; int rectSize = 10; int yPos = 0; int xPos = 0; int gridSize = 10; void setup(){ size(500, 500); background(255); stroke(255, 0, 0); noFill(); // Makes a grid using lines //for(int i = 0; i < numberOfLines; i++){ // line(i * cellSize, 0, i * cellSize, […]

Ramer–Douglas–Peucker algorithm

// Algorytm zmniejszajÄ…cy topologiÄ™ linii ArrayList allPoints = new ArrayList(); float epsilon = 0; void setup() { fullScreen(); //size(600, 400); for (int x = 0; x < width; x++) { float xval = map(x, 0, width, 0, 5); float yval = exp(-xval) * cos(TWO_PI*xval); float y = map(yval, -1, 1, height, 0); allPoints.add(new PVector(x,y)); } […]

celluar automata 1D in Processing

// celluar automata 1D class Matrix2D { ArrayList val; int[] shape = new int[2]; Matrix2D(int size0, int size1, String init_method) { val = new ArrayList(); shape[0] = size0; shape[1] = size1; for (int i = 0; i < size0; i++) { ArrayList column = new ArrayList(); for (int j = 0; j < size1; j++) […]