Legacy GM [SOLVED] Draw circle's outline with a thick outline?

F

feminist52

Guest
How can I draw a vector circle's outline?
I typed this code and it gave me a gray circle with a 1 pixel-width black outline
Code:
draw_set_circle_precision(64)
draw_set_color(c_ltgray)
draw_circle(room_width/2,room_height/2,100,0)
draw_set_color(c_black)
draw_circle(room_width/2,room_height/2,100,1)
Can I somehow draw, for example, a 7 pixel-width outline.
 
Could you draw a larger circle behind that one that is black. It would be larger by how thick you want the border to be.

(this is just theoretical, I haven't really played with drawing circles yet...).

EDIT: I am re-reading your code, sorry, I wasn't being thorough. You are drawing a second circle already.

Instead of drawing it as a border, draw it as solid and increase the size. You may also have to draw the larger circle first to keep it behind the smaller.
 
Last edited:
F

feminist52

Guest
Could you draw a larger circle behind that one that is black. It would be larger by how thick you want the border to be.

(this is just theoretical, I haven't really played with drawing circles yet...).

EDIT: I am re-reading your code, sorry, I wasn't being thorough. You are drawing a second circle already.

Instead of drawing it as a border, draw it as solid and increase the size. You may also have to draw the larger circle first to keep it behind the smaller.
DUDE!!!!!! GENIUS!!!!!! THANK YOU!!!
 
S

Sp4m

Guest
Hello! I know this is an old thread, but I've got a similar issue with a caveat.
I'm using a circle around my pawns to demonstrate energy levels (and player color).

My inner circle has a low alpha so it doesn't obscure the game.
My Outline has to be solid so players can easily read it.

My plan is to get a solid outline 4 pixels wide, by drawing 4 circle outlines. But this seems silly. Is there a better way?

draw_circle_colour(x, y, radius, c_red, c_red, true);
draw_circle_colour(x, y, radius+1, c_red, c_red, true);
draw_circle_colour(x, y, radius+2, c_red, c_red, true);
draw_circle_colour(x, y, radius+3, c_red, c_red, true);
 

Dmi7ry

Member
Hello! I know this is an old thread, but I've got a similar issue with a caveat.
I'm using a circle around my pawns to demonstrate energy levels (and player color).

My inner circle has a low alpha so it doesn't obscure the game.
My Outline has to be solid so players can easily read it.

My plan is to get a solid outline 4 pixels wide, by drawing 4 circle outlines. But this seems silly. Is there a better way?

draw_circle_colour(x, y, radius, c_red, c_red, true);
draw_circle_colour(x, y, radius+1, c_red, c_red, true);
draw_circle_colour(x, y, radius+2, c_red, c_red, true);
draw_circle_colour(x, y, radius+3, c_red, c_red, true);
It may work wrong . For example, using this code
Code:
for (var i=1; i<500; i++)
{
    draw_circle(512, 384, i, true);
}
result will be:
circles.png

As you can see, there are a lot of missed pixels.

Try this https://marketplace.yoyogames.com/assets/304/draw-circle-width
 
J

jaydee

Guest
Hello! I know this is an old thread, but I've got a similar issue with a caveat.
I'm using a circle around my pawns to demonstrate energy levels (and player color).

My inner circle has a low alpha so it doesn't obscure the game.
My Outline has to be solid so players can easily read it.

My plan is to get a solid outline 4 pixels wide, by drawing 4 circle outlines. But this seems silly. Is there a better way?

draw_circle_colour(x, y, radius, c_red, c_red, true);
draw_circle_colour(x, y, radius+1, c_red, c_red, true);
draw_circle_colour(x, y, radius+2, c_red, c_red, true);
draw_circle_colour(x, y, radius+3, c_red, c_red, true);

I'd suggest using a surface:
Code:
// Create
surf = -1;

// Draw

// Create surface
if(!surface_exists(surf))
{
  surf = surface_create(radius * 2, radius * 2);

  // Set surface target
  surface_set_target(surf);

  // Clear alpha
  draw_clear_alpha(c_black, 0);

  // Draw large circle
  draw_circle_color(radius, radius, radius, c_red, c_red, false);

  // Change blend mode
  gpu_set_blendmode(bm_subtract);

  // Remove inner section of circle
  draw_circle_color(radius, radius, radius - 4, c_white, c_white, false);

  // Reset blend mode and surface
  gpu_set_blendmode(bm_normal);
  surface_reset_target();
}

// Draw surface
draw_surface(surf, x - radius, y - radius);
As Dmi7ry pointed out, the method you're suggesting can result in a number of artifacts from missed pixels.
 
S

Sp4m

Guest
It may work wrong . For example, using this code
Code:
for (var i=1; i<500; i++)
{
    draw_circle(512, 384, i, true);
}
result will be:
View attachment 14292

As you can see, there are a lot of missed pixels.

Try this https://marketplace.yoyogames.com/assets/304/draw-circle-width
_________________________
THANKS!
I'm surprised this isn't something GMS handles on its own.

I'm still learning GMS, and (for the most part) I try to implement my own solutions rather than import assets I don't understand, that may do more than I need. But at the very least, I can review the code 'tehwave' has written to see how they solved the problem!
 

Dmi7ry

Member
I try to implement my own solutions rather than import assets I don't understand, that may do more than I need
Get the asset and look, how it done. I have not used the asset but I pretty sure this should be simple (because I did same things many times).
 
S

Sp4m

Guest
RE: Surfaces..

Thanks! There's quite a bit going on with GMS, and I'm a bit of a n00b, so there's always something new I'm learning about!

I'll look into Surfaces tonight, but at a glance, I don't see a way to set the 'depth' of a surface.

Using what I'm already familiar with, it sounds like the path of least resistance may be to create an object with a sprite with the appearance I want, and change the image_xscale and image_yscale accordingly. Is this less efficient than using draw options?

Reviewing the documentation...
https://docs.yoyogames.com/source/dadiospice/002_reference/surfaces/index.html

It sounds like a surface is a temporary canvas where draw events can be performed, and that surface can be sized and positioned as needed, which is pretty cool.

RE: Your sample code..
*Double Thanks*
I was unaware of blend modes, and had no idea that I could use them to 'subtract' sections of an image(!). That gives me some ideas about simulating damage to surfaces.
 
Top