fadeenk

Processing

Oct 6th, 2012
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.23 KB | None | 0 0
  1. Lesson 1 (Downloading/setting it up) (video)
  2. --------------------------------------------
  3. Downloading:
  4. 1. Processing.org
  5. 2. Click download
  6. 3. Pick according to your computer specs
  7. 4. go to folder in program -- extract
  8. 5. run (remember to drag down)
  9. ---------------------------------------------
  10. Introduction:
  11. 1. void setup() .
  12. - Used to define initial properties such as screen size, background color.
  13. - Variables declared within setup() are not accessible within other functions.
  14. - Only one void setup() allowed.
  15. ---------------------------------------------
  16. 2. void draw()
  17. - Called directly after void setup().
  18. - continuously executes the lines of code contained inside its block until the program is stopped.
  19. - only one void draw() allowed.
  20. ---------------------------------------------
  21. 3. size (400, 400);
  22. - First things first, display box.
  23. - Defines the dimension of the display window in units of pixels.
  24. - Placed in void setup() , if not, default is size (100,100);
  25. - Width and Height.
  26. ----------------------------------------------
  27. 4. Example (Ellipse)
  28. - ellipse ( x , y , width, height)
  29. - ellipse ( 200, 200, 50,50); // placed at center and have 50 width and 50 height(pixels)
  30. - ellipse ( mouseX, mouseY, 50,50); // placed where your mouse goes, same size
  31. ----------------------------------------------
  32. 5. Background
  33. - default is gray.
  34. - Parameters ( Red, Green, Blue) from 0 to 255.
  35. - Parameters (255); sets color for all 3 parameters.
  36. - Placed in either(void setup() or void draw() ). show difference(and then show difference before after ellipse
  37. -but if placed in setup the position will not be cleared out, as opposed to draw() which refreshes screen everytime.
  38. -Les1Co1
  39. -----------------------------------------------
  40. 6. strokes/noStroke
  41. - Edges/Borders of your object.
  42. - stroke( Red, Green, Blue);
  43. - Placed behind "ALL" the objects you want to have that color of edge, that come after in the coding.
  44. - Will make the edges of all shapes until another stroke(); is declared.
  45. -----------------------------------------------
  46. 7. Fill
  47. - Fill all the objects after it with the color you chose, until new fill.
  48. - fill ( Red, Green, Blue);
  49. - for example purple = fill (255,0,255);
  50. -----------------------------------------------
  51. Review
  52. 1. Setup - size, background
  53. 2. Draw - the repeat loop/programming
  54. 3. Size -size of the display screen
  55. 4. Ellipse -shape, parameters (x, y, width, height)
  56. 5. Background - difference between being in setup and draw?
  57. 6. stroke/noStroke - edges of a shape
  58. 7. fill - colors in shapes, all after this code
  59. ------------------------------------------------
  60. Project:
  61. 1. Create 1 Ellipse of any size in the center of a 500 by 500 size screen, fill it in with blue, and have the outline be red
  62.  
  63. 2. Make your code to where the background does not refresh, for your Eclipse coordinates type "MouseX and MouseY"
  64. make the background yellow.
  65.  
  66.  
  67. Lesson 2: Tricks, Lines, Mouse
  68. ---------------------------------
  69. 1. Lines
  70. - Draw a line on the screen
  71. - Syntax: line(x1, y1, x2, y2)
  72. - Parameters (first point, seconc point)
  73. ----------------------------------
  74. 2. strokeWeight()
  75. - adds thickness to the line
  76. - add right before the lines you want to increase thinkness
  77. - syntax: strokeWeight(8); //
  78. -the higher the number inside, the thicker the line
  79. -it will not go under default, for example .5 wont make it thinner than 1
  80. -----------------------------------
  81. 3. MouseX and MouseY
  82. - Using your mouse for the coordinates
  83. - Neat trick, giving you the control with your mouse
  84. -
  85. -----------------------------------
  86. 3. pmouseX and pmouseY
  87. - creates that special effect lag
  88. - Syntax: (pmouseX, pmouseY, mouseX, mouseY);
  89. - Contains the horizontal/Vertical position of the mouse in the frame previous to the current frame.
  90. -----------------------------------
  91. 4. if-Statement
  92. - A conditional Statement
  93. -Syntax:
  94. ------
  95. if (test) {
  96. statements
  97. }
  98. -----
  99. -It allows code to execute on whether the test is true or not
  100. -------------------------------------
  101. 5. mousePressed
  102. - When mouse pressed checks for validity
  103. - Goes inside void draw()
  104. - true/false
  105. -------------------------------------
  106. 6. mousePressed()
  107. - when mouse pressed it calls the function, then it reacts accordingly
  108. - outside of void draw()
  109. - values
  110. -Les2Co1
  111. ------------------------------------
  112. 6a.
  113. A. Clearing
  114. If(mousePressed==true)
  115. {
  116. Background(0); // clears window
  117. }
  118. -------------------------------------
  119. 7. mouseClicked()
  120. - Function is called once after a mouse button has been pressed and then released.
  121. - Outside void draw()
  122. - values
  123. - Les2Co3
  124. -------------------------------------
  125. 8. MouseDragged()
  126. - Function call when mouse is moving and the mouse is being pressed
  127. - refer to code
  128. - Outside void draw()
  129. - values
  130. -Les2Co2
  131. -------------------------------------
  132. Review:
  133. 1. Line syntax
  134. 2. What does strokeWeight do, and difference to just stroke?
  135. 3. What does pmouseX and pmouseY do?
  136. 4. What are "if statements" for?
  137. 5. difference between mousePressed and mousePressed();
  138. 6. What is a method
  139. --------------------------------------
  140. Project:
  141. 1. Write a code that everytime you press the mouse it changes from black to white, and vice-versa
  142. 2. Write a code to where you can draw with lines, pressing the keyword "C" will clear your screen.
  143.  
  144.  
  145. Lesson 3: OPENGL
  146. ----------------------------------------------
  147. 1. OPENGL
  148. - OPENGL is a library (Open Graphics Library)
  149. - Allows 3d Graphics into your code
  150. - Must be imported(As any library should be)
  151. ----------------------------------------------
  152. 2. Creating the Cube
  153. - box (); size of the cube (width, height, depth);
  154. - translate (); location of object
  155. - Les3Co1
  156. -----------------------------------------------
  157. 3. rotateY and rotateX
  158. - Can be actual coordinates or your mouse // way it faces
  159. - For example it can be rotateX(PI/3.0); or rotateX(MouseY);
  160. - rotateX will synch will mouseY and rotateY will synch with mouseX,
  161. - This is because they are backwards
  162. - Rotating is quite quick, to slow down multiply times .03
  163. -----------------------------------------------
  164. 4. Operators
  165. - Addition, Subtraction, Multiplication and Division
  166. - Used to alter the code
  167. - +, -, *, /
  168. -----------------------------------------------
  169. 5. Directional Lights
  170. - Adds a directional light
  171. - Syntax: directionalLight(red, green, blue, x, y, z)
  172. - x = 1 (left) = -1 (right), y= 1 (top), y = -1 (bottom), z = 1 (back), y =-1 (front)
  173. -----------------------------------------------
  174. 6. Point Lights
  175. - Syntax: pointLight(v1, v2, v3, x, y, z) (red, gree, blue, x,y,z)
  176. - places the light at the coordinates you choose
  177. -as oppose to directional lights that it just -1,0 and 1.
  178. -------------------------------------------------------
  179. 7. pushMatrix() and popMatrix()
  180. - 3d shapes placed in the same coordinates will be displaced, using pushMatrix and popMatrix() it will fix this error.
  181. - place pushMatrix(); before and popMatrix(); after your 3d shape and all its modifications.
  182. -
  183. pushMatrix();
  184. stroke(weight(1);
  185. box(x,x,x,);
  186. popMatrix();
  187.  
  188. Review:
  189. 1. What is the OPENGL library for?
  190. 2. What is translate used for?
  191. 3. What is rotateX and rotateY used for?
  192. 4. What is the operator sign for multiplication?
  193. 5. directional lights -on and off lights
  194. 6. point lights - lights at certain coordinates
  195. ------------------------------------------------
  196. Project:
  197. 1. Create 2 cubes, one red and one blue, one cube has to be twice the size of the other, can have any positioned location and must stay in place.
  198.  
  199. 2. Create 4 cubes, reb, blue, green, and purple. must move according to your mouse, but every cube must move in an opposite direction from each other.
  200.  
  201.  
  202. Lesson 4: Minim
  203. ------------------------------------------
  204. 1. Importing Minim
  205. - import ddf.minim.*; (Very will go at the top) such as any imported library, like OPENGL
  206. - It is one of the libraries in Minim Folder
  207. - Allows sound to be used in your program
  208. --------------------------------------------
  209. 2. Creating a folder
  210. - Inside your "processing folder"
  211. - Once in the processing folder, go to the folder of your code(Les4Co1)
  212. - Create new folder, call it "data" (data) (traditional, and easy to remember)
  213. - Copy and paste the song into that folder (song file)
  214. - Processing folder --> Les4Co1 folder --> data folder --> song file
  215. --------------------------------------------
  216. 3. Creating variables - Minim
  217. - Minim minim (Minim + "variable") -- (Placed at the top)
  218. - The first part is mandatory, while the variable can be anything, but traditionally "minim" and "song" are used instead.
  219. ---------------------------------------------
  220. 3b. Creating Variables - AudioPlayer
  221. - AudioPlayer song (AudioPlayer + "variable")
  222. - AudioPlayer is used to allow sound to be played.
  223. -
  224. -----------------------------------------------
  225. 4. song.play(); and song.loop();
  226. - Used to play your song in your program
  227. - song.play(); plays the song, once
  228. - song.loop(); plays the song various times
  229. -----------------------------------------------
  230. 4. Example
  231. - Variables placed at the top
  232. - minim = new Minim(this);
  233. - song = minim.loadFile("Daniel-I Am Boxxy You See Song.mp3");
  234. - song.play();
  235. - Les4Co1
  236. -------------------------------------------------
  237. 5. void stop()
  238. - Used to safely stop the program
  239. - code is:
  240. - song.close();
  241. - minim.stop();
  242. - super.stop();
  243. --------------------------------------------------
  244. 6. ddf.minim.analysis.*; - Using BeatDetect
  245. - Variable: BeatDetect beat;
  246. - Variable (beat) can be anything but traditionally "beat"
  247. - Used to detect beat of a song to precise calculations.
  248. - Syntax: beat = new BeatDetect();
  249. - Les4Co2
  250. --------------------------------------------------
  251. 7. beat.setSensitivity();
  252. - Inside the parameters, which is only one, sets the sensitivity
  253. - Measured in milliseconds
  254. - Default: 10 milliseconds.
  255. --------------------------------------------------
  256. Review:
  257. 1. What does the Minim Library do?
  258. 2. Where do we place the objects?
  259. 3. What will song.play(); do?
  260. 4. Why do we place a "void stop() method at the end of our code"
  261. 5. What is Minim, AudioPlayer, BeatDetection for?
  262. 6. What is beat.setSensitivity do?
  263. 7. What folder do you need to make to place your music in it?
  264. -----------------------------------------------
  265. Project:
  266. 1. Import a sound of your choice into your program and then run it.
  267. 2. Write a code using BeatDetect
Advertisement
Add Comment
Please, Sign In to add comment