[NEW] GRRLIB_Circle function by Dark-Link

This commit is contained in:
Crayon2000 2009-02-28 03:57:19 +00:00
parent 971bc0f9b5
commit f3a8825d21
4 changed files with 34 additions and 2 deletions

View file

@ -9,6 +9,7 @@
#include <malloc.h> #include <malloc.h>
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
#include <math.h>
#include "../lib/libpng/pngu/pngu.h" #include "../lib/libpng/pngu/pngu.h"
#include "../lib/libjpeg/jpeglib.h" #include "../lib/libjpeg/jpeglib.h"
#include "GRRLIB.h" #include "GRRLIB.h"
@ -90,6 +91,37 @@ inline void GRRLIB_Rectangle(f32 x, f32 y, f32 width, f32 height, u32 color, u8
} }
} }
/**
* Draw a circle.
* @author Dark-Link
* @param x.
* @param y.
* @param radius the radius of the circle.
* @param color the color of the circle in RGBA format.
* @param filled true to fill the circle with a color.
*/
inline void GRRLIB_Circle(f32 x, f32 y, f32 radius, u32 color, u8 filled) {
Vector v[36];
u32 a;
f32 ra;
f32 G_DTOR = M_DTOR * 10;
for (a = 0; a < 36; a++) {
ra = a * G_DTOR;
v[a].x = cos(ra) * radius + x;
v[a].y = sin(ra) * radius + y;
v[a].z = 0.0f;
}
if (!filled) {
GRRLIB_GXEngine(v, color, 36, GX_LINESTRIP);
}
else {
GRRLIB_GXEngine(v, color, 36, GX_TRIANGLEFAN);
}
}
/** /**
* Draw a polygon. * Draw a polygon.
* @param v * @param v

View file

@ -69,6 +69,7 @@ void GRRLIB_NPlot(Vector v[], u32 color, long n);
inline void GRRLIB_Line(f32 x1, f32 y1, f32 x2, f32 y2, u32 color); inline void GRRLIB_Line(f32 x1, f32 y1, f32 x2, f32 y2, u32 color);
inline void GRRLIB_Rectangle(f32 x, f32 y, f32 width, f32 height, u32 color, u8 filled); inline void GRRLIB_Rectangle(f32 x, f32 y, f32 width, f32 height, u32 color, u8 filled);
inline void GRRLIB_Circle(f32 x, f32 y, f32 radius, u32 color, u8 filled);
void GRRLIB_NGone(Vector v[], u32 color, long n); void GRRLIB_NGone(Vector v[], u32 color, long n);
void GRRLIB_NGoneFilled(Vector v[], u32 color, long n); void GRRLIB_NGoneFilled(Vector v[], u32 color, long n);

View file

@ -147,6 +147,7 @@ int main() {
GRRLIB_Line(100, 100, 350, 200, GRRLIB_SILVER); GRRLIB_Line(100, 100, 350, 200, GRRLIB_SILVER);
GRRLIB_NGoneFilled(triangle, GRRLIB_GRAY, 3); GRRLIB_NGoneFilled(triangle, GRRLIB_GRAY, 3);
GRRLIB_Rectangle(left + 150, top + 150, 200, 200, 0x0000FFC8, 1); // Blue with alpha GRRLIB_Rectangle(left + 150, top + 150, 200, 200, 0x0000FFC8, 1); // Blue with alpha
GRRLIB_Circle(left + 300, top + 300, 50, GRRLIB_OLIVE, 1);
// Draw a yellow four pixel dot where the wiimote is pointing // Draw a yellow four pixel dot where the wiimote is pointing
GRRLIB_Plot(ir1.sx, ir1.sy, GRRLIB_YELLOW); GRRLIB_Plot(ir1.sx, ir1.sy, GRRLIB_YELLOW);

View file

@ -24,8 +24,6 @@ ChangeLog :
* Color format change for ALL GRRLib function (now its RGBA) to fit to GX_Color format and use GX_Color1u32 * Color format change for ALL GRRLib function (now its RGBA) to fit to GX_Color format and use GX_Color1u32
* Name Change GRRLIB_LoadTexture to GRRLIB_LoadTexturePNG
* GRRLib introduce a new texture structure (easier to handle texture width, height, etc ...): * GRRLib introduce a new texture structure (easier to handle texture width, height, etc ...):
typedef struct GRRLIB_texImg{ typedef struct GRRLIB_texImg{
unsigned int w; unsigned int w;