Legacy GM Pixelated circles?

S

Spooticus

Guest
I am wondering how to create pixelated circles using draw_circle(); and possibly surfaces. I've never really used surfaces or had a reason to so i would like to know if i can use them in conjunction with the built in circle function to make crisp dynamic pixel art circles, or if i would have to create a whole new function.

thanks! :)
 

Bayesian

Member
I don't see any questions here... If you don't know how to do something, watch a tutorial. If you run into errors or other problems ask specific questions here on the forum.
 

TsukaYuriko

☄️
Forum Staff
Moderator
I don't see any questions here... If you don't know how to do something, watch a tutorial. If you run into errors or other problems ask specific questions here on the forum.
This is contradictory to this community's spirit. Keep in mind that there may not always be a tutorial ready for any given subject. Surely doing personal research and consulting learning resources is always a good first step, but there is nothing wrong with asking for help finding an approach for how to do something.

"how to create pixelated circles using draw_circle();" seems like a specific enough question to me, although lacking a question mark and a more detailed description of the subject of the question...
 
When you draw a circle there is a command that sets how defined it is. The higher the definition, the more points it is drawing of the circles circumference, and that is why they look more rounded. Set this to low and it will appear pixelly.

draw_set_circle_precision(precision) is the function you want to look at.
 
When you draw a circle there is a command that sets how defined it is. The higher the definition, the more points it is drawing of the circles circumference, and that is why they look more rounded. Set this to low and it will appear pixelly.

draw_set_circle_precision(precision) is the function you want to look at.
That's probably not what he's looking for. I mean all that does it make it more n-"ogon". Like a hexagon doesn't look pixelated.

Easiest way to do it is to draw it to a low res surface first, then draw that surface. I'd recommend researching surfaces first.
 

Bayesian

Member
I am wondering how to create pixelated circles using draw_circle(); and possibly surfaces. I've never really used surfaces or had a reason to so i would like to know if i can use them in conjunction with the built in circle function to make crisp dynamic pixel art circles, or if i would have to create a whole new function.

thanks! :)
oCircle:
Create:
Code:
circleReal = 20;
circleScale = 4;

circleActual = circleReal / circleScale;
surfScale = circleReal * circleScale;

surf = surface_create(circleReal,circleReal);
  • "circleReal" is the real size of the circle on the screen(in radius)
  • "circleScale" is basicly how pixelated it is(Note you can only change circleReal in increments/decrements of 1/2 of circleScale otherwise you''ll get cropped or uneven circles)
  • "circleActual" is the size we draw to the surface
  • "surfScale" is the new dimensions of our stretched surface
  • Then we create a surface called "surf"

Draw:
Code:
if !(surface_exists(surf)){
    surf = surface_create(circleReal,circleReal)
}else{
    surface_set_target(surf);
    draw_clear_alpha(c_white, 0);
    draw_circle(circleActual,circleActual,circleActual,false);
    surface_reset_target();
    draw_surface_stretched(surf,x-circleReal,y-circleReal,surfScale,surfScale)
}
  • Surfaces can get deleted sometimes so we always check if they exist before manipulating them
  • In this case if the surface does NOT exists we just create it again.
  • In the else condition we know our surface exists so we manipulate it
  • By default GM draws to the "Application surface" so we need to change drawing targets to our surface called "surf"
  • Surfaces keep what's ever on them, so draw_clear_alpha manually clears the whole surface with the color white but 0 transparency; a blank image.
  • Surfaces also start at 0,0 x,y so we draw the circle to the center of the surface's current position, with a size of circleActual set to false(fill, not outline)
  • Now that we're done drawing to our surface we reset the drawing target back to the application surface.
  • Finally we draw the surface called "surf" the the center of our objects x,y stretched to the dimensions "surfScale"
 
Top