arc
来自「下载来的一个看图软件的源代码」· 代码 · 共 32 行
TXT
32 行
/* s and e are integers modulo 360 (degrees), with 0 degrees being the rightmost extreme and degrees changing clockwise. cx and cy are the center in pixels; w and h are the horizontal and vertical diameter in pixels. Nice interface, but slow, since I don't yet use Bresenham (I'm using an inefficient but simple solution with too much work going on in it; generalizing Bresenham to ellipses and partial arcs of ellipses is non-trivial, at least for me) and there are other inefficiencies (small circles do far too much work). */void gdImageArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color){ int i; int lx = 0, ly = 0; int w2, h2; w2 = w/2; h2 = h/2; while (e < s) { e += 360; } for (i=s; (i <= e); i++) { int x, y; x = ((long)gdCosT[i % 360] * (long)w2 / 1024) + cx; y = ((long)gdSinT[i % 360] * (long)h2 / 1024) + cy; if (i != s) { gdImageLine(im, lx, ly, x, y, color); } lx = x; ly = y; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?