Changeset 138 for ttyvaders


Ignore:
Timestamp:
Nov 10, 2003, 9:43:02 PM (20 years ago)
Author:
Sam Hocevar
Message:
  • libee/conic.c: Clip circles and ellipses.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ttyvaders/trunk/libee/conic.c

    r136 r138  
    2424
    2525#include <stdlib.h>
     26#include <inttypes.h>
    2627
    2728#include "ee.h"
     
    8788static void ellipsepoints(int xo, int yo, int x, int y, char c)
    8889{
    89     ee_putcharTO(xo + x, yo + y, c);
    90     ee_putcharTO(xo - x, yo + y, c);
    91     ee_putcharTO(xo + x, yo - y, c);
    92     ee_putcharTO(xo - x, yo - y, c);
     90    uint8_t b = 0;
     91
     92    if(xo + x >= 0 && xo + x < ee_get_width())
     93        b |= 0x1;
     94    if(xo - x >= 0 && xo - x < ee_get_width())
     95        b |= 0x2;
     96    if(yo + y >= 0 && yo + y < ee_get_height())
     97        b |= 0x4;
     98    if(yo - y >= 0 && yo - y < ee_get_height())
     99        b |= 0x8;
     100
     101    if((b & (0x1|0x4)) == (0x1|0x4))
     102    {
     103        ee_goto(xo + x, yo + y);
     104        ee_putchar(c);
     105    }
     106
     107    if((b & (0x2|0x4)) == (0x2|0x4))
     108    {
     109        ee_goto(xo - x, yo + y);
     110        ee_putchar(c);
     111    }
     112
     113    if((b & (0x1|0x8)) == (0x1|0x8))
     114    {
     115        ee_goto(xo + x, yo - y);
     116        ee_putchar(c);
     117    }
     118
     119    if((b & (0x2|0x8)) == (0x2|0x8))
     120    {
     121        ee_goto(xo - x, yo - y);
     122        ee_putchar(c);
     123    }
    93124}
    94125
Note: See TracChangeset for help on using the changeset viewer.