Graphics Concepts CS 2302, Fall 2014. 11/17/20142 Drawing in Android.

Slides:



Advertisements
Similar presentations
First of all – lets look at the windows you are going to use. At the top you have a toolbar, with all your various tools you can use when customising your.
Advertisements

Chapter 13 Graphics classes Bjarne Stroustrup
2D Graphics Drawing Things. Graphics In your GUI, you might want to draw graphics E.g. draw lines, circles, shapes, draw strings etc The Graphics class.
1 Drawing C Sc 335 Object-Oriented Programming and Design Rick Mercer.
1. Tuesday: Halloween Shoot due TOMORROW. You must make a contact sheet of your photos and print it from my computer tomorrow. -5 pts for every day I don’t.
Chapter 3 Drawing and Composing an Illustration. Objectives Draw straight lines Draw curved lines Draw elements of an illustration Apply attributes to.
Chapter 6 Photoshop and ImageReady: Part II The Web Warrior Guide to Web Design Technologies.
Chapter 7 Creating Graphics. Chapter Objectives Use the Pen tool Reshape frames and apply stroke effects Work with polygons and compound paths Work with.
Image Maps and Graphics Internet Basics and Far Beyond! Mrs. Wilson.
Working with Vector Graphics – Lesson 21 Working with Vector Graphics Lesson 2.
Cosc 5/4730 Game Design. A short game design primer. A game or animation is built on an animation loop. – Instance variables of “objects” are updated.
Chapter Day 5. © 2007 Pearson Addison-Wesley. All rights reserved2-2 Agenda Day 5 Questions from last Class?? Problem set 1 Posted  Introduction on developing.
Graphics Programming. In this class, we will cover: The difference between AWT and Swing Creating a frame Frame positioning Displaying information in.
1 Applets Chapter 1 To understand:  why applets are used to extend the capabilities of Web pages  how an applet is executed and know about the restrictions.
ObjectDraw and Objects Early Chris Nevison Barbara Wells.
Sketchify Tutorial Graphics and Animation in Sketchify sketchify.sf.net Željko Obrenović
Text, Masks, and Live Effects – Lesson 41 Text, Masks, and Live Effects Lesson 4.
1 Python Programming: An Introduction to Computer Science Chapter 3 Objects and Graphics.
InDesign CS3 Lesson 3 Working with Frames. Using Frames Frames are containers in which you place graphics or text. Frames can also be used as graphic.
Graphics in Android 1 Fall 2012 CS2302: Programming Principles.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 16: Java Applets & AWT Fundamentals of Web Programming.
Lab 5: drawing and output User Interface Lab: GUI Lab Sep. 25 th, 2013.
Click your mouse for next slide Flash – Introduction and Startup Many times on websites you will see animations of various sorts Many of these are created.
6-2 2D Graphics CSNB544 Mobile Application Development Thanks to Utexas Austin.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington GUI and the UI API COMP.
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
Tip Calculator App Building an Android App with Java © by Pearson Education, Inc. All Rights Reserved.
Color Correct and Remove Keystoning A minimalist approach to photographing your art By Paul Marley.
Graphics Concepts CS 2302, Fall /17/20142 Color Concepts.
Alice 2.0 Introductory Concepts and Techniques Project 1 Exploring Alice and Object-Oriented Programming.
Adobe Illustrator Basics Instructor: Cristol Gregory Assistant: Tara Caimi.
Graphics Concepts CS 2302, Fall /3/20142 Drawing Paths.
Working with Objects. Objectives Create an object Transform an object Arrange and lock an object Step and repeat an object Use Live Distribute Use the.
© 2010 Delmar, Cengage Learning Chapter 2 Working with Text and Gradients.
Android Graphics Library. Color Android colors are represented with four numbers, one each for alpha, red, green, and blue (ARGB). Each component can.
Creating HUD Rings. Step 1 Open a new document in Illustrator. You can set it to the size you prefer to work in. In my case I have it set at 500px by.
Lesson 10 Using AutoShapes, WordArt, and Comments Lesson 10 Using AutoShapes, WordArt, and Comments.
Making Python Pretty!. How to Use This Presentation… Download a copy of this presentation to your ‘Computing’ folder. Follow the code examples, and put.
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.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Introduction to Android (Part.
Tkinter Canvas.
Exploring the Macromedia Flash Workspace – Lesson 2 1 Exploring the Macromedia Flash Workspace Lesson 2.
© 2010 Delmar, Cengage Learning Chapter 7 Creating Graphics.
The Abstract Window Toolkit (AWT) supports Graphical User Interface (GUI) programming. AWT features include: a rich set of user interface components; a.
Design Studies 20 ‘Show Off’ Project How to make a computer monitor In Google Sketchup By: Liam Jack.
1 GUIs, Layout, Drawing Rick Mercer. 2 Event-Driven Programming with Graphical user Interfaces  Most applications have graphical user interfaces (GUIs)
By: Affaf Muzammal ALLIED SCHOOL 46-Iqbal Block, Ittefaq Town, Multan Road, Lahore ,
Creating visual interfaces in python
ADOBE INDESIGN CS3 Chapter 7 CREATING GRAPHICS. Chapter 72 Introduction InDesign allows you to create graphics using tools in InDesign The Pen Tool can.
Graphics in Android 1 CS7030: Mobile App Development.
Paint Tutorial Created February 2006 Start Paint: Start>Programs>Accessories>Paint.
ADOBE INDESIGN CS3 Chapter 4 WORKING WITH FRAMES.
Intoduction to Andriod studio Environment With a hello world program.
First of all – lets look at the window’s you are going to use. At the top you have a toolbar, with all your various tools you can use when customising.
Basic 2D Graphics in Android. Android Graphics Programming There are many ways to do graphics programming in Android – 2D vs. 3D – static vs. dynamic.
>>0 >>1 >> 2 >> 3 >> 4 >>
CS 115 Lecture 6 Graphics Taken from notes by Dr. Neil Moore.
Chapter 7 Vector Editing © 2013 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website,
10/20/2005week71 Graphics, mouse and mouse motion events, KeyEvent Agenda Classes in AWT for graphics Example java programs –Graphics –Mouse events –Mouse.
Adobe Photoshop CS5.
Android Application 2D Graphics cs.
Flash Interface, Commands and Functions
Android Layouts 24 July 2018 S.RENUKADEVI/AP/SCD/ANDROID LAYOUTS 1.
Python: Simple Graphics and Event-driven Programming
ISC440: Web Programming II Ch14: HTML5 Canvas
The Canvas.
Chapter 7 Vector Editing
2.02 Understand Digital Vector Graphics
Graphics in Android Fall 2012 CS2302: Programming Principles.
Chapter Lessons Use the Macromedia Flash drawing tools
Presentation transcript:

Graphics Concepts CS 2302, Fall 2014

11/17/20142 Drawing in Android

11/17/20143 Android Alternatives Android provides several ways to create graphic images Drawable objects Defined by program code Defined in resource files Can be manipulated and animated 2D Canvas More in a moment, this is the approach we will take 3D Canvas

11/17/20144 Constructive Graphics Android supports building graphic images from simple components This is sometimes called vector graphics, recalling very early graphics display systems The organization of the visible interface and underlying code is very similar to other systems Event driven drawing Constructive graphics

11/17/20145 Drawing Surface Any View can be used as a drawing surface Reference Every View has an associated Canvas object that provides various drawing methods Canvas reference Even buttons and other widgets can be drawn on, though that may conflict with the drawing done for their basic look View has a method onDraw() that is called by the system when any drawing needs to be done

11/17/20146 Why Event Driven Drawing? In older systems, especially before Windows and Linux, drawing was carried out directly and immediately by programming commands In Android and other GUI systems, drawing is delayed until the system asks for it by calling a method This is because there are many situations in which the drawing may be needed, based on external circumstances The application is starting The application is being uncovered The application is being un-minimized

11/17/20147 Supporting Classes There are numerous supporting classes needed to carry out effective drawing. We mention just a few for now (the links lead to reference pages) Color (already discussed) Color Paint Paint.Style Path (will be discussed later) Path

11/17/20148 Class Paint Paint objects are used to specify many characteristics of drawing Paint can be used to specify The color used to outline and/or fill shapes The style of drawing a shape: filled or outlined Width of lines and curves How lines and curves will be 'joined' and 'capped' Characteristics of text such as font family, font size, and weight

11/17/20149 A Widget to Draw On Since drawing is carried out when the system calls the onDraw method in View, we must create a new class that Extends View Overrides onDraw The overriding method will carry out the drawing The onDraw method takes one parameter, a Canvas that can be used to create the graphics we wish

11/17/ Start an Application Start a new Android application In the same package with the main activity, create a new class named ViewForGraphics

11/17/ View Details View does not have a default constructor, so we must provide at least one constructor that uses 'super' It is convenient to use the constructor that takes two parameters public ViewForGraphics(Context context, AttributeSet attrs) This will allow the new class to be used like any other widget in the GUI editor We won't use that constructor in code When overriding onDraw, call the super method to make sure any standard actions are taken

11/17/ Creating the Interface In the GUI editor, remove the standard TextView Find the new 'widget' at the bottom of the palette Drag the new widget into the editing area Set the widget to fill the space completely Running the app at this point will show nothing

11/17/ Creating Paint Any drawing needs paint A default Paint object will work, but is monochrome Define a color Define the style for filling or not Define the stroke width

11/17/ Drawing a Figure Start with a Paint object Use one of the drawing methods from Canvas Rectangle, Circle and Oval are easy to use The example we will do is Draw a rectangle outline Draw a filled oval using the same coordinates The oval touches the sides of the rectangle Drawing a circle uses the center and radius, so beware!

11/17/ Drawing Text Some terminology Baseline Ascent, descent Leading Font family Drawing text Alignment

11/17/ Add Some Text Write the word 'Center' in the center of the oval/rectangle combination Set the text size to 40 to make it more visible Try different text alignment settings Try both stroke and fill for the characters

11/17/ Drawing Paths

11/17/ Drawing models Drawing models explain how color is applied to the screen to create graphics. We’ve not had to worry about that so far because we’ve worked with very simple figures. However, even to draw something as simple as a triangle and fill it in, our tools are not adequate. Drawing models usually work with a pen which is moved around. Sometimes the pen leaves a trace, sometimes it does not The color of the trace the pen leaves can change If the pen traces a closed curve, that is it finishes at the point where it started, the area enclosed can be filled.

11/17/ Turtle Graphics One drawing model, called Turtle Graphics was popularized by a language called Logo. The pen is called a turtle in this model In this model, the turtle has a position and heading. The turtle can turn in place, changing its heading The turtle can move a given distance in the direction it is currently heading

11/17/ Android Paths The model used in Android for paths is similar, but only works with position. The pen has a current position at any time The pen can be moved to another position. The pen can leave a trace or not. The pen can move in a straight line to another position or along a variety of curved segments. If the path is the outline of an area to be filled, the path is ended by closing the path. Once the Path is created, it must be drawn to be visible Path Reference

11/17/ Polygonal Paths Paths made of line segments Create a Path object Apply methods moveTo(x,y) lineTo(x,y) Close() Use drawPath to make display the path

11/17/ Examples We'll continue using the example project we used earlier Each example will be implemented as a new widget that can be dragged into the user interface The first example will be a path that has five line segments: two will be invisible, three will be visible Fill the path first Outline the path second Note the visible and invisible segments Note that even invisible segments bound the interior

11/17/ Diamonds Another view will draw diamonds A diamond is created by connecting the midpoints of the sides of a rectangle Write a method that will create and return a diamond shaped path given the left, top, right and bottom coordinates of the enclosing rectangle The view will draw many diamonds in random position and with random color The color will have value.75 but with random hue and saturation

11/17/ Interactive Diamonds View This is the same as the basic diamond view except that every time the view is clicked, the number of diamonds is reduced by 1 The view will contain a listener registered to 'this' Once the number of diamonds has been reduced, the view must be redrawn Note that, right now, clicking the view causes no visible change Write a message to the log file (visible in the logcat view) to show that the listener is actually active

11/17/ Forcing Redrawing There is an internal change but not a visible change The onDraw method must be executed somehow However, we don't have a Canvas, necessary to call onDraw There's no good way to create a useful one either The system must call onDraw So, we ask the system to call onDraw for us This is what the method 'invalidate' does It tells the system that the current state of the view is not valid, so it must be redrawn