Draw Multiple Paths on Canvas Android -
i have 1 class named myview extends view..in options menu have 4 types of color.
what want when select greenish , draw path on canvas should draw greenish path , when select reddish should draw reddish path , previous greenish should ...
i got success in drawing multiple paths of various colors @ 1 time 1 color holding in canvas .. can draw multiple color of paths on canvas ??
the way i've done store color along path subclassing path:
private class drawingpath extends path { public drawingpath(float w, int c) { width = w; color = c; } public float width; public int color; }
then when draw each of paths have set color beforehand.
as can see can set width code can alter stroke width each path.
to draw used:
mcanvas.drawcolor(color.white); (drawingpath p : mpaths) { mpaint.setcolor(p.color); mpaint.setstrokewidth(p.width); mcanvas.drawpath(p, mpaint); } invalidate();
android canvas paint
No comments:
Post a Comment