Tutorial - How to create masks

e.g., mouse, keyboard
e.g., visualization, fractal, mouse
Learn more about Creative Commons
Join Plus+ to change privacy settings
  • This tutorial is a part of the creative coding class for COD 208 course at Ozyegin University.


    Let's start by creating variables for facial features

    • Line 0-30
    • Line 34: colors array for the mask
    • Head background -> line 43-53
  • Create eyes using symmetry;

    • Left eye -> line 57-63
    • For the right eye we can keep the y position.
    • For the symmetry of the eye, we need to make some calculation as follows;


    to create the symmetric position of the right eye;

    we must start from the x position of head (xh) + width of the head (headW) - distance to head side (35)



  • To draw the nose;

    • Calculate the center point of the head -> line 72-80
    • Between beginShape() - endShape() lines, we add points to draw a triangle
    • Right now the nose appears on the top-left corner of the canvas.
    • We can move it using translate()
  • We use translate() function with push() and pop() methods.

  • Draw mouth;

    • To craw mouth we can use variety of techniques.
    • Let's use beginShape() and endShape() to create the mouth
    • First create the points to form the mouth
    • You can use small circle in order to determine the specific curve positions via trial-error practice...
    • line 94-103
    • Attention to the x and y position of each points.
    • I want to create a curve that looks like a wave.
    • Next we will disable the lines between 98-103. Because we know the parameters to draw curve for the mouth
    • Comment out the lines 98-103
    • set color and disable fill -> line 105
    • add beginShape() to start drawing points into custom shape -> line 106
    • to draw curves with shapes, we need to use curveVertex() function. There is just a point you need to be careful about it. The first and the last points must be duplicated in order to make curcVErtex work properly. Do not ask why? Just take it as a rule. If you are curious we can discuss the issue in class time. (ref. reference | curveVertex() (p5js.org))
    • Let's make the code looks cleaner
    • To do that cut the line-> 46-52 into custom function. Mine is called drawHead()
    • It will be outside of the draw() function
    • check lines - 45
    • There is function that is cited in the previous page.
    • Goto line 113
    • All the codes that draw the head are inside the drawHead() function now.
    • Let's create custom function for each face element
  • Now we can work on the style and get benefit from randomness to create variations of the existing attributes.


    Try to determine min-max values that can change....


    Let's move the mask into the center of the canvas.

    To do that we can use push, translate, and pop methods again to move all parts of the mash without editing individual x and y positions of each variable.

  • line 44- push()

    line 45- translate to the middle of the screen

    line57- pop()


    • Since the pivot point is on the top left, the shape group doesn't seem to be in the middle.
    • By subtracting the half of the with and height from half of the canvas width and height, we can perfectly position the mask into the middle of the screen.

  • Let's apply some randomness

1/12
  • mySketch
  • v1.11.3
  • v1.11.2
  • v1.11.1
  • v1.11.0
  • v1.10.0
  • v1.9.4
  • v1.9.3
  • v1.9.2
  • v1.9.1
  • v1.9.0
  • v1.8.0
  • v1.7.0
  • v1.6.0
  • v1.5.0
  • v1.4.2
  • v1.4.1
  • v1.4.0
  • v1.3.1
  • v1.3.0
  • v1.2.0
  • v1.1.9
  • v1.1.7
  • v1.1.5
  • v1.1.4
  • v1.1.3
  • v1.0.0
  • v0.10.2
  • v0.9.0
  • v0.8.0
  • v0.7.3
  • v0.7.2
  • v0.6.1
  • v0.6.0
  • v0.5.16
  • v0.5.11
  • v0.5.8
  • v0.5.7
  • v0.5.2
Select mode or a template
Centers sketch and matches the background color.
Prevents infinite loops that may freeze the sketch.
This will be the default layout for your sketches
Easy on the eyes
It will show up when there is an error or print() in code
Potential warnings will be displayed as you type
Closes parenthesis-like characters automatically as you type

Controls
Play
Ctrl+Enter
Code
Ctrl+Shift+Enter
Save
Ctrl+S
Interface
Fullscreen
Ctrl+Alt+F
Switch Layout
Ctrl+Alt+L
Settings
Ctrl+Alt+.
Editor
Tidy Code
Ctrl+B
Multiple Cursors
Ctrl+Click
Duplicate Line/Selection
Ctrl+Shift+D
Move Line
Alt+↑/↓
Select Multiple
Ctrl+D
Find in Code
Ctrl+F
Find Next
Ctrl+G
Find Previous
Ctrl+Shift+G

See More Shortcuts

Join Plus+ for private sketches, version history, 1GB space, custom embeds, and more!