Learning to code beyond block style coding.

Slides:



Advertisements
Similar presentations
Summer Computing Workshop. Introduction to Variables Variables are used in every aspect of programming. They are used to store data the programmer needs.
Advertisements

Variables and Operators
 Variables  What are they?  Declaring and initializing variables  Common uses for variables  Variables you get “for free” in Processing ▪ Aka: Built-in.
Chapter 2: Using Objects Part 1. To learn about variables To understand the concepts of classes and objects To be able to call methods To learn about.
CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
Week 9: Methods 1.  We have written lots of code so far  It has all been inside of the main() method  What about a big program?  The main() method.
10-Jun-15 Introduction to Primitives. 2 Overview Today we will discuss: The eight primitive types, especially int and double Declaring the types of variables.
Introduction to Primitives. Overview Today we will discuss: –The eight primitive types, especially int and double –Declaring the types of variables –Operations.
Introduction to a Programming Environment
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
Computer Science 101 Introduction to Programming.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Programing Concept Ken Youssefi/Ping HsuIntroduction to Engineering – E10 1 ENGR 10 Introduction to Engineering (Part A)
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 2 Graphics Programming with C++ and the Dark GDK Library Starting.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
1 Printing in Python Every program needs to do some output This is usually to the screen (shell window) Later we’ll see graphics windows and external files.
Chapter 3 AS3 Programming. Introduction Algorithms + data structure =programs Why this formula relevant to application programs created in flash? The.
Variables Variables:-
Quiz 1 A sample quiz 1 is linked to the grading page on the course web site. Everything up to and including this Friday’s lecture except that conditionals.
Chapter # 2 Part 2 Programs And data
Week 2 - Wednesday CS 121.
Course Contents KIIT UNIVERSITY Sr # Major and Detailed Coverage Area
Chapter 10 Programming Fundamentals with JavaScript
ECE 1304 Introduction to Electrical and Computer Engineering
Chapter Topics The Basics of a C++ Program Data Types
Prof: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2017
Concepts of Object Oriented Programming
UNIT 2 – LESSON 3 Encoding B&W Images.
Chapter 3 Syntax, Errors, and Debugging
Principles of Architecture & Construction
Computing and Statistical Data Analysis Lecture 2
FOP: Buttons and Events
Chapter 2 - Introduction to C Programming
Introduction to Computer Science / Procedural – 67130
Basic Elements of C++.
Lesson Two: Everything You Need to Know
Chapter 2 - Introduction to C Programming
Basic Elements of C++ Chapter 2.
Tkinter GUIs Computer Science and Software Engineering
Lecturer: Mukhtar Mohamed Ali “Hakaale”
Introduction to the C Language
Chapter 10 Programming Fundamentals with JavaScript
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
2.1 Parts of a C++ Program.
Introduction to C++ Programming
Chapter 2 Edited by JJ Shepherd
Variables ICS2O.
Language Basics.
Programming for Artists
Chapter 2 Graphics Programming with C++ and the Dark GDK Library
Java Programming Function Introduction
Compound Statements A Quick Overview
Fundamentals of Data Representation
Game Loop Update & Draw.
Lecture 7: Introduction to Processing
Chapter # 2 Part 2 Programs And data
Chapter 2: Introduction to C++.
Overloading functions
Introduction to Primitives
Introduction to Primitives
Variables and Operators
Java Programming Function Introduction
Chapter 1 Introducing Small Basic
Chapter 9 Using Decisions to
Variables in C Topics Naming Variables Declaring Variables
Software Development Techniques
Animation Translation.
Presentation transcript:

Learning to code beyond block style coding. Processing Learning to code beyond block style coding. The Next Step.

What is Processing? Processing is an open source programming language and integrated development environment (IDE) built for the electronic arts, new media art, and visual design communities with the purpose of teaching the fundamentals of computer programming in a visual context, and to serve as the foundation for electronic sketchbooks. Processing is aimed at artists, musicians, hobbyist and high school students rather than programmers. Java (a commonly used programming language) is a fairly complicated language involving OOP (object-oriented programming) concepts. Processing is a great starting point and/or gives the ability to program without the complexity and large span of Java.

Processing is for writing software to make images, animations, and interactions. Processing is a flexible software sketchbook and a language for leaning how to code with in the context of the visual arts. The idea is to write a line of code and then watch an image show up on the screen. Then you can add a few more lines of code, and you have an animation. This is sometimes called sketching with code. Processing offers a way to learn programming though creating interactive graphics.

Sketching and Prototyping. Sketching is a way of thinking on paper. This is usually done before you start to write your code. It is a good idea to know what you want you code to look like, in order to identify all of the pieces needed in the code. Ideas for animations are usually sketched out as a story board with notations. Next is a cyclical process of drawing, coding, testing, and improving. When creating a sketch with processing, you will need to sketch out your ideas by hand first. This will help you visualize what you want to happen on the screen after entering code.

Rules of Processing. For beginners it should be easy to create a basic image. Especially after working through this tutorial. More advanced users can advance their animation skills or even build creatures which interact with other creatures. I will only expect you to create sketches that range in you own ability. (with growth and advancement of course.) A few rules come with a more advanced creation: Each creation starts with a setUp() method. Variables are declared by type. Each creature must implement the move() and draw() methods. Animations can be timed with frames or actual time. Have fun, break the rules, and build something new and amazing.

Processing- Variables Computer Science

Variables The concept of a variable is a powerful programming idea. It’s called a variable because – now pay attention – it varies. A variable is a symbolic name for information. The variable's name represents what information the variable contains. They are called variables because they represent information that can change, but the operations on the variable remain the same. The variable stores a value in memory, so that it can be used more than one time and/or later in a program. The reason that we use variables is to avoid repeating the same thing in code over and over.

Variables include: a Type a Name a Value a Scope a Life time a Location(in Memory)

Variable – A type The type represents what "kind" of data is stored with the variable. In C, Java, ActionScript, Processing, etc., the type of a variable must be explicitly declared when the name is created. Some common types of variables include: int; (integer value)32,767 max double; (integer or decimal value)10^308 max short; (small numbers between minus 32,768 and plus 32,767.)

Variable - A Name: The name is Symbolic . It represents the "title" of the information that is being stored with the variable. The name is perhaps the most important property to the programmer, because this is how we "access" the variable. Every variable must have a unique name! Legal Variable Names: Start with a letter Use _ (underscore) for clarity Can use numbers Don't use special symbols Don't have spaces Have meaningful Names Good variable names tell you, your teammates, and your teacher or boss what information is "stored" inside that variable. They should make sense to a non computer programmer. For example: int g=-9.81; this is a bad name. What does g stand for? int gravity=-9.81; this is a good name. We know exactly what the variable represents.

Variable – A Value A variable, by its very name, changes over time. Thus, if the variable is jims_age and is assigned the value 21. At another point, jims_age may be assigned the value 27. Variables start with a Type (declaration) such as int or double, have a variable name, then are set equal to its initial value, and end with a semicolon. For example: int age = 18; Default Values Most of the time, when you "create a variable" you are primarily defining the variables name and type. Often (and the best programming practice) you will want to provide an initial value to be associated with that variable name. If you forget to assign an initial value, then various rules "kick in" depending on the language and type.

Variable- A Scope Good programs are "chopped" into small self contained sections (called functions) much like a good novel is broken into chapters, and a good chapter is broken into paragraphs, etc. A variable that is seen and used in one function is NOT available in another section. Because of this, the same variable name can be used in another function and take on the same name without changing the other functions variables. If you want to use one variable in more than one function you can declare/initialize the variable at the top, outside of the functions.

Variable- A Life Time: The life time of a variable is strongly related to the scope of the variable. When a program begins, variables "come to life" when the program reaches the line of code where they are "declared". Variables "die" when the program leaves the "Scope" of the variable.

Variable – A Location (in Memory) Luckily, we don't have to worry too much about where in the computer hardware the variable is stored. The computer does this for you.

Vocabulary: "Access" a variable. "Assign" a value to a variable. To access a variable is to "read" (or assign) the information inside the variable. To access a variable, you simply type its name. For example: total_age = jims_age + jens_age; "Assign" a value to a variable. When you assign a value to a variable, you replace the old value with the new one. The old value is gone forever. You can, and often do, replace the old value of a variable based on the current value of the variable. For example: int age = 10; age = 12; The variable age started with a value of 10 and then was changed/"Assigned" to a value of 12.

More Vocabulary "Declare"a variable. "Initialize" a variable. To declare a variable is to create the variable. "Initialize" a variable. Initilizing a variable is another way to say, "declare a variable", but further, implies giving it a base value. For example, if you are plotting something on the X/Y axes, and we want to start at zero for X, we would say("x=0;"). Thus we have "initialized" the x variable to the value of 0. "Stored" in a variable. The information "stored" in a variable, is the last piece of information assigned to the variable name. After assigning into a variable, all previous information is lost. Note, we often use the statement "store the value 5 in X" to mean the same as "assign the value 5 to X".

Drawing with Processing Coordinate System and Drawing Shapes Drawing on a computer is like drawing on graph paper. With minor changes. Take out a piece of graph paper and draw two points. Connect those two points with a line.

Lines The shortest distance between the two points will be a straight line, and this is where we begin, with two points on that graph paper. Let's say these two points are located at A(1,0) and B(4,5). If you wanted to direct a friend of yours to draw that same line, you would have to say, "draw a line from the point one-zero to the point four-five." Well, for the moment, imagine your friend is a computer and you wanted to instruct this digital pal to display that same line on its screen. The same command applies (only this time you can skip the pleasantries and extra verbiage.) Here, the instruction will look like this: line(1,0,4,5);

line(1,0,4,5); Even without having studied the syntax of writing code, the above statement should make a fair amount of sense. We are providing a command (which we will refer to as a "function") for the machine to follow entitled "line". A computer screen is a grid of light elements called pixels. Each pixel has a position defined by its coordinates. In processing the x and y coordinates are similar to a coordinate plane. The x-coordinate represents horizontal distance and the y-coordinate represents the vertical distance.

However, the x-coordinate represents the distance from the left edge of the display window and the y-coordinate is the distance from the top edge. Each being positive numbers. The top left corner represents the location (0,0). The coordinate of pixels are written (x,y). https://processing.org/tutorials/drawing/

Simple Shapes lines(x1, y1, x2, y2); triangles(x1, y1, x2 , y2, x3, y3); quad(x1, y1, x2, y2, x3, y3, x4, y4); rect(x, y, width, height); ellipse(x, y, width, height); arc(x, y, width, height, start, stop); start represents the starting angle and stop represents where the angle stops.

Can you create this image? Now let's look at what some code with shapes in more realistic setting, with window dimensions of 200 by 200. Note the use of the size() function to specify the width and height of the window.  void setup( ) { size (200, 200); // set size of frame background( ? ); //set background color } void draw( ) { // draw the image …… (shape code goes here)