Android Graphics Library. Color Android colors are represented with four numbers, one each for alpha, red, green, and blue (ARGB). Each component can.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Importing and Modifying Graphics
© 2010 Delmar, Cengage Learning Chapter 7: Importing and Modifying Graphics.
Noadswood Science,  To know how to use Python to produce windows and colours along with specified co-ordinates Sunday, April 12, 2015.
Bitmap Editing – Lesson 1
© 2004 Pearson Addison-Wesley. All rights reserved2-1 Introduction to Graphics The last few sections of each chapter of the textbook focus on graphics.
User Interface Programming in C#: Graphics
App Development on Android
GUI and Swing, part 2 The illustrated edition. Scroll bars As we have previously seen, a JTextArea has a fixed size, but the amount of text that can be.
Four simple expressions in meta. Data objects Pieces of data in a computer are called objects Today, we’ll talk about four kinds of objects Numbers Pictures.
©2004 Brooks/Cole Applets Graphics & GUIs. Figures ©2004 Brooks/Cole CS 119: Intro to JavaFall 2005 Graphical Programs Most applications these days are.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Topics  Applets  Classes used for graphics Graphics Point Dimension.
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.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 5 Java Graphics Applets.
Four simple expressions in meta. Data objects Pieces of data in a computer are called objects Today, we’ll talk about four kinds of objects Numbers Pictures.
Java Review Structure of a graphics program. Computer Graphics and User Interfaces Java is Object-Oriented A program uses objects to model the solution.
DIGITAL GRAPHICS & ANIMATION
2D Graphics: Part 1. Android Graphics Libraries 2D Graphics –custom 2D graphics library in packages android.graphics android.graphics.drawable android.graphics.drawable.shapes.
Graphics and Multimedia. Introduction The language contains many sophisticated drawing capabilities as part of namespace System.Drawing and the other.
V Obtained from a summer workshop in Guildford County July, 2014
Graphical images Bit-mapped (or raster-based) image: Matrix describing the individual dots that are the smallest elements (pixels) of resolution on a computer.
Chapter 3 Working with Symbols and Interactivity.
Basic Drawing Techniques
1 Interface Types & Polymorphism & introduction to graphics programming in Java.
2D Graphics: Part 2.
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.
BFTAW BDPA Workshop Introduction to GIMP Chris
BFTAW BDPA Workshop Introduction to GIMP Chris
Tutorial 6 Working with Bitmaps and Gradients, and Publishing Flash Files.
Graphics Concepts CS 2302, Fall /17/20142 Color Concepts.
CS324e - Elements of Graphics and Visualization Compositing.
Getting Started with Canvas IDIA Spring 2013 Bridget M. Blodgett.
© 2011 Delmar, Cengage Learning Chapter 3 Working with Symbols and Interactivity.
Working with Symbols and Interactivity
CSE 219 Computer Science III Images. HW1 Has been posted on Blackboard Making a Game of Life with limited options.
Chapter 2 The Android User Interface. Objectives  In this chapter, you learn to:  Develop a user interface using the TextView, ImageView, and Button.
Computer Science 112 Fundamentals of Programming II Graphics Programming.
Lecture 15: Intro to Graphics Yoni Fridman 7/25/01 7/25/01.
CSCE 121: Introduction to Program Design and Concepts Dr. J. Michael Moore Spring 2015 Set 12: A Display Model 1 Based on slides created by Bjarne.
Canvas and Graphics CS 21a. 9/26/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved L17: Canvas.
Java Graphics. Review 3 kinds of elements in components API? Layout managers Events Extend vs. Implement.
Chapter 2: Color and Applets Coming up: Introduction to Graphics.
Custom Widget 1 UNIT 26 로봇 SW 콘텐츠 교육원 조용수. 캔버스 public void drawColor(int color) 2 public class ControllerView extends View { public ControllerView(Context.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Introduction to Android (Part.
(C) 2010 Pearson Education, Inc. All rights reserved.  Class Graphics (from package java.awt) provides various methods for drawing text and shapes onto.
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.
Graphics Concepts CS 2302, Fall /17/20142 Drawing in Android.
Creating visual interfaces in python
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Review_6 AWT, Swing, ActionListener, and Graphics.
Fall UI Design and Implementation1 Lecture 6: Output.
8 Graphics Digital Media I. What is a graphic? A graphic can be a:  Chart  Drawing  Painting  Photograph  Logo  Navigation button  Diagram.
1 Introduction to Graphics b The last one or two sections of each chapter of the textbook focus on graphical issues b Most computer programs have graphical.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
1 Drawing C Sc 335 Object-Oriented Programming and Design Rick Mercer.
Basic 2D Graphics in Android. Android Graphics Programming There are many ways to do graphics programming in Android – 2D vs. 3D – static vs. dynamic.
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.
Android Application 2D Graphics cs.
Lecture 3: Animation & Graphics
CS499 – Mobile Application Development
Lecture 3: Animation & Graphics
Flash Interface, Commands and Functions
2D Graphics: Part 2.
Graphics and Multimedia
Java Graphics The basic rendering mechanism is the drawing system that controls when and how programs can draw on a graphics component. When a component.
GUI Graphics Chris North cs3724: HCI.
Graphics with Canvas.
CIS 470 Mobile App Development
Presentation transcript:

Android Graphics Library

Color Android colors are represented with four numbers, one each for alpha, red, green, and blue (ARGB). Each component can have 256 possible values, or 8 bits, so a color is typically packed into a 32-bit integer. For efficiency, Android code uses an integer instead of an instance of the Color class. int color = Color.BLUE; // solid blue // Translucent purple color = Color.argb(127, 255, 0, 255); #7fff00ff color = getResources().getColor(R.color.mycolor);

Paint One of the Android native graphics library’s most important classes is the Paint class. It holds the style, color, and other information needed to draw any graphics including bitmaps, text, and geometric shapes. cPaint.setColor(Color.LTGRAY);

Canvas The Canvas class represents a surface on which you draw. Initially canvases start off devoid of any content, like blank transparencies for an overhead projector. Methods on the Canvas class let you draw lines, rectangles, circles, or other arbitrary graphics on the surface. In Android, the display screen is taken up by an Activity, which hosts a View, which in turn hosts a Canvas. You get an opportunity to draw on that canvas by overriding the View.onDraw( ) method. The only parameter to onDraw( ) is a canvas on which you can draw. Here’s an example activity called Graphics, which contains a view called GraphicsView: public class Graphics extends Activity public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new GraphicsView(this)); } static public class GraphicsView extends View { public GraphicsView(Context context) { super(context); protected void onDraw(Canvas canvas) { // Drawing commands go here }

Path The Path class holds a set of vector-drawing commands such as lines, rectangles, and curves. Here’s an example that defines a circular path: circle = new Path(); circle.addCircle(150, 150, 100, Direction.CW); private static final String QUOTE = "Now is the time for all " + "good men to come to the aid of their country."; canvas.drawPath(circle, cPaint); canvas.drawTextOnPath(QUOTE, circle, 0, 20, tPaint); This defines a circle at position x=150, y=150, with a radius of 100 pixels. Now that we’ve defined the path, let’s use it to draw the circle’s outline plus some text around the inside:

Drawable In Android, a Drawable class is used for a visual element like a bitmap or solid color that is intended for display only. You can combine drawables with other graphics, or you can use them in user interface widgets (for example, as the background for a button or view). Drawables can take a variety of forms: Bitmap: A PNG or JPEG image. NinePatch: A stretchable PNG image, so named because originally it divided the image into nine sections. These are used for the background of resizable bitmap buttons. Shape: Vector-drawing commands, based on Path. Layers: A container for child drawables that draw on top of each other in a certain z-order. States: A container that shows one of its child drawables based on its state (a bit mask). One use is to set various selection and focus states for buttons. Levels: A container that shows only one of its child drawables based on its level (a range of integers). This could be used for a battery or signal strength gauge. Scale: A container for one child drawable that modifies its size based on the current level. One use might be a zoomable picture viewer.