0% found this document useful (0 votes)
215 views

Processing Cheat Sheet English

Dicas rápidas para começar um sketch em Processing.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
215 views

Processing Cheat Sheet English

Dicas rápidas para começar um sketch em Processing.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 9
open srattack com nk Erasure arent ret void setup()¢ 7/Runs only once y void draw(o{ Runs repeatedly during the execution } @ variables Types int Postve and negative integer variables. float Floating point negative and postive variables boolean Variables of whch vals can be! TRUE or FALSE ‘Stores color type values in diferent formats, char Stores a single character. string Stores a single string, Cy id size (width, height); Sets main window size in pixels, background(color); Sets window background colar. smooth() ‘Sets antialiasing on FrameRate (fps); Sols the application's FPS. printIn(string); rites a string to the console CUE a id rrandom(low, high) ; Retums @ random value within the ints, randonSeed(seed) ; ‘Changes random seed. noise(value); tums a value in Perl Nolse sequence. noiseDetail (octaves) Sets detail tireshod for noise function results noiseSeed(seed) ; (Changes noise seed. width Rotums sketch's width n pixol height tums sketch's height in pels mouseX tur mouse pointer's postion (axis) nouseY Rotur mouse pointe's positon (Y axis) prouseX. FRetums previous mouse pointer's X axis prouse¥ Fetums previous mouse pointer's ¥ axis. frameCount tums sketch's curent fame, FrameRate Retums skotch's curent FPS, Fill(color); ‘Sets the color used to fil shapes. noFil1(); Disables fil color stroke(color); ‘Sets the color used to draw strokes/borders around shapes. noStroke() ; Disables border for shapes. #1110255); #2110255); noFA1LOs nostroke(); stroke(@); stroke(@) ora aay colorMode (mode) ; ‘Set color mode, Usually RGB or HSB. red(color); Return the ed value ofthe color green(color) Fetum the green value ofthe color. blue(color) ; FRetum the blue value ofthe color. hue(color) ; Return the hue value of the color. saturation(color); tum the eaturation value ofthe coor. brightness(color); tum the brightness value ofthe color. alpha(color) FRetum the transparency value ofthe color. LerpColor (colort ,color2,noment) tums @ color value betwoon two colors. Popa is peer SS cur color (grayscale); color (grayscale, alpha); © 199) (255) color(red, green, blue) ; ml a color(red, green,blue, alpha) ; (255,0,0) (@,255,0) (0,0, 255) (255,255,0) (0,255,255) (255,0, 255) @ Coordinates system xX 4, > yi? In any Processing sketch, top left comer is the (0, 0) point. That axis changes when we make Use of translate) or rotate). © 122,100) Minimum unit of measurement in a computer screen is the Pixel. © (120,200) pushMatrix(); Saves the current matrix. Meaning the “translate, rotate and scale" values, For every pushMatix() belongs a final popMatrix) popMatrix() ; ‘Allows you to go back to the last saved matrix. You need a previous pushMatrx() to go back to an older matrix printMatrix(); Prints current matrix tothe console. translate posx, posy) Moves the anchor point to a certain postion After this the (0,0) isthe certain postion. rotate(radians) ; Changes plane rotation according to axis scale(x,y) Scales the plane, affects al sizes on the sketoh can also be: scaly.2) or scalmutiple), shearX(radians) ‘Applies a shear on X avs shearY(radians) ; Apples a shear on ¥ ax. rotatex(radians) ; Applies rotation to X axis, Works only on 3D enviroments rotateY (radians) ; Apples rotation to Y ax, Works only on 2D enviroments. rotateZ(radians) ‘Applies rotation to Z axis, Works only on 3D enviroments pushstyle(); Saves the curent style of fil), stroke tint), strokeWeigh, strokeCap),strokeJoing, imageMode), rectModel, elipseMode), shapeMode), colorModep, textAlgng, textFont, texiModeo, textSizo),toxtLeadingd, emissived, specular), shininess), ambient popstyle(); Goes back to lat siyle used. You need a previous pushStye0 to go back to an older style Pais perrereceens om oe eres width, height rt ery ee neigh ead eC point (posx, posy) ; Draws a point fo the screen. quad(x1,y1 x2, y2,x3,y3,x4, y4) 5 Draws a quadflateral based upon the our vertex positions we pass. arc(posx,posy, width, height, startangle, endangle) ; Rea MST) y! posx2, Cone Draws an arc in position (posx, posy), with size "width" and "height", and ‘startangle" and “endangle' passed as radians. triangle (xt, y1,x2,¥2,x3, 93); Draws a tangle based upon three postions passed as arguments @ Bezier and curves bezier(x1, yl, x2, y2, x3, y3, x4, v4) Draws a Bezier- positions 1 and 4 are the main anchor points, 2 and 3 work as control points, bezierDetail (level); Sets the Bezier detail evel bezierTangent(a, b, c, d, moment); Retume the Beziers tangent at “time” bezierPoint(a, b, c, d, moment); Fetus the Beziers axis positon at “time curve(xt, yl, x2, y2, x3, y3, x4, y4); Draws a curve. postions 1 and 4 are the main anchor points, 2 and 3 work as control points. curveTightness(tightness) ; Sets tightness forthe next curves. curvePoint(a, b, c, d, t); Retums the curve's axis position at "time". curveTangent(a, b, c, d, t); FRotums the curve's tangent at "time" curveDetail (detail); Sets the curve detal level rv) beginShape() and endShape() beginshape(); ‘Stars Istening for vertices to build a shape. It stops listening ‘when endShaped is called. Modes can be passed as arguments, ‘endShape() ; ‘Stops listening for vertices. vertex(posx, posy); Draws a vertex in position (o08x. posy) bezierVertex(x2, y2, x3, y3, x4, y4); Defines a vertex based on a Bezier curv. curveVertex(x, y); Defines a vertex based on a curve texture(PImage) ; Sets the texture fora drawn shape. beginContour(); Starts Istening for vertices to cut a previous form endContour(); ‘Stops listening for "beginContour’ vertices. @ Functions structure // Create the function void hello (){ printin("Hello } / Call the function insult; Create) class ClassName( ClassNane (/+Variables*/)( MIC ictor y void methodNane(/+Variables*/){ ) } //declare an objec ClassNane myClass; void setup(t Initialize an object myClass = new ClassNane(/*Variables*/); } void draw()¢ Hcal ject method myClass.methodName() ; farables or variables //Simple usage of For loop for(int i = 0;i /INested For loop for(int i = ;i Rear Eat eee en PFont font; void setup() £ font = loadFont(”Helvetica-32.v1w"); textFont(font, 32); y void draw() ¢ text ("Hello”, 0, 0); ‘image img, posx, posy, width, height); Draws an image in the main screen. Loadtmage(fileNane) ; Initalzes a Plage passing an image ile name or path as ‘an argument requestImage (FileName) ; Inialzes a Plmage on a separate toad. tint (color) ; ‘Sets the tint value ofan image. noTint(); Disables image tint. saveFrane(filenane) ; text (string, posx, posy); Displays text on the screen. LoadFont (FileName); Initalzes a Pont passing a font fle name or path as an argument. textFont (font, size); ‘Sets font type and size, textAlign (mode) ; Sets align mode to: LEFT, FIGHT or CENTER. textLeading(size); cing between lines of extn units of px Ou Re ag Ce RE fee SS ier PShape myshape; void setup() £ myshape = loadShape(""nyShape. svg"); y void draw) ¢ shape(nyshape, @, 0); bee een ed float x; Weasing value float easing = 0.05; void setup() ¢ size(22e, 120); > void draw() ¢ background(e); float targetX = mousex; x += (targetX - x) * easing; ellipse(x, 42, 10, 10); @ Events captur ‘ void mousePressed() Funs when any mouse button is pressed. void mouseClicked() uns when any mouse button is pressed and released, void mouseMoved() uns everytime mouse is moved and NOT pressed. 3 void mouseDragged() i uns everytime mouse is moved while a button is pressed void mouseReleased() Funs when any mouse button is released Z void keyPressed() uns on a key press event void keyTyped() uns when a key is pressed except for SHIFT, CTRL of ALT. void keyReleased() uns on akey reloase event. Pears k ctrl) Rute geserck cree) Cv sistent eee LV ines tener anol void draw() ¢ void draw() { if (keyPressed == true) { if mousePressed == true) { Fi11(@); //If any key is pressed Fi11(@); //If mouse is pressed } else ¢ ) else ( . Fi11(255); //0therwise #i11(255); //0therwise y y 3 rect(25, 25, 58, 50); rect(25, 25, 50, 50); 2 ? 1's a special variable w 3 ee Paneer og eee void draw) { void keyPressed() { z if (keyPressed) ( iF (key == CODED) ¢ af (key == 'b" [| key == '8') ( if (keyCode i Tf B key is pressed // If UP arrow key is pressed } } else if (keyCode == DOWN) { } else { /1 Tf down arrow key is press : // otherwise > > p else ¢ ) // Otherwise 2 5 ? = aor Se SS eS @ one dimension array int [] arrayint = { 43, -2, 8, 1}; //peclaration of an Particle (] particles; ject array printIn(arrayInt£0]) ;// Prints 43 printIn(arrayInt{1]);// Prints -2 void setup(rc 3 printIn(arrayInt{2]);// Prints & /Set the size of our array particles = new Particle(5@]; 3 for(int i = 0; particles. length; i++){ particles[i] = new Particle(); ? Cv ore dard ‘1 s void draw(o{ call a function of each object for(int i = 0; isparticles length; i++)( particlesCiJ.dran(); //peclaration of an array int [1] arrayint; void setup(y( /set the array's size > arrayint = new int(50]; 2 mnitialize each index value for(int i = @; icarraylnt. length; i+)¢ arrayInt{i) = ) > Void draw(y¢ //oeclaration ray Uiaurteaa tec eaviel cerita a int CIC] array20; for(int 4 = @; icarrayint.length; it+){ printIn(arrayintCil) ; Cenod ) //peclaration of our array y array20 = new int[width]Cheight]; //initializing every index ae forCint 1 = 6; tewiathy tee for(int j = 0; jcheight; 5++)¢ array2D[iJ03] = int (random(1@6)); @ array functions nia ‘append(array, value) ; > ‘Acid a value to an aay. arrayCopy(sre, srcPos, dst, dstPos, length); Copy an array or art oft inte another void draw(o{ //Pisplaying each index value for(int i = @; iswidth; in){ ‘concat (a,b); for(int j = @; icheight; j++)¢ CConcatenates two arrays. printIn(array20[iJCi]); expand(array,newSize) ; 5 Expands and array's size value. ) reverse(array); > Roverses an array order. shorten(array); Reduces aray's size by one index. sort(array); Sorts an aray in increasing order. splice (array, value/array, index) ; Inserts a value or an array inside any given index subset(array, start, count) Extracts set from a given aay from ‘star to "count Peace Cac EGAN lass ‘An excelent 00k for beginners Covers a let of tonics, Parictly oxolaned, Interactivity. It's an introduction to Processing, Opentameworks and Arduino. Covers many aspects of of the three, Ce eae) ees [A good book at a complement to “Learning Processing", bath of them 900d introduction Ce eel Prue i cs 1 2 Generative at rented book Covers same Processing based projects And comes witha blo exanphs 10 ovnioas, ey ee and Computational Art. aries Another good attemative to start ‘with Processing. Contains @ verse mount of examples eee eu) cease “This book reviews some important aspects to go further inthe task of Teaming Processing processing. org (Ofical Procesing's webste, Docuretaton and dowricad openprocessing. org (Open Processing community where you can upload and review related works. wiki.processing. org Processing's official Wik. forum.processing.org Processing offal forum. vimeo. con/channels/processing Processing channel on Vimeo, flickr. com/groups/processing/ Processing account on Flickr creativeapplications.net This forum gathers digital installations and works made with Processing and ot createdigitalmotion.com One of the most updated blogs with information about new communication media reatve coding tools wy Uae ALT = VAN) ee eee nts Se oS RS ee Mee oes)

You might also like