To specify the dimensions of the drawing canvas use the size statement: ! size( 300, 400 );

Similar documents
CISC 1600, Lab 3.1: Processing

CISC 1600, Lab 2.1: Processing

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

Paint Tutorial (Project #14a)

CISC 1600 Lecture 3.1 Introduction to Processing

Solution Notes. COMP 151: Terms Test

Old 257 Exam #2s for Practice

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

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

Ai Adobe. Illustrator. Creative Cloud Beginner

An Introduction to Processing

1 Getting started with Processing

Kimberly Nguyen Professor Oliehoek Introduction to Programming 8 September 2013

CSE120 Wi18 Final Review

EXAMINATIONS 2016 TRIMESTER 2

Transform 1: Translate, Matrices

Creating a Text Frame. Create a Table and Type Text. Pointer Tool Text Tool Table Tool Word Art Tool

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

Real Time Data Plotting

CS 101 Media (Images, Video, etc) Lecture 20

CHAPTER 6 THE SUITES VECTOR DRAWING SUITE

CS116X Midterm Review Winter 2015

EXAMINATIONS 2017 TRIMESTER 2

Paint/Draw Tools. Foreground color. Free-form select. Select. Eraser/Color Eraser. Fill Color. Color Picker. Magnify. Pencil. Brush.

Corel Grafigo User Guide The contents of this user guide and the associated Corel Grafigo software are the property of Corel Corporation and its

Pen Tool, Fill Layers, Color Range, Levels Adjustments, Magic Wand tool, and shadowing techniques

Name. Criteria for grading. Total Points Earned. What to do to Create your own Tessellation

1 Getting started with Processing

Processing & Arduino in Tandem. Creating Your Own Digital Art Tools

ABB PowerPoint template User s Guide

Adobe Illustrator. Always NAME your project file. It should be specific to you and the project you are working on.

CISC 1600, Lab 2.3: Processing animation, objects, and arrays

PyGame Unit ?

ESCHERLIKE developed by Géraud Bousquet. User s manual C03-04 STROKE WIDTH C03-05 TRANSPARENCY C04-01 SAVE YOUR WORK C04-02 OPEN A FILE

Exam: Applet, Graphics, Events: Mouse, Key, and Focus

CS 201 Advanced Object-Oriented Programming Lab 10 - Recursion Due: April 21/22, 11:30 PM

Page 1. Fireworks Exercise

Programme. Introduction to Animation Shop

Introduction to Processing

Topics for section today. Homework 10 functions for loops and loading fonts

How to...create a Video VBOX Gauge in Inkscape. So you want to create your own gauge? How about a transparent background for those text elements?

TESSELLATION PROJECT DIRECTIONS

Part 7 More fill styles and an effect

2. If a window pops up that asks if you want to customize your color settings, click No.

How to draw and create shapes

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

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

InDesign Tools Overview

Class #1. introduction, functions, variables, conditionals

Programming Project 1

CSC 120 Introduction to Creative Graphical Coding, Fall 2017

OnPoint s Guide to MimioStudio 9

Photocopiable/digital resources may only be copied by the purchasing institution on a single site and for their own use ZigZag Education, 2013

PYTHON NOTES (drawing.py and drawstuff.py)

Using Methods. Methods that handle events. Mairead Meagher Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics

Adobe Illustrator. Quick Start Guide

IGCSE ICT Section 16 Presentation Authoring

The figures below are all prisms. The bases of these prisms are shaded, and the height (altitude) of each prism marked by a dashed line:

IMAGE VIEWER. Following is the explanation of different settings and features: Page. First Page

Introduction to Flash - Creating a Motion Tween

GIMP WEB 2.0 ICONS. GIMP is all about IT (Images and Text) OPEN GIMP

Learning to use the drawing tools

Name CMPS 5J Final March 17, 2010 This is a closed notes, closed book exam. Each problem is worth 1 point unless indicated otherwise.

SHAPES & TRANSFORMS. Chapter 12 of Pro WPF : By Matthew MacDonald Assist Lect. Wadhah R. Baiee. College of IT Univ.

INKSCAPE BASICS. 125 S. Prospect Avenue, Elmhurst, IL (630) elmhurstpubliclibrary.org. Create, Make, and Build

Adobe Flash CS3 Reference Flash CS3 Application Window

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

Creating T-Spline Forms

In this exercise you will be creating the graphics for the index page of a Website for children about reptiles.

MS Publisher County of Henrico Public Libraries

This document should only be used with the Apple Macintosh version of Splosh.

Corel Draw 11. What is Vector Graphics?

Class Notes CN19 Class PImage Page

The Processing language. Arduino and Processing.

Variables One More (but not the last) Time with feeling

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

Introduction To Inkscape Creating Custom Graphics For Websites, Displays & Lessons

lundi 7 janvier 2002 Blender: tutorial: Building a Castle Page: 1

CS 101 Computer Science I Fall Instructor Muller. stddraw API. (DRAFT of 1/15/2013)

TWO-DIMENSIONAL FIGURES

Programming Fundamentals

Transforming Objects in Inkscape Transform Menu. Move

Conditional Events. Mouse events and Operators. Dr. Siobhán Drohan Mairead Meagher. Produced by:

Day 1: Introduction to MATLAB and Colorizing Images CURIE Academy 2015: Computational Photography Sign-Off Sheet

Creating Digital Illustrations for Your Research Workshop III Basic Illustration Demo

Topic Notes: Java and Objectdraw Basics

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

Exercise III: Creating a Logo with Illustrator CS6

[ the academy_of_code] Senior Beginners

Customisation and production of Badges. Getting started with I-Color System Basic Light

How to make labels in Word By Kathleen K. Koch 26 April Introduction

03 Vector Graphics. Multimedia Systems. 2D and 3D Graphics, Transformations

JASCO CANVAS PROGRAM OPERATION MANUAL

EFILive V8 Gauge Editor

ANSYS AIM Tutorial Structural Analysis of a Plate with Hole

Informatik Image Markup

Adobe PageMaker Tutorial

PLC Papers Created For:

Creative Effects with Illustrator

Design Development Documentation

Transcription:

Study Guide We have examined three main topics: drawing static pictures, drawing simple moving pictures, and manipulating images. The Final Exam will be concerned with each of these three topics. Each of these three topics involve a number of concepts: coordinates, drawing basic shapes and lines, colors, variables, and functions, and other programming statements such as for loops. Drawing with Processing In order to draw, you need a canvas. Processing creates a canvas automatically when you press the play button. This canvas is usually too small to do anything useful though. To specify the dimensions of the drawing canvas use the size statement:! size( numberofpixelsforx, numberofpixelsfory ); For example, the statement:! size( 300, 400 ); creates a canvas which is 300 pixels wide and 400 pixels high. Coordinates Coordinates are a system for naming locations. For example, the longitude and latitude (used in GPS) is a system of coordinates for determining your location on the Earth. In Processing, coordinates can be used to designate a particular pixel on the sketch canvas. We specify pixel locations using two numbers: one for the column and one for the row. On the Processing canvas, columns of pixels are numbered from 0 up to the width of the canvas. Higher numbered columns are to the right of lower numbered columns. Rows of pixels are numbered from 0 up to the height of the canvas. Higher numbered rows are further DOWN the canvas than the lower numbered rows. Drawing Lines Processing can draw straight lines between any two points:! line( firstx, firsty, secondx, secondy ); which will draw the line from (firstx, firsty) to (secondx, secondy).

For example:! line( 0, 0, 0, 100 ); will draw the vertical line from (0, 0) to (0, 100). The line is vertical because the end points have the same x coordinate. The statement:! line( 0, 100, 200, 100 ); will draw the horizontal line from (0, 100) to (200, 100). The line is horizontal because the end point have the same y coordinate. Drawing Rectangles A rectangle can be drawn by specifying the position of a corner and a width and height. The function is:! rect( cornerx, cornery, width, height ); To draw a rectangle at (0, 0) with a width of 50 and a height of 75:! rect( 0, 0, 50, 75 ); To draw a square specify the width and height to be the same value:! rect( 0, 0, 100, 100 ); would draw a square with a side length of 100 pixels. Drawing Circles and Ellipses To draw an ellipse, use the ellipse statement:! ellipse( x, y, width, height ); For example:! ellipse( 10, 10, 100, 200 ); will draw an ellipse at (10, 10) which is half as wide as tall. In one sense, drawing circles and ellipses is similar to drawing squares and rectangles. There is no specific statement for drawing circles. To draw a circle you draw an ellipse with both size dimensions equal. For example:

! ellipse( 20, 40, 10, 10 ); will draw a circle centered at (20, 40) with a radius of 10. Color A color in Processing is created as either a shade of grey or as a combination of red, green, and blue. Colors can also be created with different levels of transparency. Fill Color You can change the interior color of shapes using the fill statement:! fill( amountofwhite ); or! fill( amountofred, amountofgreen, amountofblue ); For example,! fill( 255 ); would cause drawn shapes to have a white interior and! fill( 0, 0, 255 ); would cause drawn shapes to have a blue interior. To change the transparency, specify an additional number in the range from 0 which is completely transparent to 255 which is completely opaque. For example,! fill( 0, 255, 0, 127 ); would fill shapes with a halfway transparent green color. There are quite a few variations of the fill statement:! fill( amountofwhite );! fill( amountofwhite, amountoftransparency );! fill( amountofred, amountofgreen, amountofblue );! fill( amountofred, amountofgreen, amountofblue, amountoftransparency ); where each of the amounts is a number from 0 to 255.

Stroke Color The outline color of shapes is modified with the stroke statement. Stroke works the same as the fill statement. Stroke Weight The thickness or weight of the outline can be specified with the strokeweight statement. The number given is the width in pixels of the outline. For example:! strokeweight( 5 ); specifies an outline which is 5 pixels wide. Variables A variable is a chunk of computer memory which holds a particular type of information. All variables have a name, a current value, and a data type. The name allows the program to access the current value stored in the variable. A variable can only hold one value at a time. The current value must always be of the designated data type (you cannot store colors in number variables or vice versa). Variables are created by specifying the data type and name. For example,! int x; creates a variable named x which can hold integer (whole number) values. Variables are assigned values using assignment statements such as:! x = 155; These can be combined:! int y = 200; A variable to hold a color can be created and assigned a value as follows:! color thecolor = color( 255, 127, 127 );

For loops This statement allows us to repeat steps in our program. The loop statement creates a counting variable which controls the number of repetitions which occur.! for ( int i = 0; i < 400; i = i + 100 )!! rect( i, 200, 40, 40 ); would create a variable i which will count from 0 to almost 400 by 100. The loop continues as long as i is strictly less than 400. The code draws a row of rectangles positioned at (0, 200), (100, 200), (200, 200), (300, 200). Simple Moving Pictures To make something move, we must define a setup function, a draw function, and variable which holds the position of the moving shape:! int x = 0;!! void setup()!! size( 400, 400 );! void draw()!! background( 200 );!! rect( x, 200, 40, 40 );!! x = x + 1; This program will create a small rectangle which will move across the sketch canvas.

Images Processing has a type of variable, called PImage, which can hold an entire image (such as a jpg, gif, or tiff). Such a variable can be created as follows:! PImage theimage; Loading an Image When a PImage variable is created, it does not actually hold an image until the image is loaded from a file:! theimage = loadimage( Homer.jpg ); The Homer.jpg file must be added to the Processing Sketch for this to work. The file can be added by choosing Sketch -> Add File from the Processing tool bar. NOTE: If the file cannot be found or could not be loaded this will generally result in a NULL Pointer error and the program will fail to run. Adding an Image to the Canvas Drawing an image on the sketch canvas is done using the image function:! image( theimage, 100, 0 ); The first value must be a variable of type PImage which contains the image you wish to show, the other two values are the x and y coordinates of where you want the upper left corner of the image to be located on the sketch Canvas. Tint The colors of an image can be changed using the tint function. This function is similar to the stroke and fill functions. You can specify how much red, green, and blue should be used to change the colors in the image. You can also specify transparency. There are four variations of the tint function:! tint( amountofwhite );! tint( amountofwhite, amountoftransparency );! tint( amountofred, amountofgreen, amountofblue );! tint( amountofred, amountofgreen, amountofblue, amountoftransparency ); Each of the amounts is a number from 0 to 255.

Changing or Filtering an Image There are many different ways of altering or filtering an image. The image can be flipped vertically, horizontally, or diagonally. The image could be rotated 90 degrees, 180 degrees, or 270 degrees. The image can also be filtered to remove (or add) red, green, or blue. The image could be made brighter or darker. All of these ideas follow a single template and can be implemented in Processing as a function:! PImage filterimage( PImage someimage )!! PImage thecopy =!!!! someimage.get( 0, 0, someimage.width, someimage.height);!! for (int col = 0; col < someimage.width; col++ )!!!! for (int row = 0; row < someimage.height; row++ )!!!!!! color thecolor = someimage.get( col, row );!!!!! // Put thecolor into thecopy after possibly changing it!!!!! return thecopy; This function takes a PImage called someimage as a parameter or function value. The function first copies someimage into another image called thecopy. It then loops over all of the individual pixels in someimage and gets each pixelʼs color. The function should then alter thecolor and possibly put the altered color into a different place in thecopy image. After all the alteration is complete the function returns (or gives back) thecopy image.

ArrayList An ArrayList object is a container for other objects. When you create an ArrayList variable you specify what it can contain. If you want an ArrayList of PImages, you would do the following:! ArrayList<PImage> thelist; You then need to create the actual list:! thelist = new ArrayList<PImage>(); This creates an empty ArrayList which does not contain any PImage objects. To add a PImage to the list, first load a PImage and then use the add method:!! PImage homer = loadimage( Homer.jpg );! thelist.add( homer ); Objects can be retrieved from the list using get and specifying which item is desired:! PImage charlie = thelist.get( 3 ); This would retrieve the fourth item in the list (because the first item is item number 0). For Loops and ArrayLists To loop over all of the items in an ArrayList there are two methods. The first is to use a standard for loop and the get method:! for ( int i = 0; i < thelist.size(); i++ )!! PImage foo = thelist.get( i );!! image( foo, 0, 0 ); The second is to use the alternative form of the for loop:! for ( PImage foo : thelist )!! image( foo, 0, 0);