[Android] Zhaohuaxishi Custom View chapter of the (two) Canvas common technique

 

Foreword

       View the article about the drawing process had talked about in the last step is to draw the process, in this process, the child needs to be rewritten view onDraw way to draw their own content. When the Custom View to draw their own content, the system provides three important classes to help developers draw all kinds of cool graphics: Canvas, Paint, Path. This part describes the Canvas relevant content, some of the more popular and useful features presentations related to carding Canvas, Paint and Path alone in the back will do introduction.

 

First, the beginning of everything

        Following code shows a very simple example of a custom view drawing of graphics, draw a circle, we found very easy to use custom drawing. Canvas parameters onDraw method here is the protagonist Benpian, the Chinese meaning "canvas", meaning that all the contents of "painting" is done on this canvas.

1 Paint paint = new Paint();
2 @Override
3 protected void onDraw(Canvas canvas) {
4 super.onDraw(canvas);
5 // 绘制一个圆
6 canvas.drawCircle(300, 300, 200, paint);
7 }

 

Two, Canvas basic draw function

 

Three, Canvas implement cutting

 

Four, Canvas achieve geometric transformation

Guess you like

Origin www.cnblogs.com/andy-songwei/p/10958677.html