Draw smooth transparent line - android

I am trying to draw smooth line following my finger. The problem is in superposition. Left example is array of drawLine, and right is drawPath. Is it way to make it like smooth left example?

Construct the line as a solid color, then wrap that line inside of a drawable. Turn this drawable transparent, and then draw it to the screen.

Related

How would you do this in canvas drawing

How would you draw something like this programmatically in a ondraw method? I know how to draw lines or squares, but to have an image inside a squarebox that has an arrow, is kind of confusing for me
Thank you
Just break the drawing up in different elements:
a gray box
a white rounded rectangle
a white rectangle
a blue rectangle
a blue rounded rectangle
a blue triangle
a red heart (I would just try to find a font with a nice heart)
the text in white.
Draw it all to the canvas in this order and you are fine.

how create circle drawables like below

I would like to create drawables like the following so that I can adjust the colour at run time.
I can easily create the drawable with a stroke around a colour but all it does is create the line on the edge of the circle, but I need to have the white line on the inside with the same colour as the center on the outside?
Anyone have any ideas?
Thanks
I think this is what you are looking for.
You basically override the onDraw method of your view and call drawCircle(x, y, radius, paint) with the parameters on the link.

How to draw a curved arrow in canvas android

I have this code to draw the arrow tail line between 2 point but how should I draw curved line for arrow tail?
canvas.drawLine(pt1[X], pt1[Y], pt2[X], pt2[Y], paint);//draw line
I want to have something like this, whereby the arrow is dynamic
Depending on what shape you want for the curved line, you could perhaps use Canvas.drawArc(), but that is restricted to sections of an oval aligned with the screen axes.
For a more general approach, define your curved line as a Path and then use Canvas.drawPath() to render it to the canvas. A Path can be composed of an arbitrary number of straight line, quadratic curve, and cubic curve segments. (See the docs for how to construct the Path that you want.) For a solid arrow tail, you should set the paint's style to FILL when calling drawPath().

Animating Draw Programmatically

My app teaches how to write letters and I want to draw for example letter "A" programmatically.
I do not want to draw it pixel by pixel(it is so hard!)
What other ways to do that?
UPDATE:
I want to show how to write "A" not just showing A in the screen
Romain Guy recently wrote a blog post on how to do path tracing using paths. If you can construct paths yourself (or finding a method for creating correct paths for letters) you could use the information from his blog to do something.
http://www.curious-creature.org/2013/12/21/android-recipe-4-path-tracing/#more-1904
Good luck
if you are using Canvas, you can draw text on canvas using this:
canvas.drawText("A",marginFromLeft,MarginFromRight, paint);
also you can draw bitmap of A on canvas using this:
canvas.drawBitmap(bmp,marginLeft,marginTop, paint);
after drawing this,you can animate an other image like circle using animationSet:
anim One: animate circle moving from bottom left to top center of A
anim Two: animate circle moving from top center of A to bottom left Right
anim Three: animate circle moving from left-verticaly-center to right-verticaly-center.

Android, canvas: How can I draw transparent circle without overprinting?

Stage 1. I have a background
Stage 2. I apply an overlay to background with a canvas to draw. First I fill the whole area with canvas.drawColor(Color.argb(128,0,0,0))
Then I need to draw a red transparent circle with color.argb(128,255,0,0) at a specified place, but I want circle red transparency replaced black filling transparency, not added. So, I wanna get this
but NOT this
How can I get it?
You can try to use Canvas.clipPath before filling area with black color to exclude area, which will be used later by circle.

Categories

Resources