Microsoft® Small Basic

Slides:



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

Microsoft® Small Basic
Microsoft® Small Basic
Microsoft® Small Basic Statements, Properties, and Operations Estimated time to complete this lesson: 1 hour.
Microsoft® Small Basic
Microsoft® Small Basic
Microsoft® Small Basic
Microsoft® Small Basic Clock, Desktop, and Dictionary Objects Estimated time to complete this lesson: 1 hour.
Sketchify Tutorial Graphics and Animation in Sketchify sketchify.sf.net Željko Obrenović
1 Introduction to the Visual Studio.NET IDE Powerpoint slides modified from Deitel & Deitel.
Microsoft® Small Basic The Math Object Estimated time to complete this lesson: 1 hour.
Microsoft® Small Basic Sharing Code Estimated time to complete this lesson: 1 hour.
Microsoft® Small Basic Clock, Desktop, and Dictionary Objects Estimated time to complete this lesson: 1 hour.
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
Microsoft® Small Basic The Controls Object Estimated time to complete this lesson: 1 hour.
Microsoft® Small Basic
Creating a Basic Presentation in PowerPoint Welcome to the Faculty Instructional Technology Support Center.
Visual BasicC++ Diane Zak. Microsoft © Small (But Powerful) Basic Presented by Diane Zak.
Microsoft® Small Basic
Introduction to Flash. Topics What is Flash? What can you do with it? Simple animation Complex interactive web application, such as an online store. Starting.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 7 The Game Loop and Animation Starting Out with Games & Graphics.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved CheckWriter Application Introducing Graphics and Printing.
© 2011 Delmar, Cengage Learning Chapter 1 Getting to Know Illustrator.
Laboratory Exercise # 9 – Inserting Graphics to Documents Office Productivity Tools 1 Laboratory Exercise # 9 Inserting Graphics to Documents Objectives:
Microsoft® Small Basic Collision Detection Estimated time to complete this lesson: 1 hour.
Chapter 2 – Introduction to the Visual Studio .NET IDE
Loops & Graphics IP 10 Mr. Mellesmoen Recall Earlier we wrote a program listing numbers from 1 – 24 i=1 start: TextWindow.WriteLine(i) i=i+1 If.
Welcome to PowerPoint for Beginners In-Tech Training Elementary School Teachers Day 2 January 13 and 14, 2003.
Microsoft® Small Basic Exploring Shapes Estimated time to complete this lesson: 1 hour.
CRE Programming Club - Class 5 Robert Eckstein and Robert Heard.
Microsoft® Small Basic Flickr, ImageList, and Network Objects Estimated time to complete this lesson: 1 hour.
Microsoft® Small Basic Conditions and Loops Estimated time to complete this lesson: 2 hours.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
Adobe Illustrator CS Design Professional WITH ILLUSTRATOR GETTING STARTED.
Dive Into® Visual Basic 2010 Express
Creating a UFO Rescue Game in Alice
MOM! Phineas and Ferb are … Aims:
Introduction to presentations ms PowerPoint
Flash Interface, Commands and Functions
Adobe Photoshop 101 With Professor John Blandin Technology Department
Chapter 2 – Introduction to the Visual Studio .NET IDE
INTERACTIVE TRANSPARENCY BUILDING A Character IN ANIMATION
Exploring Mathematical Relationships Module 5: Investigation 2
Example: Card Game Create a class called “Card”
Visual programming Chapter 1: Introduction
Creating, Formatting, and Editing a Word Document with Pictures
Graphics and Multimedia
Microsoft PowerPoint 2003 Illustrated Introductory
Microsoft® Small Basic
Microsoft® Small Basic
Creating a UFO Rescue Game in Alice
Starter Write a program that asks the user if it is raining today.
A Tiny Look at the Graphics Window
First text statement positioned here at guide intersection
Basic Graphics Drawing Shapes 1.
Chapter 14 JavaFX Basics Dr. Clincy - Lecture.
Chapter 15, Images …a few points
Chapter 2 – Introduction to the Visual Studio .NET IDE
Microsoft® Small Basic
Microsoft® Small Basic
Fly-in marquee lights at picture entrance (Intermediate)
Microsoft® Small Basic
Animated recolored picture fades in over black and white copy
Chapter 15, Images …a few points
ICT Gaming Lesson 3.
A Tiny Look at the Graphics Window
Microsoft Publisher 2016.
Using Animation and Multimedia
PowerPoint Practice Exercise
Chapter 7 The Game Loop and Animation
Presentation transcript:

Microsoft® Small Basic Exploring Shapes Estimated time to complete this lesson: 1 hour

Exploring Shapes In this lesson, you will learn about: Creating shapes by using the Shapes object. Using various operations of the Shapes object. Animating shapes on the screen.

Introduction to the Shapes Object So far, you have learned to use the GraphicsWindow and the Turtle objects to draw patterns in Small Basic. This lesson introduces you to the Shapes object offered by Small Basic! You can use the Shapes object to add, rotate, and animate the shapes in the graphics window. You can color your shapes by using specific properties of the GraphicsWindow object.

Operations of the Shapes Object Using certain operations of the Shapes object, you can give a vibrant look and feel to the shapes you create. Some of these operations are: AddImage AddRectangle HideShape ShowShape SetOpacity GetOpacity Move Animate Zoom

Operations of the Shapes Object Let’s look at an example to demonstrate these operations… output In this example, we have used the ShowShape, HideShape and SetOpacity operations of the Shapes object to perform various actions on the rectangle shape. You can insert a shape on the graphics window by using the Shapes object in Small Basic. Take a look at the example displayed on the screen. To insert a rectangle shape on the screen, you can use the AddRectangle operation. Then, you can perform actions on the shape by using various operations of the Shapes object. For example, to show and hide the rectangle on the screen, you can use ShowShape and HideShape operations. To change the opacity level of the shape, you can use the SetOpacity operation. Check the output of your program by clicking the Run button on the toolbar or pressing F5 on the keyboard. A rectangle shape is displayed on the graphics window. After a delay of one second, the shape is hidden. When the shape reappears on the screen, its opacity level is reduced. This process continues until the rectangle is completely opaque. Code: rectangle = Shapes.AddRectangle(400, 300) Shapes.Move(rectangle, 100, 50) For i = 1 To 10 If i = 10 Then i = 0 Else Shapes.ShowShape(rectangle) Program.Delay(1000) Shapes.HideShape(rectangle) Shapes.SetOpacity(rectangle, 100 - i * 20) Program.Delay(800) EndIf EndFor

Operations of the Shapes Object Now let’s understand these operations in detail… AddRectangle—Using this operation, you can draw a rectangle on the graphics window. HideShape—This operation allows you to hide a shape displayed on the graphics window. ShowShape—This operation allows you to display a shape on the graphics window. SetOpacity—You can set the opacity of a shape by using the SetOpacity operation. You must specify the name of the shape and an opacity level from 0 to 100. GetOpacity—This operation gets the opacity of a shape. You must specify the name of the shape as a parameter to this operation. When specifying the opacity level as a parameter, note that 0 renders the shape as completely transparent and 100 renders the shape as completely opaque. Code: rectangle = Shapes.AddRectangle(150, 100) Shapes.HideShape(rectangle) Shapes.ShowShape(rectangle) Shapes.SetOpacity(rectangle, 50) Shapes.GetOpacity(rectangle)

Operations of the Shapes Object Let’s look at another example to demonstrate some more operations… In this example, we have used the AddImage operation to insert an image on the screen. Next, we have used the Move, Animate and Zoom operations to perform various actions on the image. You can also insert images on the graphics window by using the Shapes object in Small Basic. To insert an image on the screen, you can use the AddImage operation with the Shapes object. Then, you can perform actions on the shape by using various operations of the Shapes object. For example, to move a shape on the screen, you can use Move operation. To animate a shape on the screen, you can use the Animate operation. Similarly, to zoom a shape on the screen, you can use the Zoom operation. Check the output of your program by clicking the Run button on the toolbar or pressing F5 on the keyboard. An image is displayed on the graphics window. The image is then moved and animated to a different location on the screen. Finally, the image is zoomed until the image covers the entire screen. Code: imagepath = "C:\Small Basic\Water lilies.jpg" image=Shapes.AddImage(imagepath) Shapes.Move(image, 5, 5) Shapes.Animate(image, 20, 20, 1000) Shapes.Zoom(image, 0.1, 0.1) For i=0 To 1 Step 0.1 Program.Delay(1000) Shapes.Zoom(image, 0.1 + i, 0.1 + i) EndFor

Operations of the Shapes Object AddImage—Using this operation, you can insert an image on the graphics window. Move—Using this operation, you can set the new location of the shape on the graphics window. You must specify the name of the shape, and the x- and y-coordinates of the new location. Animate—This operation animates a shape to a new position. You must specify the name of the shape, the x- and y-coordinates of the new position, and the duration of the animation. Code: rectangle = Shapes.AddRectangle(150, 100) Shapes.Move(rectangle, 125, 125) Shapes.Animate(rectangle, 30 * I, 150, 5000) Shapes.Zoom(rectangle, 2, 2) Zoom—The Zoom operation scales a shape by using a particular zoom level. You must specify the name of the shape and select a zoom level between 0.1 and 20.

Operations of the Shape Object You can use the Shapes object to add different types of shapes in your program. You can then perform various operations on the Shapes object, such as moving the shape, setting its opacity, or adding a zoom effect. Now, let’s look at an example… Click the button on the toolbar. You can create shapes on the screen by using the Shapes object. Take a look at the example on the screen: First, you use the PenWidth, PenColor, and BrushColor properties of the GraphicsWindow object to set the color and width of the pen, and the color of the brush that you use to draw the shapes. In this example, you want to draw two rectangles of the same size, so you use the AddRectangle operation of the Shapes object, and define the parameters for the width and height of the rectangle. You set the location of the rectangles on the graphics window; use the Move operation and define the parameters for the x-coordinate and y-coordinate to where you want the rectangle to move. To set an opacity level for a rectangle, you use the SetOpacity operation with parameters that include the name of the shape and the opacity level. Next, you can zoom a rectangle, by using the Zoom operation. Simply specify the parameters for the name of the shape, and the zoom level on the x-axis and y-axis, respectively.   Check the output of your program by clicking the Run button on the toolbar or pressing F5 on the keyboard. Notice the difference between the two rectangles after using operations of the Shapes object on one of the rectangles. Code: GraphicsWindow.Title = "Exploring Shapes" GraphicsWindow.Height = 350 GraphicsWindow.Width = 450 GraphicsWindow.PenWidth = 2 GraphicsWindow.PenColor = "Black" GraphicsWindow.BrushColor = "Purple" rectangle1 = Shapes.AddRectangle(100, 100) Shapes.Move(rectangle1, 50, 80) rectangle2 = Shapes.AddRectangle(100, 100) Shapes.Move(rectangle2, 300, 80) For i = 1 To 4 Program.Delay(1000) Shapes.Zoom(rectangle1, i * 0.4, i * 0.4) Shapes.SetOpacity(rectangle1, i * 5) EndFor

Animating a Shape Let’s see an example to animate a shape by using the Shapes object. In this example, you animate a shape from its original position to a new position and back to its original position on the graphics window. You can animate shapes in Small Basic by using the Animate operation. For example, say you want to move a ball on the graphics window from one position to another. First, you create the ball shape by using the AddEllipse operation and set its original position on the graphics window by using the Move operation. Next, you define a variable with a new x co-ordinate value. You use this variable when animating the ball shape by using the Animate operation. You also create a rectangle shape on the screen, against which the ball will be animated. You define a simple conditional statement to animate the ball against the rectangle. When you click the Run button on the toolbar or press F5 on the keyboard, the program is executed, and the ball is animated against the rectangle. Code: GraphicsWindow.Title = "Exploring Shapes" shape1 = Shapes.AddRectangle(100, 100) Sball = Shapes.AddEllipse(100, 100) Shapes.Move(Sball, 0, 340) x = 450 GraphicsWindow.DrawRectangle(550, 0, 80, 450) GraphicsWindow.BrushColor = "Purple" GraphicsWindow.FillRectangle(550, 0, 80, 450) Shapes.Animate(Sball, x, 40, 490) Program.Delay(500) If (Shapes.GetLeft(Sball) = x) Then Shapes.Animate(Sball, 0, 340, 500) EndIf

Rotating a Shape Let’s explore some more operations of the Shapes object by writing a program to rotate a shape. In this example, you use a For loop to rotate a shape along its original position on the graphics window. output Click the button on the toolbar. You can rotate shapes in Small Basic by using conditions and loops for your shapes. For example, say you want to rotate a rectangle on the graphics window along its original position. First, you create the shape by using the AddRectangle operation and set its original position on the graphics window by using the Move operation. Next, you use a For loop to rotate the shape along its original position on the graphics window to a new position. When you click the Run button on the toolbar or press F5 on the keyboard, the program is executed, and the rectangle rotates and moves from one position to another. Code: GraphicsWindow.Title = "Exploring Shapes" GraphicsWindow.BrushColor = "Purple" rotateshape = Shapes.AddRectangle(150, 100) Shapes.Move(rotateshape, 200, 150) For i = 0 To 12 Shapes.Rotate(rotateshape, 30 * i) Program.Delay(1000) EndFor When you execute the program, the rectangle rotates on the graphics window.

Fun with Shapes In addition to drawing shapes of different styles and sizes, you can also create unique shape designs by using conditions and loops in your program. For example, you can use a For loop to create multiple rectangles in random colors… output In addition to drawing shapes of different styles and sizes, you can also create unique shape designs by using conditions and loops in your program. For example, look at the displayed code. You use a For loop to create multiple rectangles, positioned in ascending order by size. You also use the GetRandomColor operation of the GraphicsWindow object to randomize the color of the rectangles. When you click the Run button on the toolbar or press F5 on the keyboard, the program executes, demonstrating a colorful display of rectangles. Code: GraphicsWindow.Title = "Exploring Shapes" GraphicsWindow.Height = 500 GraphicsWindow.Width = 700 For i = 0 To 20 GraphicsWindow.PenWidth = 0.5 GraphicsWindow.BrushColor = GraphicsWindow.GetRandomColor() rectangle1 = Shapes.AddRectangle(i * 20, i * 10) Shapes.Move(rectangle1, i * 10, i * 10) EndFor

Let’s Summarize… Congratulations! Now you know how to: Create shapes by using the Shapes object. Use various operations of the Shapes object. Animate the shapes on the screen.

It’s Time to Apply Your Learning… Write a program to display a graphics window, and perform the following steps: Add a line and a circle to the graphics window. Set the color, size, and location for the shapes as required. Animate the circle so that it moves from the left side of the graphics window to the right, on top of the line. Solution:   GraphicsWindow.Title = "Exploring Shapes" GraphicsWindow.Height = 200 GraphicsWindow.Width = 300 GraphicsWindow.PenColor = "Purple" base = Shapes.AddLine(0, 0, 300, 0) Shapes.Move(base, 0, 100) GraphicsWindow.PenColor = "Black" GraphicsWindow.BrushColor = "Cyan" circle = Shapes.AddEllipse(50, 50) Shapes.Move(circle, 0, 50) Shapes.Animate(circle, 250, 50, 1000)