Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draw dashed line #2337

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
enforced odd number of segments so beginning and end are both visible…
… segments
  • Loading branch information
oddbookworm committed Jul 23, 2023
commit 65fae4eb8a6eaf75219db66c9d3b43caaeb9ba9d
4 changes: 4 additions & 0 deletions src_c/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ dashed_line(PyObject *self, PyObject *args, PyObject *kwargs)
int dy = endy - starty;
double total_line_length = sqrt(dx * dx + dy * dy);
int number_segments = (int)total_line_length / length;
if (!(number_segments % 2))
{
number_segments++;
}
double xstep = (double)dx / number_segments;
double ystep = (double)dy / number_segments;

Expand Down