用openGL ES繪製圓角矩形的實現

2021-06-04 18:59:52 字數 1590 閱讀 8101

不廢話,直接上**

//呼叫部分

roundrect( 200, /* x */

400, /* y */

400, /* width */

300, /* height */

25, /* corner radius, at least less than 140? */

64 /* need to be "dividable" by 4 */ );

//實現部分

typedef struct

vector2f;

void roundrect( int x,

int y,

int width,

int height,

int radius,

int resolution )

; while( i != segment_count )

glbegin( gl_********_strip );

}// in order to stop and restart the strip.

glcolor4f( 0.0f, 1.0f, 0.0f, 1.5f );

glvertex2i( top_right[ 0 ].x,

top_right[ 0 ].y );

glcolor4f( 0.0f, 1.0f, 0.0f, 1.5f );

glvertex2i( top_right[ 0 ].x,

top_right[ 0 ].y );

// center

// bottom

i = 0;

while( i != segment_count )

}glend();

glbegin( gl_line_strip );

//glcolor4f( 0.0f, 1.0f, 1.0f, 1.0f );

glcolor4f( 1.0f, 0.5f, 0.0f, 1.0f );

// border

i = 0;

while( i != segment_count )

i = ( segment_count - 1 );

while( i > -1 )

i = 0;

while( i != segment_count )

// close the border.

glvertex2i( top_left[ ( segment_count - 1 ) ].x,

top_left[ ( segment_count - 1 ) ].y );

}glend();

glbegin( gl_lines );

//glcolor4f( 0.0f, 1.0f, 1.0f, 1.0f );

glcolor4f( 0.0f, 0.5f, 1.0f, 1.0f );

// separator

glend();

free( top_left );

free( bottom_left );

free( top_right );

free( bottom_right );

}

呼叫方式如下

繪製圓角矩形(方法 )

c gdi 繪製圓角矩形 graphics 物件 rectangle 物件,圓角矩形區域 邊框顏色 邊框寬度 圓角半徑 public static void drawroundrectangle graphics g,rectangle rectangle,color bordercolor,flo...

GDI 繪製圓角矩形

繪製圓角矩形 pen p new pen c,real nsize 畫矩形上面的邊 graphics.drawline p,rc.left width 2,rc.top,rc.right width 2,rc.top 畫矩形下面的邊 graphics.drawline p,rc.left width...

html canvas 繪製圓角矩形

由於canvas沒有直接繪製橢圓的方法,只能通過拼接的形式去繪製 將橢圓拆解成6部分,兩條橫向和4個四分之一圓 通過使用lineto和arcto這兩個方法去進行拼接 canvas id mycanvas width 300 height 150 style border 1px solid d3d3...