#define PI 3.1415926535898
void Gfx_RenderCircle( float x, //圆心x坐标
float y, //圆心y坐标
float w, //圆半径宽
float h, //圆半径高( 当w和h不相等时为椭圆 )
DWORD color = 0xFFFFFFFF, //颜色
float p = 8.0f //精度
)
{
float Points[ 361 ][ 2 ];
int PointCount = 0;
for( float i = .0f; i <= 360.0f; i += p )
{
Points[ PointCount ][ 0 ] = sin( i * PI / 180 ) * w;
Points[ PointCount ][ 1 ] = cos( i * PI / 180 ) * h;
++PointCount;
}
float x1 = .0f;
float x2 = .0f;
float y1 = .0f;
float y2 = .0f;
for( int i = 0; i < PointCount - 1; ++i )
{
x1 = Points[ i ][ 0 ];
x2 = Points[ i + 1 ][ 0 ];
y1 = Points[ i ][ 1 ];
y2 = Points[ i + 1 ][ 1 ];
GHGE->Gfx_RenderLine( x1 + x, y1 + y, x2 + x, y2 + y, color );
}
}
HGE引擎中实现自定义画圆的方法
最新推荐文章于 2014-11-22 11:16:04 发布