Loops & Graphics IP 10 Mr. Mellesmoen 2014. Recall Earlier we wrote a program listing numbers from 1 – 24 i=1 start: TextWindow.WriteLine(i) i=i+1 If.

Slides:



Advertisements
Similar presentations
FUN WITH SHAPES INFORMATION PROCESSING 10 MR. MELLESMOEN.
Advertisements

Lab # 03- SS Basic Graphic Commands. Lab Objectives: To understand M-files principle. To plot multiple plots on a single graph. To use different parameters.
Lesson 5+: Using He- Builder/She-Builder And Adding Text! Slides are adapted from aliceprogramming.net or
Noadswood Science,  To know how to use Python to produce windows and colours along with specified co-ordinates Sunday, April 12, 2015.
RAPTOR Syntax and Semantics By Lt Col Schorsch
PHY-102 SAPIntroductory GraphicsSlide 1 Introductory Graphics In this section we will learn how about how to draw graphics on the screen in Java:  Drawing.
Go through this show in OpenOffice Impress by using the right scrollbar or clicking individual slide thumbnails on the left side. This hands-on demo is.
Chapter 6 Photoshop and ImageReady: Part II The Web Warrior Guide to Web Design Technologies.
Code Club Session 3 Shark Eats Fish. Picture of finished product here.
Section 2.3 Gauss-Jordan Method for General Systems of Equations
Mrs. Chapman. Tabs (Block Categories) Commands Available to use Script Area where you type your code Sprite Stage All sprites in this project.
Copyright 2008 by Pearson Education Building Java Programs Graphics Reading: Supplement 3G.
Copyright 2006 by Pearson Education 1 Building Java Programs Supplement 3G: Graphics.
Section 1.2: Drawing a UFO (continued). Writing a program to draw UFOs Remember that the header includes: define program’s name(let’s call it UFO-draw)
Copyright 2006 by Pearson Education 1 Building Java Programs Supplement 3G: Graphics.
Back to Table of Contents Advanced PowerPoint Techniques Prepared by Pat Samuel WS 445/545 - Feb
Introduction to TouchDevelop
Mr. Wortzman. Tabs (Block Categories) Available Blocks Script Area Sprite Stage All sprites in this project.
Making a Timer in Alice.
Shorter of two objects and changing color V2 Functions, events and setting the color in sequence and randomly This is a modification of the Changing Color.
Microsoft® Small Basic
Art 321 Lecture 7 Dr. J. Parker. Programming In order to ‘make things happen’ on a computer, you really have to program it. Programming is not hard and.
Agent P, I have been hearing some rumours about a Python Turtle.
TURTLE GRAPHICS IP MR. MELLESMOEN. LOGO IN THE 1970’S THERE WAS A SIMPLE BUT POWERFUL PROGRAMMING LANGUAGE CALLED LOGO THAT WAS USED BY A FEW.
Introduction to TouchDevelop
CRE Programming Club - Class 4 Robert Eckstein and Robert Heard.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.
Making Python Pretty!. How to Use This Presentation… Download a copy of this presentation to your ‘Computing’ folder. Follow the code examples, and put.
Graphic Basics in C ATS 315. The Graphics Window Will look something like this.
1 Building Java Programs Supplement 3G: Graphics These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They may not be rehosted, sold,
Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.
CSC 1010 Programming for All Lecture 7 Input, Output & Graphics.
Graphics Concepts CS 2302, Fall /17/20142 Drawing in Android.
Kindergarten Shapes. Part 1: Multiple Choice (1 point each)
Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008.
Intro to Arrays COMPUTER GAME DESIGN FAIRPORT HIGH SCHOOL.
Microsoft® Small Basic Exploring Shapes Estimated time to complete this lesson: 1 hour.
CRE Programming Club - Class 5 Robert Eckstein and Robert Heard.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
CS305j Introduction to Computing Simple Graphics 1 Topic 11 Simple Graphics "What makes the situation worse is that the highest level CS course I've ever.
Introduction to Graphics. Graphical objects To draw pictures, we will use three classes of objects: –DrawingPanel : A window on the screen. –Graphics.
The Microsoft ® Mouse Mischief ™ add-in works with Microsoft ® PowerPoint ® 2010 or Microsoft ® Office PowerPoint ® Download and install the Mouse.
Turtle Graphics Lesson 2 1. There are 3 homeworks to complete during the six lessons of this unit. Your teacher will let you know when a homework has.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech May 2009.
Hackety Hack! Written by Krystal Salerno Presented by _______________.
MOM! Phineas and Ferb are … Aims:
Adapted from slides by Marty Stepp and Stuart Reges
Building Java Programs
Building Java Programs
Building Java Programs
Microsoft® Small Basic
Starter Write a program that asks the user if it is raining today.
A Tiny Look at the Graphics Window
Learning to program with Logo
Basic Graphics Drawing Shapes 1.
Microsoft® Small Basic
CSc 110, Spring 2018 Lecture 9: Parameters, Graphics and Random
Microsoft® Small Basic
Fractions 1/2 1/8 1/3 6/8 3/4.
Here are four triangles. What do all of these triangles have in common
Using Logo and Logic This presentation uses a version of Logo called StarLogo available through MIT. It can be downloaded for free and installed on your.
Building Java Programs
Building Java Programs
A Tiny Look at the Graphics Window
Building Java Programs
Building Java Programs
Creating a Simple Game in Scratch
Graphics Reading: Supplement 3G
Presentation transcript:

Loops & Graphics IP 10 Mr. Mellesmoen 2014

Recall Earlier we wrote a program listing numbers from 1 – 24 i=1 start: TextWindow.WriteLine(i) i=i+1 If (i<25) Then Goto start EndIf This program is equivalent to: For i = 1 to 24 TextWindow.WriteLine (i) EndFor Run this program to see the results

For…EndFor For…EndFor is a called a loop, it allows you to take a variable and give it initial and ending values. Try this one: For i = 1 to 24 Step 2 TextWindow.WriteLine(i) EndFor

Task: 1. Use this program to list all the even numbers between 50 and Try to make your computer count down from 10 to 0. You will need to change the order of your numbers in your program AND Step -1 each time. 3. Look back to the first few programs we did and tell your computer to count from 0 to 100 but have the numbers appear YELLOW.

While Loop While Loops will run until a given condition is true. In this program we will continually divide a number by 2. Number=100 While (number>1) TextWindow.WriteLine(number) Number=number/2 Endwhile What’s happening here? We are giving a starting point: 100 We are saying that if the number is greater than 1 then divide it by 2. The program will keep doing this until an answer that is less than 1 is found, then it will stop.

Beginning Graphics So far we have just used Small Basic® to work with text & numbers, we did so in the TextWindow. Small Basic® also offers a place to work on graphics, that being the GraphicsWindow Type in to your editor: GraphicsWindow.Show( ) Now you should see a white screen.

Size & Color Enter the following code to customize the size & color of your graphics window. GraphicsWindow.BackgroundColor = "steelblue" GraphicsWindow.Title = "My Graphics Window" GraphicsWindow.Width = 320 GraphicsWindow.Height = 200 GraphicsWindow.Show( ) Play with the variables to change the size and color of your window.

Drawing Lines Once we have GraphicsWindow up we can draw shapes, text & even pictures on it. We will create a simple shape using the code listed at the right. GraphicsWindow.Width = 200 GraphicsWindow.Height = 200 GraphicsWindow.DrawLine (10, 10, 100, 100) GraphicsWindow.DrawLine (10, 100, 100, 10)

Pen Color & Pen Width Let’s add some color to our lines… GraphicsWindow.Width = 200 GraphicsWindow.Height = 200 GraphicsWindow.PenColor = “Green” GraphicsWindow.DrawLine (10, 10, 100, 100) GraphicsWindow.PenColor = “Gold” GraphicsWindow.DrawLine (10, 100, 100, 10) GraphicsWindow.Width = 200 GraphicsWindow.Height = 200 GraphicsWindow.PenWidth = 10 GraphicsWindow.PenColor = “Green” GraphicsWindow.DrawLine (10, 10, 100, 100) GraphicsWindow.PenColor = “Gold” GraphicsWindow.DrawLine (10, 100, 100, 10) As a default, the program has the pen width set to 1. Add line 3 to your program as shown below.

Looping With Graphics! By using a looping program (seen at right) we can write a program that creates multiple lines that increase in thickness. GraphicsWindow.BackgroundColor = “black" GraphicsWindow.Width = 200 GraphicsWindow.Height = 160 GraphicsWindow.PenColor = “Blue” For i = 1 to 10 GraphicsWindow.PenWidth = i GraphicsWindow.DrawLine (20, i * 15, 180, i * 15) endfor

How Did That Work? GraphicsWindow.BackgroundColor = “black" GraphicsWindow.Width = 200 GraphicsWindow.Height = 160 GraphicsWindow.PenColor = “Blue” For i = 1 to 10 GraphicsWindow.PenWidth = i GraphicsWindow.DrawLine (20, i * 15, 180, i * 15) endfor What we notice is the PEN WIDTH is increased each loop. We said to start at 1 and go to 10 (For i=1 to 10) and then said our PenWidth = i

Coordinates In our GraphicsWindow, the top left corner corresponds to 0, 0 on the coordinate plane (think math now). After that we are simply adding coordinates. Let’s go back to drawing lines. Draw a line from 0, 0 to 10, 10 by entering the code at the right. GraphicsWindow.Width = 200 GraphicsWindow.Height = 200 GraphicsWindow.DrawLine (0, 0, 10, 10)

Squares In the command line GraphicsWindow.DrawLine (0, 0, 10, 10) you are identifying a starting point (0, 0) and an ending point (10, 10). Try to draw a square that starts at (1, 1)

Easier Ways That square took some figuring, and of course with programming there always seems to be an easier way. Enter the code at right: GraphicsWindow.Width=300 GraphicsWindow.Height=300 GraphicsWindow.DrawRectangle (20, 20, 220, 220)

Other Shapes Try drawing ellipses, triangles, and rectangles. You can also fill these shapes by entering the command: GraphicsWindow.FillRectangle ( coordinates go in here )

Task Try to draw a circle in a circle, you can try to color the circles if you wish. Here is how I created mine: Note: this filled the ellipse with a random color. This filled it with the color I specified GraphicsWindow.Width=300 GraphicsWindow.Height=300 GraphicsWindow.DrawEllipse (20, 20, 200, 200) GraphicsWindow.FillEllipse (20, 20, 200, 200) GraphicsWindow.DrawEllipse (70, 70, 100, 100) GraphicsWindow.BrushColor = "yellow" GraphicsWindow.FillEllipse (70, 70, 100, 100)