浏览代码

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

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/ttyvaders/trunk@138 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam 22 年前
父节点
当前提交
4849672b2e
共有 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);
}
} }



正在加载...
取消
保存