THE JAVASCRIPT ARTIST 15/10/2016

Similar documents
An Introduction to Processing

+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created.

CISC 1600 Lecture 3.1 Introduction to Processing

mith College Computer Science CSC103 How Computers Work Week 7 Fall 2017 Dominique Thiébaut

CISC 1600, Lab 2.1: Processing

University of Cincinnati. P5.JS: Getting Started. p5.js

We will start our journey into Processing with creating static images using commands available in Processing:

Bingo! (Photoshop Elements)

1. Complete these exercises to practice creating user functions in small sketches.

Street Artist Teacher support materials Hour of Code 2017

Step 1: Create A New Photoshop Document

ADOBE PHOTOSHOP Using Masks for Illustration Effects

REVIEW. while (condition) { <body> for (<init> ; <condition> ; <increment>) { } if (condition) { <command> } else { <command> }

[ the academy_of_code] Senior Beginners

CISC 1600, Lab 3.1: Processing

Using Masks for Illustration Effects

Today, I m going to show you how use custom shapes and Layer styles in Photoshop CS3 to create a creative Christmas illustration. Let s get started!

Interaction Design A.A. 2017/2018

Khan Academy JavaScript Study Guide

1 Getting started with Processing

The Processing language. Arduino and Processing.

Drawing a Circle. 78 Chapter 5. geometry.pyde. def setup(): size(600,600) def draw(): ellipse(200,100,20,20) Listing 5-1: Drawing a circle

Adobe photoshop Using Masks for Illustration Effects

Basic Computer Programming (Processing)

How to create shapes. Drawing basic shapes. Adobe Photoshop Elements 8 guide

Paint Tutorial (Project #14a)

Fireworks 3 Animation and Rollovers

1 Getting started with Processing

Class #1. introduction, functions, variables, conditionals

ANIMATION FOR EDUCATORS. Professional Development Salary Point Class Presented by Jonathan Mazur, NBCT

Page 1. Fireworks Exercise

If the ball goes off either the right or left edge, turn the ball around. If x is greater than width or if x is less than zero, reverse speed.

Practice Written Examination, Fall 2016 Roger B. Dannenberg, instructor

GRAPHICS & INTERACTIVE PROGRAMMING. Lecture 1 Introduction to Processing

Kimberly Nguyen Professor Oliehoek Introduction to Programming 8 September 2013

FLASH CS6 DIRECTIONS TO GET YOU STARTED!

HAPPY HOLIDAYS PHOTO BORDER

ITEC185. Introduction to Digital Media

On the Web sun.com/aboutsun/comm_invest STAROFFICE 8 DRAW

Intermediate Microsoft Office 2016: Word

6 Using Adobe illustrator: advanced

mith College Computer Science CSC103 How Computers Work Week 6 Fall 2017 Dominique Thiébaut

Smoother Graphics Taking Control of Painting the Screen

Captain America Shield

2. Click on the Freeform Pen Tool. It looks like the image to the right. If it s not showing, right click on that square and choose it from the list.

Creating Digital Illustrations for Your Research Workshop III Basic Illustration Demo

In this lesson, you ll learn how to:

Language Reference Manual

What can we do with Processing? Let s check. Natural Language and Dialogue Systems Lab Guest Image. Remember how colors work.

Revision of Level I. In this lesson you will: Revise the topics learnt in the previous level.

Data Representation From 0s and 1s to images CPSC 101

Acknowledgments. Who Should Read This Book?...xxiv How to Read This Book...xxiv What s in This Book?...xxv Have Fun!...xxvi

Tips and Ideas for Your IWB Software

Processing Assignment Write- Ups

The Fundamentals. Document Basics

8. How to use social networks (Skype, Facebook)

Learning to use the drawing tools

ICS 61 Game Systems and Design Introduction to Scratch

Graphing on Excel. Open Excel (2013). The first screen you will see looks like this (it varies slightly, depending on the version):

Description: Learn how to create a beautiful pumpkin using Bitmaps for Textures and the Gradient Fill Editor to colour the shapes.

Basic Scene Composition

disclabel help: what is disclabel?

TESSELLATIONS #1. All the shapes are regular (equal length sides). The side length of each shape is the same as any other shape.

Making a maze with Scratch

Click on Add a layer style icon from bottom part of the Layers panel and select Gradient Overlay.

Creating and Editing Images in Paint Shop Pro Version XI. File Types

A Step-by-step guide to creating a Professional PowerPoint Presentation

Lesson 3 Creating and Using Graphics

Layout of Movie Maker. Elements of Movie Maker. Step by step instructions on how to use Movie Maker. Web resources for Movie Maker

Session 7 MS Word. Graphics. Inserting Clipart, and Graphics Modify graphics Position graphics

Camden County HS Honors Math II Summer Tessellation Project 2018

Using Flash Animation Basics

Animating the Page IN THIS CHAPTER. Timelines and Frames

Christmas Card Final Image Preview Coach Christian s Example Ctrl+N 1920px 1200px RGB 72 pixels/inch Rectangle Tool (U)

Introduction to Programming with JES

Making ecards Can Be Fun!

Adobe Animate Basics

Adobe Illustrator. Quick Start Guide

CSC 110 Lab 12 Graphics and Objects. Names:

Tutorial Four-Point Tracking. Four-Point Tracking

Cruising Sacramento/ A PowerPoint Slide Show (Project #8)

Bits and Bytes. How do computers compute?

animation, and what interface elements the Flash editor contains to help you create and control your animation.

Work with Shapes. Concepts CHAPTER. Concepts, page 3-1 Procedures, page 3-5

HO-1: INTRODUCTION TO FIREWORKS

12 Steps for Creating Your Project Successfully

With the help of Adobe and a dash of creativity, we can create all kinds of fun things just using the shapes found in our tool box.

Create an Adorable Hedgehog with Basic Tools in Inkscape Aaron Nieze on Sep 23rd 2013 with 5 Comments

FRACTALS AND THE SIERPINSKI TRIANGLE

How to draw and create shapes

= 3 + (5*4) + (1/2)*(4/2)^2.

Going 3D with Blender: A room with toys

Interaction Design A.A. 2017/2018

Creative Effects with Illustrator

Recall that creating or declaring a variable can be done as follows:

SNOWFLAKES PHOTO BORDER - PHOTOSHOP CS6 / CC

DesignWorks- CrystalWork Skillbuilder

AppyBuilder Beginner Tutorials

ACS-1805 Introduction to Programming (with App Inventor)

Solution Notes. COMP 151: Terms Test

Transcription:

THE JAVASCRIPT ARTIST 15/10/2016

Objectives Learn how to program with JavaScript in a fun way! Understand the basic blocks of what makes a program. Make you confident to explore more complex features of JavaScript. Unleash your creativity. Review a bit of Maths! To encourage you to present your work.

What is Javascript? Set of commands which our internet browsers understand. Like any other language (e.g. French, English, Dutch) we need to respect a specific syntax / format when writing the programs. Without JavaScript, the web pages would not be cool! Facebook, Gmail, Twitter all use JavaScript to make their website more user-friendly.

What can we do with Javascript? Play music Interaction on a web page (E.g. zoom on a photo, drag drop an email in the bin etc.) Drawing on a web page Game development And a lot more! See by yourself: http://lights.helloenjoy.com/ http://www.patatap.com/ https://www.cubeslam.com/ For today..

How do we code? We will use a nice online editor to write our program. Log to https://www.khanacademy.org/computer-programming/new/pjs Sign in using your Gmail or Facebook account, so that you can save your work.

The Editor Editor for our Canvas program

The Canvas Our painting area 400 x 400 Follows (x, y) coordinates system X from left to right Y from top to bottom As an exercise, can you locate: (300, 100) (50, 400) (0,0) (400,400) (399, 17)

Our first program line(50, 50, 350, 350); Ends with semicolon function Parameters What do you see on the Canvas? Change the value of the parameters 50, 350 etc. Can you draw a square? line(100, 100, 300, 100); line(300, 100, 300, 300); line(100, 100, 100, 300); line(100, 300, 300, 300);

A small exercise Can you draw the small boat with what we have learned so far? Do not forget to save your work!

Circles ellipse(120, 150, 100, 150); This command draws an ellipse on the canvas. By changing the parameters, can you draw a circle? When clicking on one of the parameter, you can see a pointer appearing. When you slide this pointer, the values of the parameters will be changed. That will be easier for you to visualize your changes on the canvas.

Rectangles rect(100, 100, 50, 50); X Y Width Height

Triangle Has 3 points triangle(100, 100, 300, 100, 200, 300); X 1 Y 1 X 2 Y 2 X 3 Y 3

Colors So far, our drawings were of black lines! In JS, you can mix RED, GREEN and BLUE to make any colors. Shortname = RGB. Amount of Red, Blue and Green varies from 0 to 255. Drawing a red rectangle stroke(255, 0, 0); rect(10, 10, 100, 100); Chose the color picker to chose your color. Notice how the parameters change. R = 255, G = 0, B = 0

Colors (ctd..) If you draw several shapes that overlap, you will not completely see the shapes behind. This is because these shapes are filled with the white color. To make them transparent, before drawing a shape, use nofill(); To fill them with a particular color, before drawing a shape, use fill(r, g, b); r, g, b will of course be between 0 and 255.

A small exercise Try to make this snowman in the sun. Make use of what you have learned before. Enleash your creativity!

Random & Variables To generate a random number use the command: var x = random(0, 400); variable low hig h A variable is a place in memory where you can store a value and use it later. It can even be modified. Here, the name of the variable is x, which will store a random value from 0 to 400. Variable x can take values like 0, 1, 1.5, 114.56, 200.99, 400, 399.99 etc.. Use different names for different variables: y, z, myvariables, toto,.. Should always start with a letter of the alphabet. Can you generate a rectangle of a random color?

Decision if.. Else if The «if» block allows the program to take decision. It is pretty much the same reasoning when a person decides what to wear on a rainy or sunny day. This program generates a random number between 0 and 100 and then outputs a text specifying where the number lies. var x = random(0, 100); fill(255, 0, 0); text(x, 5, 10); if (x < 10) { } text(" is less than 10!", 50, 10); else if (x >= 10 && x <= 50) { } text(" is between 10 and 50!", 50, 10); else { } text(" is greater than 50!", 50, 10);

Loops Loops are used to repeat a piece of code several times. Generate 10 circles. nofill(); var i = 1; while (i <= 10) { } ellipse(200, 200, i*20, i*20); i = i + 1; Initially, set value of i = 1 While the value of i less or equal to 10: Increment its value by 1. Draw a circle

A small exercise Gerate 10 shapes on the canvas and fill them with random colors. Place them randomly on the canvas.

Images We can also insert an image on the Canvas. We have a library of cool images at our disposal. This command is used to insert an image on the canvas. var mrpink = getimage("avatars/mr-pink"); image(mrpink, 10, 10);

Simple Animations Special function «draw» draw = function() {.. }; This function is called about 30 times per second. We can exploit this special function to make animations. It is as if the entire canvas is cleaned and the shapes are redrawn on it.

Animation using the draw function var x = 0; var dx = 10; draw = function() { background(255, 255, 255); // we always paint the background in white fill(255, 0, 0); ellipse(x, 200, 10, 10); x = x + dx; if (x >= 400) { dx = -10; } else if (x < 0) { dx = 10; This piece of code draws a moving ball on the canvas. 1) Try to add 2 or 3 more balls moving at the same time but different speeds. 2) Add a paddle somewhere on the canvas and make the ball bounce when it hits the paddle. } };

CHALLENGES

Challenge #1 On the left is a picture of a plate on a wooden table. What s on your plate for dinner? Use the shapes you have learned to decorate your plate. Here is the program to start with: background(186, 145, 20); // wooden table ellipse(200, 200, 350, 350); // plate ellipse(200, 200, 300, 300);

Some inspirations for challenge #1

Challenge #2 Generate an 8 x 8 checkerboard Tips: 1) Use a while loop inside another while loop 2) Make your program in 2 parts. First part displays black squares on row 1, 3, 5, 7. Then, display the black squares on row 2, 4, 6, 8

Challenge #2 solution var x, y; y = 0; while (y < 400) { x = 0; while (x < 400) { fill(0, 0, 0); rect(x, y, 50, 50); x = x + 100; } y = y + 100; } y = 50; while (y < 400) { x = 50; while (x < 400) { fill(0, 0, 0); rect(x, y, 50, 50); x = x + 100; } y = y + 100; }

Challenge #3 If you cannot picture how this drawing is made, try out on paper first to get an idea. Then write a program to do the same actions that you have made on paper.

Challenge #3 solution var x = 0; while (x < 400) { line(0, 400-x, x, 0); line(x, 400, 400, 400-x); line(x, 0, 400, x); line(0, x, x, 400); } x = x + 10;

Challenge #4 Use the animation techniques that you have learnt to make a lively aquarium full of fishes! Use pictures, shapes, colors to build your aquarium. Be creative!

BRAVO! YOU ARE NOW A JAVASCRIPT NINJA!