1 / 4

Graphics in Android

Graphics in Android. Canvas. Class android.graphics.Canvas represents a surface on which to draw Some of the useful drawing methods drawArc draws an arc of a circle. Can be used for 'pie segments' as well. drawBitmap draws an image represented as a bitmap drawCircle drawOval

hallie
Download Presentation

Graphics in Android

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Graphics in Android Fall 2012 CS2302: Programming Principles

  2. Canvas • Class android.graphics.Canvas represents a surface on which to draw • Some of the useful drawing methods • drawArc draws an arc of a circle. Can be used for 'pie segments' as well. • drawBitmap draws an image represented as a bitmap • drawCircle • drawOval • drawRect • drawText • drawColor fills the background of the canvas with a color Fall 2012 CS2302: Programming Principles

  3. Path • A Pathcan, for example, be used to build up a polygon. • A path is understood as being drawn by a pen. When the pen is touching the drawing surface, a visible trace is left. However, the pen can also be moved without leaving a visible mark. • At any stage during the construction of a path, there is a current point. This is the current position of the pen. • The lineTo moves the pen to a new point, drawing a straight line from the previous current point to the point given by the parameters to the method call. The end point of the line becomes the new current point. • By contrast, the moveTo method moves the pen, changing the current point, but does not leave a trace. The path should begin with a moveTo call so that the path can start at a well determined position. • The close adds a line segment from the current point back to the first point on the path. This signals that the path is closed and, therefore, can be filled with color. Fall 2012 CS2302: Programming Principles

  4. Paint • In Android, the android.graphics.Paintclass is used to contain many details of how drawing should be done. Most drawing methods require a Paint object be provided as an argument. • The color of the drawing is one property. • The style property is specified by a value of class Paint.Style. The three values specify whether the shape is to be outlined, filled or both filled and outlined. Fall 2012 CS2302: Programming Principles

More Related