瀏覽代碼

* libee/conic.c: Clip circles and ellipses.

tags/v0.99.beta14
Sam Hocevar sam 22 年之前
父節點
當前提交
3cd2990b02
共有 1 個文件被更改,包括 35 次插入4 次删除
  1. +35
    -4
      libee/conic.c

+ 35
- 4
libee/conic.c 查看文件

@@ -23,6 +23,7 @@
#include "config.h" #include "config.h"


#include <stdlib.h> #include <stdlib.h>
#include <inttypes.h>


#include "ee.h" #include "ee.h"


@@ -86,9 +87,39 @@ void ee_draw_ellipse(int xo, int yo, int a, int b, char c)


static void ellipsepoints(int xo, int yo, int x, int y, char c) static void ellipsepoints(int xo, int yo, int x, int y, char c)
{ {
ee_putcharTO(xo + x, yo + y, c);
ee_putcharTO(xo - x, yo + y, c);
ee_putcharTO(xo + x, yo - y, c);
ee_putcharTO(xo - x, yo - y, c);
uint8_t b = 0;

if(xo + x >= 0 && xo + x < ee_get_width())
b |= 0x1;
if(xo - x >= 0 && xo - x < ee_get_width())
b |= 0x2;
if(yo + y >= 0 && yo + y < ee_get_height())
b |= 0x4;
if(yo - y >= 0 && yo - y < ee_get_height())
b |= 0x8;

if((b & (0x1|0x4)) == (0x1|0x4))
{
ee_goto(xo + x, yo + y);
ee_putchar(c);
}

if((b & (0x2|0x4)) == (0x2|0x4))
{
ee_goto(xo - x, yo + y);
ee_putchar(c);
}

if((b & (0x1|0x8)) == (0x1|0x8))
{
ee_goto(xo + x, yo - y);
ee_putchar(c);
}

if((b & (0x2|0x8)) == (0x2|0x8))
{
ee_goto(xo - x, yo - y);
ee_putchar(c);
}
} }



Loading…
取消
儲存