A
A
Alexander Sustavov2016-07-18 20:55:56
Algorithms
Alexander Sustavov, 2016-07-18 20:55:56

How to draw a vector bubble?

Throw literature on vector graphics.
I want to draw an uneven circle based on control points. In principle, the algorithm should most likely be based on bezier curves, but it is not clear how to do this, I would like to read additional materials on this topic.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Makarov, 2016-07-18
@Nipheris

Before you draw an uneven circle, you need to work out for yourself the definition of an uneven circle. Personally, I have not heard of this.
Let's say that by an uneven circle you mean an ellipse. The ellipse has an equation that defines the set of points on the ellipse. Using this equation, you can determine which point belongs to the ellipse and which does not (respectively, which points should be filled with the contour color and which should not).
In practice, it is not always convenient to go through the entire set of points and check whether each of them belongs to an ellipse. It happens that it is easier to translate the equations of the curve into a parametric form, and calculate the values ​​of the points for some set of discrete values ​​of the parameter. Here is the parametric equation of the ellipse:
https://wikimedia.org/api/rest_v1/media/math/rende...
where the parameter t is the angle between the x-axis and the ray passing through the center of coordinates and some point on the ellipse (in this case, we will agree that the center of the ellipse coincides with the center of coordinates).
Thus, changing the values ​​of t from 0 to 2*PI, we get a lot of pairs (x, y) - these are exactly the points that should be painted over.
Trying to implement this idea, you will probably ask - in what step to change the parameter t. This is a good question and the answer depends on your problem and how precise you want to draw the ellipse. In addition, if you draw individual dots as described above, then even with a relatively small step, you will not get a continuous line. By reducing the parameter step, you will sooner or later achieve a continuous-looking line, but this can significantly increase the rendering time. As a simple optimization, instead of individual points, you can draw lines between two consecutive points. Then, instead of an ellipse, you will actually draw a polygon. However, as the number of points increases (i.e., with a decrease in the step of the parameter t), it will look more and more like an ellipse.
This is the simplest one you can start with.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question