By: Eliav Menachi.  Android custom 2D graphics library  OpenGL ES 1.0 for high performance 3D graphics.

Slides:



Advertisements
Similar presentations
Threads, Surface Views and Real-Time Games. Background Most of the Android apps we’ve covered so far have been single threaded – And Event driven – An.
Advertisements

CS378 - Mobile Computing 2D Graphics A Crash Course in Using (Android) 2D Graphics Libraries.
CS378 - Mobile Computing 3D Graphics.
App Development on Android
Graphics & Animation in Android. Android rendering options The Canvas API Renderscript OpenGL wrappers NDK OpenGL
1 Frameworks. 2 Framework Set of cooperating classes/interfaces –Structure essential mechanisms of a problem domain –Programmer can extend framework classes,
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.
3.02 Computer Animation Software and Design Guidelines
Development of mobile applications using PhoneGap and HTML 5
2D Graphics: Part 1. Android Graphics Libraries 2D Graphics –custom 2D graphics library in packages android.graphics android.graphics.drawable android.graphics.drawable.shapes.
3.02 Computer Animation Software and Design Guidelines
Basic Animation. Animation 4 options – Animated.gif – Frame by Frame animation – Tweened animation This is our focus – OpenGL ES Graphics API for more.
MULTIMEDIA TECHNOLOGY SMM 3001 MEDIA - GRAPHICS. In this chapter how the computer creates, stores, and displays graphic images how the computer creates,
UNIT-V The MVC architecture and Struts Framework.
Basic Drawing Techniques
Chapter 10: Move! Creating Animation
© 2009 Research In Motion Limited Advanced Java Application Development for the BlackBerry Smartphone Trainer name Date.
Foundation Flash CS Introduction Welcome to Flash CS3 Professional. You have seen a lot of the great stuff Flash can do and it is now time for.
6-2 2D Graphics CSNB544 Mobile Application Development Thanks to Utexas Austin.
Exploring 2D Graphics: The Sudoku Example Content taken from book: “Hello, Android” by Ed Burnette Third Edition.
Android How to Program Presented by Thomas Bucag, Rob Goodfellowe, Samantha Tomeï © by Pearson Education, Inc. All Rights Reserved.
London April 2005 London April 2005 Creating Eyeblaster Ads The Rich Media Platform The Rich Media Platform Eyeblaster.
London April 2005 London April 2005 Creating Eyeblaster Ads The Rich Media Platform The Rich Media Platform Eyeblaster.
Mobile Application Development using Android Lecture 2.
Frank Xu Gannon University.  Linear Layout  Relative Layout  Table Layout.
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 12 lcdui Rob Pooley
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 13 lcdui and OXO Rob Pooley
SpotOn Game App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Object Oriented Software Development 9. Creating Graphical User Interfaces.
Windows, Linux, Mac, Android, iOS
Introduction to Flash Animation CS 318. Topics Introduction to Flash and animation The Flash development environment Creating Flash animations  Layers.
Android Graphics Library. Color Android colors are represented with four numbers, one each for alpha, red, green, and blue (ARGB). Each component can.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Introduction to Android (Part.
Animation Liveliness Simulation of motions A video made from a series of drawings/images simulating motions by means of slight progressive changes.
Announcements Homework #2 will be posted after class due Thursday Feb 7, 1:30pm you may work with one other person No office hours tonight (sorry!) I will.
Introduction to Interactive Media Interactive Media Tools: Authoring Applications.
SurfaceView.
Graphics Concepts CS 2302, Fall /17/20142 Drawing in Android.
Pearson Webcast Series
Basic Animation. Animation 4 options – Animated.gif – Frame by Frame animation – Tweened animation This is our focus – OpenGL ES Graphics API for more.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
Mobile Computing Lecture#12 Graphics & Animation.
Object-Oriented Programming: Inheritance and Polymorphism.
S.Linev: Go4 - J.Adamczewski, H.G.Essel, S.Linev ROOT 2005 New development in Go4.
Basic 2D Graphics in Android. Android Graphics Programming There are many ways to do graphics programming in Android – 2D vs. 3D – static vs. dynamic.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 10: Move! Creating Animation 1 Android.
David Sutton 2D GRAPHICS IN ANDROID. INTRODUCTION AND OUTLINE  In this week’s session we will create a simple Kaleidoscope application. Topics that will.
CHAPTER 4 Fragments ActionBar Menus. Explore how to build applications that use an ActionBar and Fragments Understand the Fragment lifecycle Learn to.
CHAPTER 6 Threads, Handlers, and Programmatic Movement.
CHAPTER 5 Graphics Drawing Audio. Chapter objectives: Learn to draw to a canvas Examine the process of adding drawn elements and UI controls to a layout.
Services. What is a Service? A Service is not a separate process. A Service is not a thread. A Service itself is actually very simple, providing two main.
Lecture 3: Animation & Graphics Topics: Animation, Graphics, Drawing Date: Feb 2, 2016.
Build your own 2D Game Engine and Create Great Web Games using HTML5, JavaScript, and WebGL. Sung, Pavleas, Arnez, and Pace, Chapter 5 Examples 3.
Graphics & Animation Radan Ganchev Astea Solutions.
Android Application 2D Graphics cs.
Lecture 3: Animation & Graphics
Graphical Output Basic Images.
Lecture 3: Animation & Graphics
Instructor: Mazhar Hussain
Lecture 8: Graphics By: Eliav Menachi.
Activities and Intents
Android Layouts 24 July 2018 S.RENUKADEVI/AP/SCD/ANDROID LAYOUTS 1.
Data Modeling II XML Schema & JAXB Marc Dumontier May 4, 2004
Mobile Computing With Android ACST 4550 Android Animation
.NET and .NET Core 7. XAML Pan Wuming 2017.
Graphics with Canvas.
Cannon Game App Android How to Program
Lecture 3: Animation & Graphics
Lecture 8: Graphics By: Eliav Menachi.
Mobile Computing With Android ACST 4550 Android Animation
Presentation transcript:

By: Eliav Menachi

 Android custom 2D graphics library  OpenGL ES 1.0 for high performance 3D graphics

 When drawing 2D graphics, you'll typically do so in one of two ways 1. Draw your graphics or animations into a View object from your layout. 2. Draw directly to a Canvas

 Best choice when drawing simple graphics  Where is no need to change dynamically  Its not part of a performance-intensive game  The drawing and animation is handled by the system's normal View hierarchy drawing process  You simply define the graphics to go inside the View

 Android offers a custom 2D graphics library for drawing and animating shapes and images :  android.graphics.drawable android.graphics.drawable  android.view.animation android.view.animation

 A Drawable is a general abstraction for "something that can be drawn"Drawable  There are three ways to define and instantiate a Drawable:  using an image saved in your project resouces  using an XML file that defines the Drawable properties  using the normal class constructors

 ShapeDrawable is used to dynamically draw some two-dimensional graphics ShapeDrawable  A ShapeDrawable is an extension of Drawable Drawable  ShapeDrawable has its own draw() method  you can create a subclass of View that draws the ShapeDrawable during the View.onDraw() method  See Simple Shape example

 When you're application needs to regularly re-draw itself (like games)  There's more than one way to do this:  In the same thread as your UI Activity, using a custom View in your layout, call invalidate() and then handle the onDraw() callback..invalidate()onDraw()  In a separate thread, by managing a SurfaceView and performing draws to the Canvas as fast as your thread is capable.SurfaceView

 A Canvas works for you as a pretense, or interface, to the actual surface upon which your graphics will be drawn  The Canvas holds all of your "draw" calls  Via the Canvas, your drawing is actually performed upon an underlying Bitmap, which is placed into the window.Bitmap  Using the canvas:  On a View  On a SurfaceView

 Create a custom View component  Override the onDraw() callback methodonDraw()  This method will be called by the Android framework to request that the View draw itself  Use the given Canvas for drawingCanvas  The View is drawn by Android only when invalidated  Use Invalidate() to invalidate the View  See SimpleShape Example

 Create an animated View  Create a Drawable to hold our animated image  Override the onDraw method which draw the view  Setting bounds defines the position and size of the image inside the View  Display the view in your activity and update the view periodically

 The SurfaceView is a special subclass of View that offers a dedicated drawing surface within the View hierarchySurfaceView  The aim is to offer this drawing surface to an application's secondary thread  The application isn't required to wait until the system's View hierarchy is ready to draw  Secondary thread can draw to its own Canvas at its own pace using a reference to the SurfaceView

1. Create a new class that extends SurfaceViewSurfaceView  The class should also implement SurfaceHolder.Callback SurfaceHolder.Callback ▪ an interface that will notify you with information about the underlying Surface (created, changed, or destroyed)Surface 2. Define your secondary Thread class  The thread will perform all the drawing procedures to your Canvas

3. When your SurfaceView is initialized, get the SurfaceHolder by calling getHolder()getHolder()  Instead of handling the Surface object directly, you should handle it via a SurfaceHolderSurfaceHolder 4. Notify the SurfaceHolder that you'd like to receive SurfaceHolder callbacks by calling addCallback() addCallback() 5. Override each of the SurfaceHolder.Callback methods inside your SurfaceView class.SurfaceHolder.Callback

1. Pass the SurfaceHandler to the thread 2. Retrieve the Canvas with lockCanvas()lockCanvas() 3. Do the drawing 4. Call unlockCanvasAndPost(), passing it your Canvas objectunlockCanvasAndPost()  The Surface will now draw the Canvas as you left it

 A tween animation can perform a series of simple transformations (position, size, rotation, and transparency) on the contents of a View object  A sequence of animation instructions defines the tween animation  The instructions are defined by either XML or Android code

 The animation instructions defines:  The transformations  when the transformation will occur  How long they should take to apply  Transformations can be sequential or simultaneous

 Created a sequence of different images, played in order, like a roll of film  The XML file that lists the frames that compose the animation  The XML file consists of an element as the root node and a series of child nodes that each define a frame  The frame is a drawable resource for the frame and the frame duration.  See simple animation example

 OpenGL defines a cross-platform and cross- language API for computer graphics  OpenGL ES is a limited version of OpenGL costumed for mobile phones, PDAs, video game consoles, and other embedded systems  OpenGL ES standard:

1. Create a custom View subclass. 2. Get a handle to an OpenGLContext, which provides access to Android’s OpenGL ES functionality. 3. In the View’s onDraw() method, use the handle to the GL object and then use its methods to perform any GL functions.