samedi 2 décembre 2017

SDL2 circle like a sun

It was made in gimp

I'd like to do something like this in c++, though. I've found how to draw circle Drawing and filling a Circle

void draw_circle(SDL_Point center, int radius, SDL_Color color)
{
    SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, color.a);
    for (int w = 0; w < radius * 2; w++)
        for (int h = 0; h < radius * 2; h++)
        {
            int dx = radius - w; // horizontal offset
            int dy = radius - h; // vertical offset
            if ((dx*dx + dy*dy) <= (radius * radius))
            {
                SDL_RenderDrawPoint(renderer, center.x + dx, center.y + dy);
            }
        }
}

How could I get effect like in the photo?

Aucun commentaire:

Enregistrer un commentaire