Android之Canvas

一、概述

TheCanvasclassholdsthe"draw"calls.Todrawsomething,youneed4basiccomponents:ABitmaptoholdthepixels,aCanvastohostthedrawcalls(writingintothebitmap),adrawingprimitive(e.g.Rect,Path,text,Bitmap),andapaint(todescribethecolorsandstylesforthedrawing).

Canvas类支持“draw”的调用,可以去绘制别的事物。你需要四种基本的组成成分:

(1)Bitmap(图像)

(2)Canvas(画布,主办描绘调用等,即等待绘制到bitmap中)

(3)primitive(绘制的原始事物(例如矩形、路径、文本、图像))

(4)paint(颜料,描述描绘的颜色和风格)

二、嵌套类

NestedClasses

enum

Canvas.EdgeType

enum

Canvas.VertexMode

三、常量

Constans

int

ALL_SAVE_FLAG

当restore()方法被调用时,恢复全部东西

int

CLIP_SAVE_FLAG

当restore()方法被调用时,恢复当前剪辑

int

CLIP_TO_LAYER_SAVE_FLAG

clipagainstthelayer'sbounds

剪辑对立层的边界

int

FULL_COLOR_LAYER_SAVE_FLAG

thelayerneedsto8-bitspercolorcomponent

int

HAS_ALPHA_LAYER_SAVE_FLAG

thelayerneedstoper-pixelalpha

int

MATRIX_SAVE_FLAG

restorethecurrentmatrixwhenrestore()iscalled

当调用restore()方法时,恢复现有矩阵

四、公共构造函数

PublicConstructors

Canvas()

Constructanemptyrastercanvas

Canvas(Bitmapbitmap)

Constructacanvaswiththespecifiedbitmaptodrawinto

Canvas(GLgl)

Constructacanvaswiththespecifiedglcontext

相关推荐