Hi,
I’m trying to animate a dashed line kind of like an ant trail. So I’ve got a line with two endpoints and the dashes should move in one direction. I got this working but I hit an assertion in Graphics::drawDashedLine() that reminds me not to have zero length dashes. But I think I need zero length dashes for this. Here’s what I do to calculate the dash lengths:
float progress = getProgress() * 2; // getProgress return a value from 0 to 1
float dashLength = 5;
float dl1, dl2, dl3, dl4;
if(progress < 1.f) {
dl1 = 0;
dl2 = progress * dashLength;
dl3 = dashLength;
dl4 = (1.f - progress) * dashLength;
} else {
progress = progress - 1.f;
dl1 = progress * dashLength;
dl2 = dashLength;
dl3 = (1.f - progress) * dashLength;
dl4 = 0;
}
std::array<float, 4> dashLengths { dl1, dl2, dl3, dl4 };
Has anybody got an idea what’s the best way of doing this? Or is it maybe possible to change the assertion to check if all dashes have zero length?
Easiest way would be to have an offset for the dashes, but I guess that would mess up the api.
