I am working on a Custom View that implements Catch application like Circular Menu. After spending a lot of time, I have made a bit of progress, completed outer semi-circle with multile colors. Now, reading an answer provided by developer of Catch application to an user for his query, I came across the class Path. Google Android Developer page does not provides enough material to be understood and to be familiar with Path. so, Please ? Anyone ?
Thanks in advance.
The Path class encapsulates compound (multiple contour) geometric paths consisting of straight line segments, quadratic curves, and cubic curves. It can be drawn with canvas.
The Canvas class holds the "draw" calls. To draw something, you need 4 basic components: A Bitmap to hold the pixels, a Canvas to host the draw calls (writing into the bitmap), a drawing primitive (e.g. Rect, Path, text, Bitmap), and a paint (to describe the colors and styles for the drawing).
Use the Canvas method public void drawBitmap (Bitmap bitmap, Rect src, RectF dst, Paint paint) . Set dst to the size of the rectangle you want the entire image to be scaled into. EDIT: Here's a possible implementation for drawing the bitmaps in squares across on the canvas.
You can use it to draw lines on a canvas. A path is basically a collection of lines. You can use it to create shapes that are not standard. E.g. there a lots of functions to create some default shapes:
canvas.drawRect();
canvas.drawArc(RectF oval, float startAngle, float sweepAngle, boolean useCenter, Paint paint);
canvas.drawCircle(float cx, float cy, float radius, Paint paint);
canvas.drawLine(float startX, float startY, float stopX, float stopY, Paint paint);
canvas.drawOval(RectF oval, Paint paint);
canvas.drawRect(float left, float top, float right, float bottom, Paint paint);
But if you want something custom, you can create a path, and by calling
// Set the beginning of the next contour to the point (x,y).
void moveTo(float x, float y)
// Add a line from the last point to the specified point (x,y).
void lineTo(float x, float y)
You have control of the pencil that draws the lines of your path. Here's a nice tutorial
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With