Tag Archives: recipe 3

Using lights

Making my way through the Using lights recipe from the Processing 2 Creative programming cookbook source code on GitHub. In this recipe, I learned how to declare the lightMode and lightDirection integers to allow for different lighting modes to be activated. Inside the setUp function they’re assigned a value of 0 and then referenced again in the if test. In this recipe, I also learned how to use the lights, directionalLight, ambientLight, pointLight and spotLight functions for the different lighting modes, even the noLights function for a no lighting mode.

This recipe contains code for generating and animating 3D primitives (first demonstrated in Drawing 3D primitives recipe) used to demonstrate the lighting setup. This recipe also contains code for a keyboard interface (first demonstrated in the Keyboard interaction recipe) to activate different lighting modes. For this keyboard interface, N = no lights, L = lights, D = directional light, A = ambient light, P = point light, S = spot light. The Up, Right, Down and Left arrow keys also change the direction of the light when the directional light is activated.

Screen-Shot-2014-04-28-at-8.36.26-PM

Working with images

Making my way through the Working with images recipe from the Processing 2 Creative programming cookbook source code on GitHub. In this recipe I learned how to:

  • use the loadImage function to load an image from my data folder into my Sketch
  • declare a boolean (pixelMode) for the if test
  • use the image function to display the new images (dimensions specified in copWidth and copyHeight and areas specified by the pixel-swapping if test) in the window.

I also learned about the get and set methods and how they can be used to define a region and change the colour of the loaded image. Rad!

Screen Shot 2014-02-25 at 7.55.21 PM

Screen Shot 2014-02-25 at 7.55.31 PM

Screen Shot 2014-02-25 at 7.54.56 PM