ITP1 Workshop1
ITP1 Workshop1
z
CM1005
Introduction to
Programming I
Class etiquette
If you feel a strong urge to talk, you and your friends may
proceed out of the lecture hall for further discussion.
Coursera
setup()
Called once when the program starts
draw()
Call repeatedly once every frame.
Chrome
View->Developer->JavaScript Console
Safari
Safari –> Preferences->Advanced->tick Show Developer menu in menu bar
Firefox
Tools->Web Developer->Web Console
Red, Green, Blue
(RGB) Colours
In computer, colours are
represented in RGB.
Each component represent the
amount of “R, G or B” it has in
that colour
For example, a pure red will have
Red 100%
Green 0%
Blue 0%
Red, Green, Blue
(RGB) Colours
Each component is 8 bits
0 to 255
For example, a pure red will have
Red 255
Green 0
Blue 0
So each RGB pixel requires
3x8=24bits
So in total, a computer can have 224
=16777216 colours
Red, Green, Blue
(RGB) Colours
Online colour picker
https://www.rapidtables.com/
web/color/RGB_Color.html
Black, White, Grey
Colours
For pure white, all RGB values
are 255.
For pure black, all RGB values
are 0.
If value of RGB are the same,
then it is a greyscale colour.
So in total, a computer can have
28 =256 grey colours
Transparency
Alpha channel
8 bits (0 to 255)
0 – total transparent
Cannot be seen at all
255 - opaque
noFill()
Sets the colour used to draw lines and borders around shapes.
https://p5js.org/reference/#/p5/stroke
noStroke()