- Edited
I am currently using gdextension with Godot 4.3-stable
I am basically making a simple 2D graph which plots data (Vector2 type) but I have been getting a weird issue with the line width when populating my data with draw_polyline
compared to draw_line
Essentially, my draw_plot
function is just the following:
void Graph_2D::_draw_plot() {
// Ensure the range in the display frame is within range
_data1.set_range();
if (_data1.packed_v2_data.is_empty()) {
return;
}
PackedVector2Array data = _coordinate_to_pixel(_data1.packed_v2_data);
// Enable anti-aliasing for better resolution
draw_polyline(data, _data1.color, _data1.width, true);
for (size_t i = 0; i < data.size(); i++) {
draw_circle(data[i], 5.0, _data1.color);
}
}
with the following implementation, I am getting the following output:
You can see how some of the line width are not constant, but as soon as I change the same data to use draw_line
, it is a lot better (see below for the necessary changes). Here is the output of the following changes.
// Swap draw_polyline with this line of code
for (size_t i = 0; i < data.size() - 1; i++) {
draw_line(data[i], data[i + 1], _data1.color, _data1.width, true);
}
I was wondering if I am doing something wrong here, or there may be some parameters that I am not aware of. Any help would be much appreciated.