You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OpenVic's GFXPieChartTextures are generated based on the polar coordinates of each pixel relative to the texture's centre. This approach can result in sampling artefacts and messy looking slice edges, especially for very thin slices.
Solution
Instead of using polar coordinates, GFXPieChartTexture.cpp's _generate_pie_chart_image function should use a "sweeping line" approach where lines are drawn from the centre to each pixel on the outer edge of the pie chart, starting with the point directly to the right of the centre and sweeping around the whole circle anti-clockwise, choosing the colour of each line based on the polar angle of the edge point at the end the line.
The lines should be drawn using a smooth 2D line drawing function (e.g. Bresenham's Line Algorithm) and a similar smooth circle generating function should be used to to find the edge points to draw to (e.g. the Midpoint Circle Algorithm). It may be necessary to adjust the width and height of the pie chart image from their current value of 2 * radius to an odd number like 2 * radius - 1, which in turn may require offsetting the drawn pie chart image by a pixel in each axis in order to keep it aligned with the semi-transparent overlay textures covering most pie charts.
Although this still involves polar coordinates, it results in fewer sampling artefacts as the slice-edges are farther apart on the outer rim and results in cleaner edges thanks to the use of specialised smooth 2D line drawing functions.
The text was updated successfully, but these errors were encountered:
Problem
OpenVic's GFXPieChartTextures are generated based on the polar coordinates of each pixel relative to the texture's centre. This approach can result in sampling artefacts and messy looking slice edges, especially for very thin slices.
Solution
Instead of using polar coordinates, GFXPieChartTexture.cpp's
_generate_pie_chart_image
function should use a "sweeping line" approach where lines are drawn from the centre to each pixel on the outer edge of the pie chart, starting with the point directly to the right of the centre and sweeping around the whole circle anti-clockwise, choosing the colour of each line based on the polar angle of the edge point at the end the line.The lines should be drawn using a smooth 2D line drawing function (e.g. Bresenham's Line Algorithm) and a similar smooth circle generating function should be used to to find the edge points to draw to (e.g. the Midpoint Circle Algorithm). It may be necessary to adjust the width and height of the pie chart image from their current value of
2 * radius
to an odd number like2 * radius - 1
, which in turn may require offsetting the drawn pie chart image by a pixel in each axis in order to keep it aligned with the semi-transparent overlay textures covering most pie charts.Although this still involves polar coordinates, it results in fewer sampling artefacts as the slice-edges are farther apart on the outer rim and results in cleaner edges thanks to the use of specialised smooth 2D line drawing functions.
The text was updated successfully, but these errors were encountered: