Section 1

Preview this deck

function

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (78)

Section 1

(50 cards)

function

Front

-Anything with these opening and closing parenthesis () -it does something. -ex: rect

Back

If you enter four color values...?

Front

the last one is the transparency, or alpha

Back

What are relational operators?

Front

-Equal to == -Not Equal to != -Greater than > -Less than < -Greater than or equal to >= -Less than or equal to <= -comparing two numbers

Back

background()

Front

controls the background color of the canvas, and take a color as a parameter

Back

var uses function scope:

Front

the variable will work anywhere in the function, even before it is declared. This is because a process called hoisting. JavaScript will hoist the variable to the scope of entire function in which it is found.

Back

ellipse()

Front

(0,0,0,0)

Back

0

Front

black

Back

Loops

Front

-Loops are a control structure: like conditional statements, loops control how many time a certain block of code runs -And they can save you lots of time!

Back

(parameter)

Front

one value

Back

when we create a variable, our computer creates a space for that called...?

Front

an address.

Back

how to get a variable in steps

Front

1. declare 2. initialize 3. use

Back

and

Front

both statements have to evaluate to true

Back

Where is the X and Y axis?

Front

X on top y goes down

Back

How many arguments does map() have?

Front

5 ( value comparing range to new range (ex: mouseX), min range, max range, min new range, max new range)

Back

mouseIsPressed

Front

-boolean, which means true or false -is the mouse being pressed or not -mouse if being held down

Back

else

Front

do something else if the if is not true

Back

Declaring variables: initializing variables: Or do both at once:

Front

Declaring variables: var myScore; initializing variables: myScore = 1; Or do both at once: var myScore = 1;

Back

const is similar to let, but should be used as a constant

Front

-a variable where the value doesn't change. It is an option to use, for the sake of efficiency, when a variable doesn't change. If the value of a variable won't change, the computer doesn't need to reserve extra memory for the possibility that it might change

Back

rect()

Front

You will also notice that lines of code end in a semicolon.

Back

how many else if can you have?

Front

infinate

Back

function mousePressed()

Front

-event

Back

What are the 10 numbers we use in p5?

Front

0-9

Back

Code Block:

Front

code that is contained within an opening and closing curly brace: { ... }

Back

frameRate();

Front

The numbers of frames per second, or FPS, can affect how smooth the motion looks.

Back

What are the two kinds of loops?

Front

while loops and for loops

Back

how many else and if can you have?

Front

just one of each

Back

console.log("x: " + mouseX + " / y: " + mouseY)

Front

Back

random()

Front

arguments: min and max -ex: random(min,max) random(0,width)

Back

setup()

Front

-controls the overall setup of our sketch: things like the size of the canvas, frameRate, colorMode, renderer, etc. -It's like when you open Photoshop and create a new canvas. You choose the size, resolution, colormode, stuff that pertains to the overall canvas. -What this is actually doing for us is creating an HTML element, a canvas element, on our webpage

Back

If you enter three color values...

Front

it will interpret it as rgb

Back

So why wouldn't you make all your variables Global?

Front

It can conflict with other variables as your programs become more complex and interface with other programs. E.g. a variable named user is very common, and might conflict with other similarly named variables.

Back

You can also create your own variables, but there are rules to naming them. What are they?

Front

-The first character must be a letter or an underscore _. -You can't use a number as the first character. -The rest of the variable name can include any letter, any number, or the underscore. -You can't use any other characters, including spaces, symbols, and punctuation marks. -As with the rest of JavaScript, variable names are case sensitive. That is, a variable named Interest_Rate is treated as an entirely different variable than one named interest_rate. -There's no limit to the length of the variable name.

Back

Scope

Front

where you declare a variable will affect where it can be used

Back

arguments

Front

( x, y, width, height)

Back

what is a variable?

Front

-something that replaces a number -ex: (mouse x, 50, 50, 50) -We are telling the computer create a little space in memory, and give it a name, because we want to store something there. -JavaScript isn't very efficient. It is a high-language with lots of abstraction (which makes it easier for us to learn). -One of the reasons it isn't efficient is because JavaScript is an untyped language -when we use the keyword var to setup a variable, the program creates a space in the browser's memory to store that variable.

Back

function mousePressed

Front

-only when mouse is being clicked

Back

// / /

Front

comments : single line and multiline

Back

And if you ever don't want a stroke or fill:

Front

noStroke() noFill()

Back

Don't confuse a = with ==! One equal sign is an _______? two is ______________?

Front

One equal sign is an assignment operation, two is to test for equality

Back

or

Front

only one statement has to evaluate to true

Back

boolean means

Front

-true or false -1 or 0 (1 being true, 0 being false)

Back

Loops will always have three parts:

Front

-Declare and initialize a local variable to control the loop -Perform a boolean test to determine whether or not to run the loop -Increment the variable

Back

What are the three logical operators?

Front

AND && OR || NOT !=

Back

draw()

Front

is where we actually draw things to the canvas element.

Back

map()

Front

So I want to create a sketch that will take the location of the mouseX and mouseY, and remaps those values from the Canvas dimensions to the color spectrum 0-255, so the mouseX will control the G values, and the mouseY will control the R values.

Back

Binary:

Front

two states / true or false, on or off, 1 or 0

Back

point()

Front

-Anything with these opening and closing parenthesis is called a function: it does something. -We put values, or arguments, inside the parentheses to control how the function behaves. -coordinates, 0,0 is upper left hand corner, "Y" axis is flipped.

Back

Nested for loops

Front

-Nested for loops are pretty cool and extremely useful, especially when you are drawing things in a grid -You have one for loop nested inside another for loop -The first loop controls the x dimension, or all the columns, and the second loop controls the y dimension, or all the rows

Back

let uses block scope:

Front

-the variable will only work in its code block, no hoisting -Hoisting makes code prone to error as it can conflict with other variables.

Back

255

Front

white

Back

Section 2

(28 cards)

rectMode(CENTER) ?

Front

puts rectangle in center

Back

Use for loop to access values:

Front

for(i=0; i < myArray.length; i++){ console.log(myArray[i]) };

Back

To create an instance of an object from our class, we call the class a...?

Front

constructor function var myHouse; myHouse = new House(); // House() is the constructor function Classes typically start with a capital letter to distinguish them from other functions.

Back

Arrays

Front

-are an example of a data structure: a structure, or way of organizing data within computer programming. - It is a list of things: numbers, words, whatever.

Back

constructor

Front

how that object is initialized

Back

translate()

Front

-moves the point of origin -Think of it like picking up your pen; it is where you start drawing

Back

An associative array associates pairs of

Front

keys and values. var happyThings = { kittens:'10', rainbows:'29', unicorns:'34' };

Back

push and pop related to stacks:

Front

last one in, first one out (think stack of paper)

Back

How do we find out the length of the array?

Front

myArray.length

Back

or set of instructions that define our house

Front

a class

Back

What is the syntax for creating an Array?

Front

var myArray = [];

Back

pop()

Front

remove element from the end of the array

Back

First in, first out (like in a line at the movie theater)

Front

queue:

Back

new (class)

Front

creates a new instance of the object from the class by calling the constructor function

Back

How do we dynamically add an element to an array?

Front

-nameOfArray.push(thingToAdd); -And the thingToAdd could be a value, a variable, an object, even another array!

Back

not operator

Front

!

Back

We starting counting the positions in an array at what?

Front

0 Access values: myArray = [0];

Back

push()

Front

add element to end of array

Back

There is also splice()

Front

which comes with a bit more control than push() or pop() splice(index, how many);

Back

The big idea is we have this set of instructions for building a house which defines all its properties

Front

variables house.color = blue;

Back

We call the thing we make from the class (like the specific house)

Front

an object

Back

transformation matrix:

Front

A list of numbers that stores all the transformations, rotations, and scalings that we have done.

Back

this (object)

Front

references the current object, binds/ties the property to the current instance of the object

Back

DOES WHILE LOOP OVER AND OVER AGAIN

Front

YES

Back

We make instances of objects from a...?

Front

class

Back

two dimensional arrays

Front

hink an array that holds other arrays: let animalCounts = [["cat", 10],["dog", 21],["fish", 13]]; We can access specific values using the following syntax: console.log(animalCounts[1][1]); // logs 21

Back

preload()

Front

If you have a media asset (especially large ones) you want to wait until it is loaded to run your code or you will get errors:: preload() (happens before setup):

Back

and all the things that the house can do

Front

functions house.openGarageDoor()

Back