Draw a dashed path

Creating a dashed path for the pathfinder behavior is incredibly simple but making it seamless is hurting by brain.

Here is the non-seamless approach using the new local loop counter variables.

Some of the events are just my first attempt at making it seamless.

The result.

The challenge is the seamless part. Segments are rarely exactly even dashes. There needs to be a way to create partial dashes at the end and the beginning.

I’m torn between tweaking my current method or switching to a single while event with a variable for distance and a node counter.

I’ll eventually complete it. I just need to be in the right mood. I should probably create a flowchart to better organize the concept.

1 Like

Have you tried using the Path line action instead?

No. Is that more based on relative coordinates from the previous point? You just use the X, Y to the next point.

It would probably be easier to just modify the angle but inatill would need to handle connections. Either seperatly or as a double lined angle.

I need to write or draw it out to get a better grasp.

Now I’m thinking it might be easier to add the connections as a seperate step. Much easier. The start of the dashes would still need an offset.

I might eventually merge it into a single process but I think splitting the actions will help me better understand it. It’ll keep the code minimal.

I decided to swith to a while event. I also added a mode boolean variable (AddDash) to switch between adding a dash and adding a gap.

I love the new loop index. I used it to add a failsafe so I didn’t accidentally create an infinite loop with the while event. It exits the loop after either a success or 50 loops.

For testing, I decide to start with a single line going from a start to an end object. It’ll be easy to switch to pathfinding. I should be able to use the else events to draw the other half of a dash or advance the current x, y for the gaps and switch to the next node.

Result

I’m getting pretty close. I still need to handle partial leftover lines.

I added the pathfinder. Instead of a seperate event for dashes and gaps, I created arrays that hold the respective lengths and thickness.

I think the last line should be Node count - 1 but it doesn’t really matter bc the while event should end before Node is that value.

Output

1 Like

It probably needs testing and some safety checks but it seems like what I wanted. The Loop counter failsafe could probably be increased or removed after more testing.

Result

If it was an array of structures it would probably be easier plus it could be modified to add more line types like alternating small and long dashes.