Replaced move_template with procedural circle primitive - but it won't fill or alphatize yet.
This commit is contained in:
parent
ecb16a4b5c
commit
b5e385586d
|
@ -89,6 +89,39 @@ void DrawUtils::draw_line(SDL_Surface* dest, Sint16 x1, Sint16 y1, Sint16 x2, Si
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DrawUtils::draw_circle_filled(SDL_Surface* dest, Sint16 int_x, Sint16 int_y, Uint16 int_r, Uint32 colour, Uint8 alpha)
|
||||||
|
{
|
||||||
|
float x = static_cast<float> (int_x);
|
||||||
|
float y = static_cast<float> (int_y);
|
||||||
|
float r = static_cast<float> (int_r);
|
||||||
|
|
||||||
|
SDL_Rect pen;
|
||||||
|
pen.w = 2;
|
||||||
|
pen.h = 2;
|
||||||
|
|
||||||
|
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);
|
||||||
|
// pen.w = static_cast<int> (2 + cos(i) * r);
|
||||||
|
// pen.h = static_cast<int> (2 + sin(i) * r);
|
||||||
|
|
||||||
|
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, alpha));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool DrawUtils::transpare(SDL_Surface* surface, int r, int g, int b)
|
bool DrawUtils::transpare(SDL_Surface* surface, int r, int g, int b)
|
||||||
{
|
{
|
||||||
if (surface == NULL) return false;
|
if (surface == NULL) return false;
|
||||||
|
|
|
@ -18,6 +18,7 @@ class DrawUtils
|
||||||
static bool draw(SDL_Surface* dest, SDL_Surface* drawable, int x, int y,
|
static bool draw(SDL_Surface* dest, SDL_Surface* drawable, int x, int y,
|
||||||
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_filled(SDL_Surface* dest, Sint16 x, Sint16 y, Uint16 r, Uint32 colour, Uint8 alpha = 255);
|
||||||
|
|
||||||
// transpare (v) - to make transparent
|
// transpare (v) - to make transparent
|
||||||
static bool transpare(SDL_Surface* surface, int r, int g, int b);
|
static bool transpare(SDL_Surface* surface, int r, int g, int b);
|
||||||
|
|
|
@ -91,9 +91,8 @@ void GameCore::render()
|
||||||
if (graph.get_current_vertex() != NULL)
|
if (graph.get_current_vertex() != NULL)
|
||||||
{
|
{
|
||||||
Vertex* v = graph.get_current_vertex();
|
Vertex* v = graph.get_current_vertex();
|
||||||
DrawUtils::draw(display, move_template,
|
DrawUtils::draw_circle_filled(display, v->x, v->y,
|
||||||
v->x - Graph::MAX_MOVE_DISTANCE,
|
Graph::MAX_MOVE_DISTANCE, 0xcb1919, 128);
|
||||||
v->y - Graph::MAX_MOVE_DISTANCE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user