You are not logged in.

#1 2009-09-04 21:08:38

elisherer
Member

GRRLIB_Ellipse

Code:

/**
 * Draw a circle.
 * @author Dark_Link
 * @param x Specifies the x-coordinate of the circle.
 * @param y Specifies the y-coordinate of the circle.
 * @param radius The radius of the circle.
 * @param color The color of the circle in RGBA format.
 * @param filled Set to true to fill the circle.
 */
void  GRRLIB_Circle (const f32 x,  const f32 y,  const f32 radius,
                     const u32 color, const u8 filled) {
    GRRLIB_Ellipse (x, y, radius, radius,color, filled);
}

/**
 * Draw an ellipse.
 * @author Dark_Link (edited by elisherer)
 * @param x Specifies the x-coordinate of the circle.
 * @param y Specifies the y-coordinate of the circle.
 * @param radiusx The x radius of the circle.
 * @param radiusy The y radius of the circle.
 * @param color The color of the circle in RGBA format.
 * @param filled Set to true to fill the circle.
 */

void  GRRLIB_Ellipse (const f32 x,  const f32 y,  const f32 radiusx, const f32 radiusy,
                     const u32 color, const u8 filled) {
    guVector v[36];
    u32 ncolor[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) * radiusx + x;
        v[a].y = sin(ra) * radiusy + y;
        v[a].z = 0.0f;
        ncolor[a] = color;
    }

    if (!filled)  GRRLIB_GXEngine(v, ncolor, 36, GX_LINESTRIP  ) ;
    else          GRRLIB_GXEngine(v, ncolor, 36, GX_TRIANGLEFAN) ;
}

not much of a change just adding another way of creativity

and without adding a lot of code by using the ellipse in the circle function! smile

hope you'de like

Offline

 

#2 2009-09-10 19:09:25

elisherer
Member

Re: GRRLIB_Ellipse

We need to add these functions:

Code:

GRRLIB_Arc(const f32 x, const f32 y, const f32 xradius, const f32 yradius, const f32 stangle, const f32 endangle)
GRRLIB_Sector(const f32 x, const f32 y, const f32 xradius, const f32 yradius, const f32 stangle, const f32 endangle, const u8 filled)
GRRLIB_PieSlice(const f32 x, const f32 y, const f32 radius, const f32 stangle, const f32 endangle, const u8 filled) //same as Sector but same radius

Offline

 

#3 2009-09-10 21:24:32

BlueChip
Moderator

Re: GRRLIB_Ellipse

Cool.

We have just put a Feature Freezeon v4.1.0
So that gives you about 2 weeks to write these functions ready to be included in v4.2 (or v5 or whatever it gets called)

My only comment would be to name your variaables so they sort nicely.  Eg angleSt & angleEnd rather than stangle and endangle.

You may also with to comment on whether you/we like Degrees or Radians.

Lastly:

Code:

#ifndef RAD2DEG
#  define RAD2DEG(r)  (r * 57.2957)
#endif

#ifndef DEG2RAD
#  define DEG2RAD(d)  (d *  0.0174532)
#endif

Thanks again for your contributions eli smile


I can be found on efnet, freenode, msn, gtalk, aim, ychat & icq ...PM me for details

Offline

 

#4 2010-01-15 15:06:26

scognito
Member

Re: GRRLIB_Ellipse

EDIT: This functions works ok like expected! Thanks!

Just curious: I'm "porting" on wii a gfxlib using GRRLIB.
The "only" problems is that i have only the header, that has this function: DrawOval(a,b,c,d,color,FALSE);
I'm sure a and b variables means x and y.
I never coded an ellipse function, so don't know if the "c" and "d" variable can be intended as "width" and "height" (like a rectangle function).
Do the radiusx and radiusy parameter may be intended like width and height, or there are various ways to draw an ellispe so I have to adapt the code?

Thanks in advance!

Last edited by scognito (2010-01-18 11:26:54)

Offline

 

Board footer

Powered by FluxBB