# How to draw the path with a thicker stroke?

I have a game where objects follow a path that resembles a circuit (f1, nascar, stock car).

Using the draw_path function, I can draw the circuit on the game screen: It turns out that dash got too thin.

To thicken the drawing line and actually look like a circuit (so I don't have to sprite and put in the background) I tried the following (Draw Event):

draw_path(circuito_ovo,500,50,false);
draw_path(circuito_ovo,501,51,false);
draw_path(circuito_ovo,502,52,false);
draw_path(circuito_ovo,503,53,false);
draw_path(circuito_ovo,504,54,false);
draw_path(circuito_ovo,505,55,false);
draw_path(circuito_ovo,506,56,false);


The result was not as expected (detail I added a unit in two dimensions, I thought the secret would be this): • I just found a possible solution, anyway any help is valid. Sep 30 '19 at 23:49
• Did your possible solution helped you out? If so, would you mind telling it as an answer? Oct 1 '19 at 6:56
• Did you try drawing rectangles instead? Also as @Steven noted, if your problem is resolved, make sure to put an answer explaining how you solved it. There are other readers that might have the same problem as you, and would love to know what your solution was :) Oct 1 '19 at 8:39
• I was optimizing the solution I found, I just added an answer. Oct 3 '19 at 0:52

This will draw a red diagonal line, 6 pixels wide, from point (100,100) to point (200,200).

draw_set_colour(c_red);
draw_line_width(100, 100, 200, 200, 6);


I can foresee you will have corner issues as the adjoining lines corner won't meet up. It will become more obvious as you thicken the lines and the two angles are extreme.

That is more tricky to solve given you need to work out the corners for each line taking thickness into account and join those with the previous line corners. Quite a bit of maths and code involving atan2, cos and sin is required to make this work correctly.

• Search for "graphic gems 1" and open link to pdf - jump to page 108 - the diagram on that page will show you what you will be faced with when doing it this way.
– John
Oct 2 '19 at 3:12

Adding 1 to each dimension just isn't enough.

It would have to be something like:

draw_path(circuito_ovo,500,50,false);
draw_path(circuito_ovo,500,51,false);
draw_path(circuito_ovo,500,52,false);

draw_path(circuito_ovo,501,50,false);
draw_path(circuito_ovo,501,51,false);
draw_path(circuito_ovo,501,52,false);

draw_path(circuito_ovo,502,50,false);
draw_path(circuito_ovo,502,51,false);
draw_path(circuito_ovo,502,52,false);


For ease just use the repeat function (Draw Event):

repeat(5){
repeat(5){
draw_path(circuito_ovo,500+i,50+j,false);
j+=1;
}
i+=1;
j=0;
}

i=0;
j=0;


Initializing the variables with the value 0 (i and j), or negative (if I want the object to be walked exactly in the center of the drawing).

The number of times the repeat function will execute will be equal to the line thickness.

Result: 