Added code for drawing a circle around selected vertex
This commit is contained in:
parent
7fd7f90770
commit
d15e6590ec
|
@ -173,8 +173,6 @@ void DrawUtils::draw_text(SDL_Surface* display, string text, int x, int y,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
transpare(surface);
|
|
||||||
|
|
||||||
/* Blit the surface */
|
/* Blit the surface */
|
||||||
dest.x = (center_x ? (display->w - surface->w) / 2 : x);
|
dest.x = (center_x ? (display->w - surface->w) / 2 : x);
|
||||||
dest.y = (center_y ? (display->h - surface->h) / 2 : y);
|
dest.y = (center_y ? (display->h - surface->h) / 2 : y);
|
||||||
|
@ -184,3 +182,33 @@ void DrawUtils::draw_text(SDL_Surface* display, string text, int x, int y,
|
||||||
SDL_BlitSurface(surface, NULL, display, &dest);
|
SDL_BlitSurface(surface, NULL, display, &dest);
|
||||||
SDL_FreeSurface(surface);
|
SDL_FreeSurface(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DrawUtils::draw_circle(SDL_Surface* dest, Sint16 int_x, Sint16 int_y,
|
||||||
|
Uint16 int_r, Uint32 colour)
|
||||||
|
{
|
||||||
|
float x = static_cast<float> (int_x);
|
||||||
|
float y = static_cast<float> (int_y);
|
||||||
|
float r = static_cast<float> (int_r);
|
||||||
|
|
||||||
|
SDL_Rect pen;
|
||||||
|
float i;
|
||||||
|
|
||||||
|
for (i=0; i < 6.28318531; i += 0.0034906585)
|
||||||
|
{
|
||||||
|
pen.x = static_cast<int> (x + cos(i) * r);
|
||||||
|
pen.y = static_cast<int> (y + sin(i) * r);
|
||||||
|
int w = 2;
|
||||||
|
int h = 2;
|
||||||
|
|
||||||
|
if (pen.x >= dest->clip_rect.x &&
|
||||||
|
pen.y >= dest->clip_rect.y &&
|
||||||
|
pen.x + pen.w <= dest->clip_rect.w &&
|
||||||
|
pen.y + pen.h <= dest->clip_rect.h)
|
||||||
|
SDL_FillRect(dest, &pen,
|
||||||
|
SDL_MapRGBA(dest->format,
|
||||||
|
(colour >> 16) & 0xff,
|
||||||
|
(colour >> 8) & 0xff,
|
||||||
|
colour & 0xff, 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ class DrawUtils
|
||||||
int x2, int y2, int w, int h);
|
int x2, int y2, int w, int h);
|
||||||
|
|
||||||
static void draw_line(SDL_Surface* dest, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint16 width, Uint32 colour);
|
static void draw_line(SDL_Surface* dest, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint16 width, Uint32 colour);
|
||||||
|
static void draw_circle(SDL_Surface* dest, Sint16 x, Sint16 y, Uint16 r, Uint32 colour);
|
||||||
static void draw_circle_filled(SDL_Surface* dest, Sint16 x, Sint16 y, Uint16 r, Uint32 colour);
|
static void draw_circle_filled(SDL_Surface* dest, Sint16 x, Sint16 y, Uint16 r, Uint32 colour);
|
||||||
|
|
||||||
static void draw_text(SDL_Surface* display, string text, int x, int y,
|
static void draw_text(SDL_Surface* display, string text, int x, int y,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user