The graphics engines commonly used to draw vector graphics apply the antialiasing technique known as Pixel Coverage.
The quality of the results could be greatly improved through the application of Sampling Theory.
~
VULETICH, Juan, 2013. Prefiltering Antialiasing for General Vector Graphics. researchgate , page , pdf
The main parts of the disclosed solution are:
a) The outline of the Shape to be drawn. This is a description of how a Pen should be dragged over a piece of Paper, in order to draw it. It is specified as a sequence of straight lines or curves. It also includes a line width w (a real number) and a color. All points (segment endpoints, center and radius for circles, control points for Bézier curves, etc.) use real numbers too. This Model of the drawing to be made is continuous and independent of any specific pixel grid.
[…] Figure 1. The outline of a sample shape, and the opacity function (i.e. the pen nib of width w) to draw it. The pen nib is completely opaque, and therefore paints over any existing background. We can say that the pen function is transparent everywhere outside the nib, as those areas won’t be affected at all. The dashed line is the path followed by the pen.
b) The destination frame buffer where the drawing is to be done. This is usually 24 bit RGB, or as appropriate for the application. The destination specifies the pixel grid that the shape must be sampled at.
[…] Figure 2. Destination frame buffer and pixel Grid for the rasterization of our example
~
kohonen-stars github is an example for our library kohonen github , a basic implementation of SOM algorithm in JavaScript.
~
c) A filter size parameter r. In the following diagrams, we’ll assume r = 1.5. This means that the transition from transparent to opaque will take at least 1.5 pixels. Other values are possible, and useful values were found to be between 1 (very crisp, some jaggies are visible) to 2 (very soft, absolutely no jaggies or aliasing).
d) A prefiltering pen. It is a pen with an opaque center and translucent borders. The area under the opacity function is the same as in (a) and equals w, meaning that the weight of the line will not change. But the transition from transparent to opaque is gradual, leading to a translucent stripe of width r at each border of the line drawn by the pen.
[…] Figure 3. Opacity function of our prefiltering pen, and our example shape as drawn by it. Translucent parts of the pen will mean that the existing background is somewhat visible behind the outline.
e) An auxiliary distance buffer, with the same extent as the destination. It needs to store for each pixel in the destination, a float number, or alternately a fixed point number.
[…] Figure 4. Our sample shape, as drawn by an ideal continuous prefiltering pen, shown over the pixel grid. The light gray background is more visible near the borders of the outline, where the pen gets progressively translucent.