HGE引擎中实现自定义画圆的方法

#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 );
	}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值