Ignore:
Timestamp:
Mar 5, 2006, 7:43:13 PM (15 years ago)
Author:
Sam Hocevar
Message:

A new low-level text management library (canvas for ultrafast compositing

of unicode letters) is now separated from the higher level rendering and I/O
(that is, libcaca). This commit totally breaks the API, but once everything
is polished I will think about source-level backward compatibility. Most
drivers are broken, but X11 still sorta works.

The new design is much more object-oriented and allows having several

active renderers at the same time, changing renderers on the fly, and more
important, having no renderer at all (useful for converters, or when you
want to do your own renderer).

And in case you are still wondering, the libcucul acronym has "Unicode"

because I want to support at least a subset of Unicode. There are awesome
glyphs in it, including the ones inherited from Codepage 437 such as
"gray 25%" that are used in DOS and Win32 ANSI art.

Location:
libcaca/trunk/test
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/test

    • Property svn:ignore
      •  

        old new  
        55colors.exe
        66colors
         7demo.exe
         8demo
        79dithering.exe
        810dithering
  • libcaca/trunk/test/dithering.c

    r522 r524  
    1414#include "config.h"
    1515
     16#include "cucul.h"
    1617#include "caca.h"
    1718
     
    2021#define FUZZY 5000000
    2122
    22 enum caca_color points[] =
     23enum cucul_color points[] =
    2324{
    24     CACA_COLOR_BLACK,
    25     CACA_COLOR_DARKGRAY,
    26     CACA_COLOR_LIGHTGRAY,
    27     CACA_COLOR_WHITE,
    28     CACA_COLOR_RED,
    29     CACA_COLOR_LIGHTRED
     25    CUCUL_COLOR_BLACK,
     26    CUCUL_COLOR_DARKGRAY,
     27    CUCUL_COLOR_LIGHTGRAY,
     28    CUCUL_COLOR_WHITE,
     29    CUCUL_COLOR_RED,
     30    CUCUL_COLOR_LIGHTRED
    3031};
    3132
     
    3435int main(void)
    3536{
     37    cucul_t *qq;
     38    caca_t *kk;
    3639    int neara, dista, nearb, distb, dist;
    3740    int x, y;
    3841
    39     caca_init();
     42    qq = cucul_init();
     43    kk = caca_attach(qq);
    4044
    4145    for(x = 0; x < 100; x++)
     
    5054        /* distance to 40% */
    5155        dist = XRATIO * (x - 40) * (x - 40) + YRATIO * y * y;
    52         if(caca_rand(-FUZZY, FUZZY) + dist < dista)
     56        if(cucul_rand(-FUZZY, FUZZY) + dist < dista)
    5357        {
    5458            nearb = neara; distb = dista; neara = 1; dista = dist;
     
    6165        /* check dist to 70% */
    6266        dist = XRATIO * (x - 70) * (x - 70) + YRATIO * y * y;
    63         if(caca_rand(-FUZZY, FUZZY) + dist < dista)
     67        if(cucul_rand(-FUZZY, FUZZY) + dist < dista)
    6468        {
    6569            nearb = neara; distb = dista; neara = 2; dista = dist;
    6670        }
    67         else if(caca_rand(-FUZZY, FUZZY) + dist < distb)
     71        else if(cucul_rand(-FUZZY, FUZZY) + dist < distb)
    6872        {
    6973            nearb = 2; distb = dist;
     
    7276        /* check dist to white */
    7377        dist = XRATIO * (x - 100) * (x - 100) + YRATIO * y * y;
    74         if(caca_rand(-FUZZY, FUZZY) + dist < dista)
     78        if(cucul_rand(-FUZZY, FUZZY) + dist < dista)
    7579        {
    7680            nearb = neara; distb = dista; neara = 3; dista = dist;
    7781        }
    78         else if(caca_rand(-FUZZY, FUZZY) + dist < distb)
     82        else if(cucul_rand(-FUZZY, FUZZY) + dist < distb)
    7983        {
    8084            nearb = 3; distb = dist;
     
    8589        dist = XRATIO * (x - 40) * (x - 40) + YRATIO * (y - 100) * (y - 100);
    8690        dist = dist * 12 / 16;
    87         if(caca_rand(-FUZZY, FUZZY) + dist < dista)
     91        if(cucul_rand(-FUZZY, FUZZY) + dist < dista)
    8892        {
    8993            nearb = neara; distb = dista; neara = 4; dista = dist;
    9094        }
    91         else if(caca_rand(-FUZZY, FUZZY) + dist < distb)
     95        else if(cucul_rand(-FUZZY, FUZZY) + dist < distb)
    9296        {
    9397            nearb = 4; distb = dist;
     
    97101        dist = XRATIO * (x - 100) * (x - 100) + YRATIO * (y - 100) * (y - 100);
    98102        dist = dist * 8 / 16;
    99         if(caca_rand(-FUZZY, FUZZY) + dist < dista)
     103        if(cucul_rand(-FUZZY, FUZZY) + dist < dista)
    100104        {
    101105            nearb = neara; distb = dista; neara = 5; dista = dist;
    102106        }
    103         else if(caca_rand(-FUZZY, FUZZY) + dist < distb)
     107        else if(cucul_rand(-FUZZY, FUZZY) + dist < distb)
    104108        {
    105109            nearb = 5; distb = dist;
     
    112116        else
    113117            ch = density[dista * 2 * 13 / (dista + distb)];
    114         caca_set_color(points[nearb], points[neara]);
     118        cucul_set_color(qq, points[nearb], points[neara]);
    115119
    116         caca_putchar(x * caca_get_width() / 100, (100 - y) * caca_get_height() / 100, ch);
     120        cucul_putchar(qq, x * cucul_get_width(qq) / 100,
     121                          (100 - y) * cucul_get_height(qq) / 100, ch);
    117122    }
    118123
    119     caca_refresh();
     124    caca_refresh(kk);
    120125
    121     while(!caca_get_event(CACA_EVENT_KEY_PRESS));
     126    while(!caca_get_event(kk, CACA_EVENT_KEY_PRESS));
    122127
    123     caca_end();
     128    caca_detach(kk);
     129    cucul_end(qq);
     130
    124131    return 0;
    125132}
Note: See TracChangeset for help on using the changeset viewer.