Let's Animate!!! Bringing Mini Me's to Life
This workshop is designed for youth to be introduced to coding fun visuals. This is the first of a series of workshops. People of all ages/knowledge levels are welcome to participate.
What will we be doing??
We are going to learn how to code some simple animations. We will go over:
Refresher: what is coding? what is syntax?
What is a variable?
Random AKA chaos!
Animating our portraits
Trouble Shooting
Useful Links and how to use them
Have fun!!!
Refresher
Coding: Writing a set of instructions for the computer to follow.
P5.JS: Part of the coding language Javascript. It's designed for visuals, animations and interactive pieces.
Syntax: The "rules" of a coding language - the order and certain punctuation (e.g curly brackets {}) See the example of the syntax of a circle below.
Cool, we have a circle. Let's make it more fun! Let's move it. To move it we are going to have to use a variable.
What is a variable?
A variable is a label for something. Computers aren't mind readers so we have to both tell them what something is called and what it is.
Variables are super useful so we will keep coming back to them.
There are some variables that have already been named and defined by P5.JS. A handy one is called frameCount
frameCount
is the amount of frames a sketch has been opened for. This means it's an increasing number.
Let's see frameCount in action!
frameCount
Wow! Pretty cool right?
frameCount
can be used in any parameter. Let's experiment.
For the next five minutes try one or more of the following:
Use
frameCount
for the x parameter of a circleUse
frameCount
for the y parameter of a circleUse
frameCount
insidefill()
Use
frameCount
insidebackground()
In the future, we will learn how to create and define our own variables. For now, we are just going to have fun with pre-made ones :)
Randomness AKA Chaos!!
//////FLASH WARNING///////
frameCount
is just one way we can animate our code. Another way is to use randomness.
ANSWER
We can use random()
to generate random numbers.
Things can get CRAZY pretty fast using random. This can be fun but sometimes you might want something less overwhelming. Here are some tips for that.
Reduce the
frameRate
: this is a very fast and easy way to soften the randomness. Lower theframeRate
infunction setup()
. Simply writeframeRate
(and put a smallish number in here). Lowering theframeRate
is a little controversial because it changes the speed of everything in your sketch.Use random in
function setup
. If you like the cool computer-generated quality of randomness but don’t want the flashing quality: userandom
infunction setup
. Why? Becausefunction setup
only runs once, instead of in the draw function which runs 60 times a second.Use
randomGaussain()
. RandomGaussain is like random but with more control! You have the mean (the average amount you want) and the standard deviation (the amount of variation you want, low means not much, high means lots)
Animating our Portraits!
Last time we were here we made some drawings, we are going to use them as our base to animate. Don't worry if you weren't here or don't have the code you made we will have a template that you can use and change.
Here's an example of one I made earlier.
But you don't have to make it crazy like that. You can just make the eyes move like this.