Lecture 3: Animation & Graphics Topics: Animation, Graphics, Drawing Date: Feb 2, 2016.

Slides:



Advertisements
Similar presentations
CE881: Mobile and Social Application Programming Simon M. Lucas Menus and Dialogs.
Advertisements

1 Drawing C Sc 335 Object-Oriented Programming and Design Rick Mercer.
CS378 - Mobile Computing 2D Graphics A Crash Course in Using (Android) 2D Graphics Libraries.
Basic 2D Graphics in Android. Android Graphics Programming There are many ways to do graphics programming in Android – 2D vs. 3D – static vs. dynamic.
Graphics & Animation in Android. Android rendering options The Canvas API Renderscript OpenGL wrappers NDK OpenGL
Using Powerpoint to Create Interface Prototype Copy & Paste Interface Designs –Use Screen Capture to Copy Existing Interface –“Print Screen / SysRq” Button:
2D Graphics: Part 1. Android Graphics Libraries 2D Graphics –custom 2D graphics library in packages android.graphics android.graphics.drawable android.graphics.drawable.shapes.
Basic Animation. Animation 4 options – Animated.gif – Frame by Frame animation – Tweened animation This is our focus – OpenGL ES Graphics API for more.
Custom Views, Drawing, Styles, Themes, ViewProperties, Animations, oh my!
Basic Drawing Techniques
2D Graphics: Part 2.
Chapter 9: Customize! Navigating with Tabs on a Tablet App.
CHAPTER 4 Images XNA Game Studio 4.0. Objectives Find out how the Content Manager lets you add pictures to Microsoft XNA games. Discover how pictures.
Chapter 10: Move! Creating Animation
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.
Animation.
1/29/ Android Programming: FrameLayout By Dr. Ramji M. Makwana Professor and Head, Computer Engineering Department A.D. Patel.
SpotOn Game App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 7: Reveal! Displaying Pictures in a GridView.
Android Boot Camp for Developers Using Java, 3E
Chapter 7: Reveal! Displaying Pictures in a Gallery.
Android Graphics Library. Color Android colors are represented with four numbers, one each for alpha, red, green, and blue (ARGB). Each component can.
ANDROID – DRAWING IMAGES – SIMPLE EXAMPLE IN INTERFACE AND EVENT HANDLING L. Grewe.
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.
Mobile Programming Lecture 11 Animation and TraceView.
Basic Animation. Animation 4 options – Animated.gif – Frame by Frame animation – Tweened animation This is our focus – OpenGL ES Graphics API for more.
Web Tools Assignment This assignment requires you to build a simple HTML page with an HTML editor of your choice and use an image or drawing tool to create.
First Project: Dance Dance Sprite  Write a dance with your sprite (You pick or create the sprite)  Incorporate as many of the Motion Commands as you.
© 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.
Processing TYWu. Where can I download? 2.0b9 Windows 32-bit.
Frank Xu Gannon University. A dialog is always created and displayed as a part of an Activity. You should normally create dialogs from within.
Resources & Bitmaps Adding clip art to your application.
Mobile Computing Lecture#12 Graphics & Animation.
Lecture 2: Android Concepts
Android View Stuff. TextViews Display text Display images???
Flag Quiz Game App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
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.
By: Eliav Menachi.  Android custom 2D graphics library  OpenGL ES 1.0 for high performance 3D graphics.
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 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.
CS371m - Mobile Computing 2D Graphics A Crash Course in Using (Android) 2D Graphics Libraries.
Mobile Software Development for Android - I397 IT COLLEGE, ANDRES KÄVER, WEB:
Graphics & Animation Radan Ganchev Astea Solutions.
CHAPTER 1 part 1 Introduction. Chapter objectives: Understand Android Learn the differences between Java and Android Java Examine the Android project.
Automata Editor Tool with GEF and EMF
Android Mobile Application Development
Android Application 2D Graphics cs.
Lecture 3: Animation & Graphics
CS499 – Mobile Application Development
Lecture 3: Animation & Graphics
Lecture 8: Graphics By: Eliav Menachi.
2D Graphics: Part 2.
Android Introduction Camera.
Cosc 4735 Vector Graphics.
Image Asset Vector Asset
Mobile Computing With Android ACST 4550 Android Animation
2D Graphics A Crash Course in Using (Android) 2D Graphics Libraries
Many thanks to Jun Bum Lim for his help with this tutorial.
Graphics with Canvas.
YEAR NINE TRANSFORMATIONS
Lecture 3: Animation & Graphics
Android SDK & App Development
Emerging Platform#3 Android & Programming an App
Lecture 8: Graphics By: Eliav Menachi.
Android: Shapes.
Mobile Computing With Android ACST 4550 Android Animation
Creating a PowerPoint Presentation
Presentation transcript:

Lecture 3: Animation & Graphics Topics: Animation, Graphics, Drawing Date: Feb 2, 2016

References (study these)

Animation Overview 1.Property Animation 2.View Animation 3.Drawable Animation

1. Property Animation Changing value of a variable over a period: Use setInterpolator() to change behavior. ValueAnimator anim = ValueAnimator.ofFloat(0f, 40f); anim.setDuration(40); anim.start();

2. View Animation You can animate a View e.g., by scaling, rotating, translating an ImageView.

2. View Animation Define the Animation in XML: res/anim Use Animation to fetch it, then apply it to a View. Animation x = AnimationUtils.loadAnimation( getApplicationContext(), R.anim.abovexmlfile ); someView.startAnimation(x);

3. Drawable Animation We can load a series of Drawable resources (e.g. images) one after another.

3. Drawable Animation Define animation-list in XML: res/drawable Use AnimationDrawable inside your code someImgView.setBackgroundResource(R.drawable.abovexml); ((AnimationDrawable)someImgView.getBackground()).start();

Code Practice: Get a few images and copy: res/drawable/ Create an XML file: res/drawable/my_anim_list Add an ImageView and set Background Use AnimationDrawable to start animation

Graphics Overview Canvas and Drawables Hardware Acceleration (think GPU) OpenGL (framework API and NDK) Bitmap drawRect() drawCircle() … Canvas

2D Drawing 1.Drawable: Put Drawables (into a View) Less work, less control, less efficiency 2.Canvas: Draw on the Canvas (of a View) More work, more control, more efficiency

1. Using Drawables Putting Drawables into a View res/drawable/Queen.png Four ButtonViews res/drawable/tfade.xml

1. Using Drawables android.graphics.drawable BitmapDrawable, Transition Drawable, Animation Drawable, ShapeDrawable, etc. Two ways to add Drawables: a)Image from Project Resource b)XML file defining Drawable properties

1(a) Image from Project Resource Copy images into res/drawable/ Use it inside the layout xml You can also do the same by writing code: ImageView i = new ImageView(this); i.setImageResource(R.drawable.my_image); LinearLayout ll = new LinearLayout(this); ll.addView(i); setContentView(ll); //instead of setContentView(R.layout.somexmllayoutfile)

1(b) XML with drawable properties e.g. Transition Drawable: res/drawable/something.xml Now, take an ImageView to show it (them): TransitionDrawable td; td = (TransitionDrawable) getResources().getDrawable(R.drawable.something); td.setCrossFadeEnabled(true); ImageView img; img = (ImageView) findViewById(R.id.img1); img.setImageDrawable(td); td.startTransition(5000);

Nine Patch Image Regular.png images + defining stretchable regions From a terminal: Run the draw9patch command from your SDK sdk/tools directory to launch the tool.

2. Using Canvas (of a View) Create your own View Class (CustomView.java) Use the View in the layout xml To force a redraw: invalidate() public class CustomView extends View { //Declare all types of constructors protected void onDraw(Canvas canvas) { super.onDraw(canvas); //Use canvas.draw*() } }

Code Practice: Create 2 Buttons: Up and Down Create a Custom View Draw a circle at location (X, Y) Every time the buttons are clicked, the point will move. (Hint: use invalidate() to force redraw).