How to fill the Area under a Bezier curve in Android - android

I'm searching for a way of filling the Area under a cubic Bezier curve in Android. To be specific I'm trying to draw a Figure like in the Picture below in a Custom View. My idea is to draw a circle and two mirrored cubic Bezier curves and fill the area beneath them. Is there an Android built in way to archive this, or do I have to find another solution? If so can you help me find an alternative solution?
The shape I would like to draw:

What you need here is Path. More info here:http://developer.android.com/reference/android/graphics/Path.html
In your case, you need to create a Path
Move that to a point that you want via path.moveTo()
Add the first bezier curve via path.cubicTo()
Add the circle to the path via path.addCircle()
Add the second bezier curve via path.cubicTo()
Finally, close the path via path.close()
As for the fill of the path. Normally, the path is filled inside. If you are looking for something else, I suggest you play around with path.setFillType().

Related

Android draw curved path Animation on canvas

How should I do a curved path draw animation in Android canvas?
I am trying to do a curved path animation on Android on canvas. I have to draw a scooter animation like drawing itself.
Thanks in Advance!!!
Curved Path animations on Android are possible through PathInterpolator and PathInterpolatorCompat which is backward compatible, available in support library. But your question seems rather confusing to me if you want to draw a path of a scooter, then create a Path object containing the path coordinates of scooter then use Canvas.drawPath and draw that path. PathInterpolator is actually used for changing the path of animation during a translate or similar kind of animation which moves along a path. However, A better approach that I suggest is using a VectorDrawable and manipulating its trimStart and trimEnd properties to maintain how much path of scooter gets drawn.

Detect shapes and create histograms

I am working on an app that will compare histograms in hopes to match faces.
The app allows the user to take a photo, select a few key points in the image and then the app draws circles around those points. I then detect the circles using the OpenCV Hough Circle Transform functions. Up to this point the app works great.
What I need to implement now is one of two options:
Detect the circles and create separate histograms for the area inside of each circle.
Detect the circles and blackout the area(s) around the circles and create one histogram.
I'm leaning towards method 2, but I'm not sure how mask/color/paint around the area outside of the circles after they are detected. Any input would be appreciated. Thanks.
Instead of painting the area outside the circles in the original image, why not create a new image and copy the content of the circles to it?
Another point is that histograms are independent of translation. So, it does not matter if you copy the circles to the exact locations in the new image.
Do clarify if I did not answer your question, or if you have other questions now.

Draw nice curved path along points

How do I draw a path along some defined points in a way so that the path is nicely curved and not necessary exactly touching the defined points, except the end points where the line must be ending at the exact points? I have tried with quadTo, but that gives me jagged connections between the quadTo end/start in some situations.
To illustrate what I want I have attached this example image:
Thank you
Søren

I want to crop image using Bezier curve in android

How can i draw bezier curve in android , can any one suggest some references or existing source code that helps me to understand bezier curve .i want to crop image in my android app using any close path like Bezier Path. i know it is possible using rectangle but i want crop in different shape. like i make one shape using touch and want to crop that image so how it is possible. any suggestion or help. Thanks in advance.
You best bet would be to use the quadTo and cubicTo and other utility methods available in the Path class. All you have to do is determine the control points.
I have written a simple tutorial on how to use Path and PathMeasure to draw lines, curves, etc., You may find it here:
http://c05mic.wordpress.com/2012/03/23/animating-a-bitmap-using-path-and-pathmeasure-android/

Drawing curved lines in AndEngine

I am new to AndEngine and very happy that it's very easy and exciting thing to do. Unfortunately I am unable to draw a curved line in AndEngine.
Actually my scenario is that I have an animated sprite say Object. I want to move this object on a Line with the points given onToucing and dragging it. Now the problem is that I can't find any method to draw a line on points in a way that it does not produce corners. I want a smooth line with no corners.
Suppose I touch the object and drag it on the screen with the points of a square type region. But I don't want the corners in it. I want curves. Previously I am doing this by using quadTo(..) function of android to do this. All I want is a complete alternative to quadto function in AndEngine but with same functionality.
You have to stitch together the curved line from many many small straight lines.
Moving an object along a line is a very different task though. You'd want to have a look at CubicBezierMoveModifier and QuadraticBezierMoveModifier for those.
Maybe you can actually use the code in those modifiers to create your 'smooth' line.

Categories

Resources