Lecture 3 (10 Feb)
You can jump to any slide with the menu to the (bottom) left.
Did you miss a slide or want to revisit? Open the narration tab while studying to get an explanation of difficult slides.





fill(255) to set the fill colourcolor defines a color that we can store in a variable to use laterClass Assignment: Gradient
With the help of the previous slides, create a sketch that draws a range of distinct colours (e.g. a rainbow)
Convert it to a continuous gradient by using loops to draw many rectangles with slightly different colours


0-2550 is fully transparent and 255 is fully opaquelet transparentRed = color(255, 0, 0, 127); // Creates a semi-transparent red colour
let transparentGreen = color(0, 255, 0, 200); // Creates a slightly transparent green colour
let transparentBlue = color(0, 0, 255, 50); // Creates a very transparent blue colour
let transparentPurple = color(134, 42, 200, 100); // Creates a semi-transparent purple colour"https://...")"imageName.png")loadImage function, which takes the path to the image as an argument and returns a p5 image objectpreload function, which is similar to setup but is specifically designed for loading files before the sketch startsimage function to draw the image on the canvas, specifying the position and sizetint applies a filter to the image, changing its colour and/or transparencyClass Assignment: Alpha
tinttranslate function to change the origin pointtranslate, as it changes the coordinate systemdraw functiontranslate at the start of the draw function if you want to apply it every timemouseX and mouseY give the position of the mouse relative to the original coordinate system, not the translated onerotate function to rotate around the origin pointtranslate, the rotation will affect everything after itangleMode to DEGREES if we want to use degreestranslate, the rotation resets at the end of the draw functionframeCount)

Class Assignment: Symmetry
pmouseX and pmouseY give the previous position of the mouse (pmouse as in previous mouse)scale to change the size of our shapes and imagesshearX and shearY create slanting effectspush() and pop() allow us to save and restore the state, which is useful for applying transformations to specific parts of our drawing without affecting the rest
Creative Programming 2026 Lecture 3 - Ties Robroek - IT University of Copenhagen