Graphics (Meme project)

var my_graphic = graphic(source, x, y)

var my_graphic = graphic(“create”);

adds a graphic

my_graphic.source = “rainbow”;

modifies the image file of the graphic

my_graphic.x = 10;

moves the graphic horizontally (left and right)

my_graphic.y = 10;

moves the graphic vertically (up and down)

my_graphic.scale = 2;

modifies the size of the graphic

my_graphic.opacity = 0.5;

modifies the transparency of the graphic (0 is transparent, 1 is completely opaque)

my_graphic.rotation = 25;

rotates the graphic

 

Text (Meme and Newscast projects)

var my_text = text(message, x, y)

var my_text = text(‘I love coding!’, 60, 55);

creates text on your video.

the first number after your message is the position from the left of your text. The second number is the position from the top of your canvas.

var emoji = text(‘😈’)

Add emojis the same way you add text.

In your Chrome menu, click ‘Edit’ then ‘Emoji and Symbols.’ If you don’t have that, you can from iemoji or getemoji.

my_text.message = “I’m an AMAZING coder!”

modify the message that the text is displaying

my_text.x = 15

modifies the horizontal text position

my_text.y = 100

modifies the vertical text position

my_text.color = “green”;

modifies the color of your text

my_text.size = 50;

modifies the size of your text

my_text.font = “Times”;

modifies the font of your text.

possible fonts: “Arial”, “Comic Sans MS”, “cursive”, “serif”, “monospace”

my_text.rotation = 75;

rotates the text

 

Timing (Newscast project)

 

repeat(function(){

   //code that repeats 

}, 3);

repeats the code inside the function every number of milliseconds (500 in this example)

 

my_repeat.stop();

stops repeat from running

my_repeat.start();

starts repeat (if it was stopped)

my_repeat.interval = 200;

modifies how often the code inside repeat gets run in milliseconds

 

Conditional Statements (useful for Newscast project)

Remember that every open bracket { must have a matching closing bracket }

if (condition) {

   //code that will run if condition is true

}

if (condition) {

   //code that will run if the condition is true

} else {

   //code that will run if condition is not true

}

Filed as:  Coding
Comments