Tag Archives: recipe 4

Accessing screen size and density

Making my way through the Accessing screen size and density recipe from the Processing 2 Creative programming cookbook source code on GitHub.

In this recipe I learned how to use the Android DisplayMetrics class to determine general information about the display of the device used to run the sketch.  While this is more of a diagnostic recipe than a creative one, I think it’s pretty useful way for finding out more about the capabilities of your device which could then inform the way you code your sketch. Nice.

Screenshot_2014-05-15-21-04-21

Screen-Shot-2014-05-15-at-9.01.26-PM

Making polygon soup

Making my way through the Making polygon soup recipe from the Processing 2 Creative programming cookbook source code on GitHub.

In this recipe I learned how to create a 3D cylinder with a flexible function that allows for the top, bottom and sides of the cylinder to be customised. In this recipe, the QUAD_STRIP parameter (draws a series of connected quads) is introduced in the beginShape function.

Once again, the frameCount system variable is used to rotate each 3D object by one degree per frame as the value of the variable is increased by one in each frame.

Screen-Shot-2014-04-29-at-9.30.34-PM
Removing the code responsible for drawing the bottom and sides of the each cylinder to learn more about how the function draws the cylinder to the screen.
Screen-Shot-2014-04-29-at-9.31.04-PM
Removing the code responsible for drawing the top and bottom of the each cylinder to learn more about how the function draws the cylinder to the screen.
Screen-Shot-2014-04-29-at-9.31.46-PM
Removing the code responsible for drawing the top and sides of the each cylinder to learn more about how the function draws the cylinder to the screen.
Screen-Shot-2014-04-29-at-9.32.29-PM

Drawing text

Making my way through the Drawing text recipe from the Processing 2 Creative programming cookbook source code on GitHub.

In this recipe I learned how to declare PFont objects for the fonts to be used in the Sketch and set the second parameter of the textFont function to determine the size of the text. For example, textFont (junction, 18). I also learned how to use:

  • loadFont function to load the fonts into the PFont object
  • draw function to draw lines of text
  • text function to draw text to screen
  • textAlign function to align the text to the coordinates used in the text function. For example, LEFT, CENTER or RIGHT.
  • textWidth to return the width of a text block in pixels. In this Sketch, the width was the string of text “Nulla blandit ut magna”.
  • textLeading to set the leading of three different text blocks.

Screen-Shot-2014-02-26-at-8.39.11-PM

Another thing I learned from this recipe was how to use Create font tool that’s part of Processing to convert each font from its original format to a bitmap format used by Processing.

Screen-Shot-2014-02-26-at-8.48.29-PM

Screen-Shot-2014-02-26-at-8.43.19-PM