Logo

Developer learning path

Processing

Basic elements of a Processing program

Basic elements of a Processing program

88

#description

Processing is an open-source programming language and environment for creating interactive visualizations and animations.

A Processing program is made up of several basic elements, which are as follows:

  1. Setup: This is the first part of a Processing program, where you define the size of the canvas and other essential settings for your sketch. This function is called only once and is generally used to initialize variables and objects.
  1. Draw: This function contains the main code of your sketch and is called repeatedly after the setup function. Here, you can define how your graphics will be drawn, for example, with shapes, colors, and images. You can use various parameters such as mouseX, mouseY, and width to create interaction and make your sketch more dynamic.
  1. Size: The size function is used to set the width and height of the canvas. It is typically used inside the setup function.
  1. Background: The background function is used to set the background color of the canvas or to clear the screen.
  1. Shape: Processing provides various functions to create shapes such as rect(), ellipse(), line(), or bezier(). These functions are used to create geometrical shapes or to draw curves and lines.
  1. Color: Colors in Processing are represented by the RGB model (red, green, blue), where each value can range from 0 to 255. You can set up a color using different functions such as color(), background(), or fill().
  1. Images: Processing provides functions to load and display images using functions such as loadImage() and image().
  1. Variables: Processing allows you to define different types of variables such as integer, float, or boolean. Variables hold values that can be used in your program to control animation or user interaction.

These are some of the basic elements of a Processing program that you need to understand to create interactive visualizations and animations.

March 27, 2023

If you don't quite understand a paragraph in the lecture, just click on it and you can ask questions about it.

If you don't understand the whole question, click on the buttons below to get a new version of the explanation, practical examples, or to critique the question itself.