The document provides information about data types, control flow, 2D primitives, coloring, constants and functions that can be used for processing data. It includes examples of how to assign variables, use relational and logical operators for conditionals and loops, as well as how to draw basic shapes and set colors.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
33 views
Processing Cheat Sheet
The document provides information about data types, control flow, 2D primitives, coloring, constants and functions that can be used for processing data. It includes examples of how to assign variables, use relational and logical operators for conditionals and loops, as well as how to draw basic shapes and set colors.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1
PROCESSING CHEAT SHEET
DATA TYPES CONTROL
Assign variables Relational Primitive Relational Operators boolean = assign value to a variable == equality == (equality) byte ; statement terminator > greater than > (greater than) char , separates parameters in function >= greater than or equal to >= (greater than or color separates variables in declarations != inequality equal to) double separates variables in array <= less than or equal to != (inequality) float /*** Assign variables ***/ /*** Example ***/ < (less than) int //Format is in variable_type variable_name; if(total == 100){ <= (less than or equal long int total; //Then do this to) //Then you can assign a value to it later } Composite total = 0; ! Iteration Array //Or, assign a value to it at the same time for Iteration ArrayList int total = 0; while HashMap //Note: use one of the primitive data types while executes statements while the Object on the left expression is true Conditionals String ! for loop continues until the test break XMLElement evaluates to false case Structure: program structure /*** while Example ***/ ?: (conditional) Conversion setup() defines initial enviroment while(total < 100){ continue binary() properties, screen size, total++; //adds 1 to total default boolean() background before the draw() } else byte() draw() called after setup() & executes if char() code continuously inside its /*** for Example ***/ switch() float() block until program is stopped for(int i=0; i<100; i++; ){ hex() or noLoop() is called. //Do something here Logical Operators int() size() size() must be first line in } && (logical AND) str() setup() defines dimension of ! ! (logical NOT) unbinary() display in units of pixels || (logical OR) Conditionals unhex() noLoop() Stops Processing from executing code within draw() if if statement evaluates to true String Functions continuously then execute code join() /*** Example ***/ else extension of if statement match() void setup() { executes if equals false matchAll() size(200, 200); else if extension of if statement nf() background(0); executes if equals true nfc() fill(102); /*** if / else / else if ***/ nfp() } if(total == 100){ nfs() void draw() { //total is equal to 100 split() //Draw code here } splitTokens() } else trim() ! if(total < 100){ //total is smaller then 100 2D Primitives Array Functions } append() point() draws a point else{ arrayCopy() point(x, y) //total is bigger then 100 concat() point(x, y, z)//3D } expand() line() draws a line ! reverse() line(x1, y1, x2, y2) Coloring stuff shorten() line(x1, y1, z1, x2, y2, z2)//3D rect() draws a rectangle background() sets background color in RGB or sort() rect(x, y, width, height) hexadecimal color splice() subset() elipse() Draws an elipse background(value1, value2, ellipse(x, y, width, height) value3) arc() draws an arc background(hexadecimal_value) Constants arc(x, y, width, height, start, stop) fill() sets color for shape HALF_PI /*** Arc (portion of circle) ***/ fill(value1, value2, value3) PI QUARTER_PI //x & y = coords, width & height = size fill(hexadecimal_value) TWO_PI //start + stop = starting and end points stroke() sets color for shape (think angle in radians) of circle in π pie stroke(value1, value2, value3) ! LINK stroke(hexadecimal_value) arc(x, y, width, height, start, stop) /*** Example ***/ arc(100, 100, 50, 50, PI, 2*PI);//Sad Face //Note call fill or stroke before every shape you arc(100, 100, 50, 50, 0, PI);//Happy Face are planning on using different colors on each //Note: Play around with start and stop. Use stroke(#CCCFFF); PIE constants or math operators PI/3 , .5*PI fill(#FFFCCC); rect(100,100,50,50);