Changeset 813


Ignore:
Timestamp:
Apr 18, 2006, 5:54:33 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • Renamed main canvas-related functions so that they have "canvas" in their name, eg. cucul_create() -> cucul_create_canvas() etc.
  • Moved buffer-related functions to cucul/buffer.c.
Location:
libcaca/trunk
Files:
35 edited
1 copied

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca/driver_conio.c

    r811 r813  
    5757    /* FIXME */
    5858#   endif
    59     _cucul_set_size(dp->cv, dp->drv.p->ti.screenwidth,
    60                             dp->drv.p->ti.screenheight);
     59    _cucul_set_canvas_size(dp->cv, dp->drv.p->ti.screenwidth,
     60                                   dp->drv.p->ti.screenheight);
    6161    return 0;
    6262}
  • libcaca/trunk/caca/driver_gl.c

    r811 r813  
    9797
    9898    if(width && height)
    99         _cucul_set_size(dp->cv, width, height);
     99        _cucul_set_canvas_size(dp->cv, width, height);
    100100
    101101    dp->drv.p->font_width = 9;
  • libcaca/trunk/caca/driver_ncurses.c

    r811 r813  
    152152        }
    153153
    154     _cucul_set_size(dp->cv, COLS, LINES);
     154    _cucul_set_canvas_size(dp->cv, COLS, LINES);
    155155
    156156    return 0;
  • libcaca/trunk/caca/driver_slang.c

    r811 r813  
    165165#endif
    166166
    167     _cucul_set_size(dp->cv, SLtt_Screen_Cols, SLtt_Screen_Rows);
     167    _cucul_set_canvas_size(dp->cv, SLtt_Screen_Cols, SLtt_Screen_Rows);
    168168
    169169    return 0;
  • libcaca/trunk/caca/driver_vga.c

    r811 r813  
    7575
    7676    /* We don't have much choice */
    77     _cucul_set_size(dp->cv, 80, 25);
     77    _cucul_set_canvas_size(dp->cv, 80, 25);
    7878
    7979    return 0;
  • libcaca/trunk/caca/driver_win32.c

    r811 r813  
    125125        return -1;
    126126
    127     _cucul_set_size(dp->cv, csbi.srWindow.Right - csbi.srWindow.Left + 1,
    128                             csbi.srWindow.Bottom - csbi.srWindow.Top + 1);
     127    _cucul_set_canvas_size(dp->cv, csbi.srWindow.Right - csbi.srWindow.Left + 1,
     128                           csbi.srWindow.Bottom - csbi.srWindow.Top + 1);
    129129
    130130    SetConsoleMode(dp->drv.p->screen, 0);
  • libcaca/trunk/caca/driver_x11.c

    r811 r813  
    7979
    8080    if(width && height)
    81         _cucul_set_size(dp->cv, width, height);
     81        _cucul_set_canvas_size(dp->cv, width, height);
    8282
    8383    dp->drv.p->dpy = XOpenDisplay(NULL);
  • libcaca/trunk/caca/graphics.c

    r811 r813  
    174174    /* Tell libcucul we changed size */
    175175    if(dp->resize.w != dp->cv->width || dp->resize.h != dp->cv->height)
    176         _cucul_set_size(dp->cv, dp->resize.w, dp->resize.h);
     176        _cucul_set_canvas_size(dp->cv, dp->resize.w, dp->resize.h);
    177177}
    178178
  • libcaca/trunk/cpp/cucul++.cpp

    r811 r813  
    2121Cucul::Cucul()
    2222{
    23     cv = cucul_create(0,0);
     23    cv = cucul_create_canvas(0,0);
    2424    if(!cv) throw -1;
    2525}
    2626Cucul::Cucul(int width, int height)
    2727{
    28     cv = cucul_create(width, height);
     28    cv = cucul_create_canvas(width, height);
    2929    if(!cv) throw -1;
    3030}
     
    3232{
    3333    if(cv) {
    34         cucul_free(cv);
     34        cucul_free_canvas(cv);
    3535    }
    3636}
     
    4545void Cucul::set_size(unsigned int width, unsigned int height)
    4646{
    47     cucul_set_size (cv, width, height);
     47    cucul_set_canvas_size (cv, width, height);
    4848}
    4949unsigned int Cucul::get_width(void)
    5050{
    51     return cucul_get_width (cv);
     51    return cucul_get_canvas_width (cv);
    5252}
    5353unsigned int Cucul::get_height(void)
    5454{
    55     return cucul_get_height (cv);
     55    return cucul_get_canvas_height (cv);
    5656}
    5757void Cucul::set_color(unsigned int f, unsigned int b)
  • libcaca/trunk/cucul/Makefile.am

    r804 r813  
    1515        cucul.h \
    1616        cucul_internals.h \
     17        buffer.c \
    1718        canvas.c \
    1819        transform.c \
  • libcaca/trunk/cucul/buffer.c

    r811 r813  
    1313
    1414/*
    15  *  This file contains the main functions used by \e libcucul applications
    16  *  to initialise a drawing context.
     15 *  This file contains buffer handling functions.
    1716 */
    1817
     
    2726#include "cucul.h"
    2827#include "cucul_internals.h"
    29 
    30 /** \brief Initialise a \e libcucul canvas.
    31  *
    32  *  This function initialises internal \e libcucul structures and the backend
    33  *  that will be used for subsequent graphical operations. It must be the
    34  *  first \e libcucul function to be called in a function. cucul_free() should
    35  *  be called at the end of the program to free all allocated resources.
    36  *
    37  *  If one of the desired canvas coordinates is zero, a default canvas size
    38  *  of 80x32 is used instead.
    39  *
    40  *  \param width The desired canvas width
    41  *  \param height The desired canvas height
    42  *  \return A libcucul canvas handle upon success, NULL if an error occurred.
    43  */
    44 cucul_canvas_t * cucul_create(unsigned int width, unsigned int height)
    45 {
    46     cucul_canvas_t *cv = malloc(sizeof(cucul_canvas_t));
    47 
    48     cv->refcount = 0;
    49 
    50     cv->fgcolor = CUCUL_COLOR_LIGHTGRAY;
    51     cv->bgcolor = CUCUL_COLOR_BLACK;
    52 
    53     cv->width = cv->height = 0;
    54     cv->chars = NULL;
    55     cv->attr = NULL;
    56     cv->empty_line = cv->scratch_line = NULL;
    57 
    58     /* Initialise to a default size. 80x32 is arbitrary but matches AAlib's
    59      * default X11 window. When a graphic driver attaches to us, it can set
    60      * a different size. */
    61     if(width && height)
    62         _cucul_set_size(cv, width, height);
    63     else
    64         _cucul_set_size(cv, 80, 32);
    65 
    66     if(_cucul_init_dither())
    67     {
    68         free(cv);
    69         return NULL;
    70     }
    71 
    72     return cv;
    73 }
    74 
    75 /** \brief Load a memory area into a canvas.
    76  *
    77  *  This function loads a memory area containing an exported canvas into
    78  *  a new \e libcucul canvas.
    79  *
    80  *  \param data The memory area to be loaded into a canvas.
    81  *  \param size The length of the memory area.
    82  *  \return A libcucul canvas, or NULL in case of error.
    83  */
    84 cucul_canvas_t *cucul_load(void *data, unsigned int size)
    85 {
    86     cucul_canvas_t *cv;
    87     uint8_t *buf = (uint8_t *)data;
    88     unsigned int width, height, n;
    89 
    90     if(size < 12)
    91         return NULL;
    92 
    93     if(buf[0] != 'C' || buf[1] != 'A' || buf[2] != 'C' || buf[3] != 'A')
    94         return NULL;
    95 
    96     width = ((uint32_t)buf[4] << 24) | ((uint32_t)buf[5] << 16)
    97           | ((uint32_t)buf[6] << 8) | (uint32_t)buf[7];
    98     height = ((uint32_t)buf[8] << 24) | ((uint32_t)buf[9] << 16)
    99            | ((uint32_t)buf[10] << 8) | (uint32_t)buf[11];
    100 
    101     if(!width || !height)
    102         return NULL;
    103 
    104     if(size != 12 + width * height * 8 + 4)
    105         return NULL;
    106 
    107     if(buf[size - 4] != 'A' || buf[size - 3] != 'C'
    108         || buf[size - 2] != 'A' || buf[size - 1] != 'C')
    109         return NULL;
    110 
    111     cv = cucul_create(width, height);
    112 
    113     if(!cv)
    114         return NULL;
    115 
    116     for(n = height * width; n--; )
    117     {
    118         cv->chars[n] = ((uint32_t)buf[12 + 8 * n] << 24)
    119                      | ((uint32_t)buf[13 + 8 * n] << 16)
    120                      | ((uint32_t)buf[14 + 8 * n] << 8)
    121                      | (uint32_t)buf[15 + 8 * n];
    122         cv->attr[n] = ((uint32_t)buf[16 + 8 * n] << 24)
    123                     | ((uint32_t)buf[17 + 8 * n] << 16)
    124                     | ((uint32_t)buf[18 + 8 * n] << 8)
    125                     | (uint32_t)buf[19 + 8 * n];
    126     }
    127 
    128     return cv;
    129 }
    130 
    131 /** \brief Resize a canvas.
    132  *
    133  *  This function sets the canvas width and height, in character cells.
    134  *
    135  *  The contents of the canvas are preserved to the extent of the new
    136  *  canvas size. Newly allocated character cells at the right and/or at
    137  *  the bottom of the canvas are filled with spaces.
    138  *
    139  *  It is an error to try to resize the canvas if an output driver has
    140  *  been attached to the canvas using caca_attach(). You need to remove
    141  *  the output driver using caca_detach() before you can change the
    142  *  canvas size again. However, the caca output driver can cause a canvas
    143  *  resize through user interaction. See the caca_event() documentation
    144  *  for more about this.
    145  *
    146  *  \param cv A libcucul canvas
    147  *  \param width The desired canvas width
    148  *  \param height The desired canvas height
    149  */
    150 void cucul_set_size(cucul_canvas_t *cv, unsigned int width, unsigned int height)
    151 {
    152     if(cv->refcount)
    153         return;
    154 
    155     _cucul_set_size(cv, width, height);
    156 }
    157 
    158 /** \brief Get the canvas width.
    159  *
    160  *  This function returns the current canvas width, in character cells.
    161  *
    162  *  \param cv A libcucul canvas
    163  *  \return The canvas width.
    164  */
    165 unsigned int cucul_get_width(cucul_canvas_t *cv)
    166 {
    167     return cv->width;
    168 }
    169 
    170 /** \brief Get the canvas height.
    171  *
    172  *  This function returns the current canvas height, in character cells.
    173  *
    174  *  \param cv A libcucul canvas
    175  *  \return The canvas height.
    176  */
    177 unsigned int cucul_get_height(cucul_canvas_t *cv)
    178 {
    179     return cv->height;
    180 }
    181 
    182 /** \brief Translate a colour index into the colour's name.
    183  *
    184  *  This function translates a cucul_color enum into a human-readable
    185  *  description string of the associated colour.
    186  *
    187  *  \param color The colour value.
    188  *  \return A static string containing the colour's name.
    189  */
    190 char const *cucul_get_color_name(unsigned int color)
    191 {
    192     static char const *color_names[] =
    193     {
    194         "black",
    195         "blue",
    196         "green",
    197         "cyan",
    198         "red",
    199         "magenta",
    200         "brown",
    201         "light gray",
    202         "dark gray",
    203         "light blue",
    204         "light green",
    205         "light cyan",
    206         "light red",
    207         "light magenta",
    208         "yellow",
    209         "white",
    210     };
    211 
    212     if(color < 0 || color > 15)
    213         return "unknown";
    214 
    215     return color_names[color];
    216 }
    217 
    218 /** \brief Uninitialise \e libcucul.
    219  *
    220  *  This function frees all resources allocated by cucul_create(). After
    221  *  cucul_free() has been called, no other \e libcucul functions may be used
    222  *  unless a new call to cucul_create() is done.
    223  *
    224  *  \param cv A libcucul canvas
    225  */
    226 void cucul_free(cucul_canvas_t *cv)
    227 {
    228     _cucul_end_dither();
    229 
    230     free(cv->empty_line);
    231     free(cv->scratch_line);
    232 
    233     free(cv->chars);
    234     free(cv->attr);
    235 
    236     free(cv);
    237 }
    238 
    239 /** \brief Generate a random integer within a range.
    240  *
    241  *  \param min The lower bound of the integer range.
    242  *  \param max The upper bound of the integer range.
    243  *  \return A random integer comprised between \p min and \p max, inclusive.
    244  */
    245 int cucul_rand(int min, int max)
    246 {
    247     return min + (int)((1.0*(max-min+1)) * rand() / (RAND_MAX+1.0));
    248 }
    24928
    25029/** \brief Get the buffer size.
     
    28766}
    28867
    289 /*
    290  * XXX: The following functions are local.
    291  */
    292 
    293 void _cucul_set_size(cucul_canvas_t *cv, unsigned int width,
    294                                          unsigned int height)
    295 {
    296     unsigned int x, y, old_width, old_height, new_size, old_size;
    297 
    298     old_width = cv->width;
    299     old_height = cv->height;
    300     old_size = old_width * old_height;
    301 
    302     cv->width = width;
    303     cv->height = height;
    304     new_size = width * height;
    305 
    306     /* Step 1: if new area is bigger, resize the memory area now. */
    307     if(new_size > old_size)
    308     {
    309         cv->chars = realloc(cv->chars, new_size * sizeof(uint32_t));
    310         cv->attr = realloc(cv->attr, new_size * sizeof(uint32_t));
    311     }
    312 
    313     /* Step 2: move line data if necessary. */
    314     if(width == old_width)
    315     {
    316         /* Width did not change, which means we do not need to move data. */
    317         ;
    318     }
    319     else if(width > old_width)
    320     {
    321         /* New width is bigger than old width, which means we need to
    322          * copy lines starting from the bottom of the screen otherwise
    323          * we will overwrite information. */
    324         for(y = height < old_height ? height : old_height; y--; )
    325         {
    326             for(x = old_width; x--; )
    327             {
    328                 cv->chars[y * width + x] = cv->chars[y * old_width + x];
    329                 cv->attr[y * width + x] = cv->attr[y * old_width + x];
    330             }
    331 
    332             /* Zero the end of the line */
    333             for(x = width - old_width; x--; )
    334                 cv->chars[y * width + old_width + x] = (uint32_t)' ';
    335             memset(cv->attr + y * width + old_width, 0,
    336                    (width - old_width) * 4);
    337         }
    338     }
    339     else
    340     {
    341         /* New width is smaller. Copy as many lines as possible. Ignore
    342          * the first line, it is already in place. */
    343         unsigned int lines = height < old_height ? height : old_height;
    344 
    345         for(y = 1; y < lines; y++)
    346         {
    347             for(x = 0; x < width; x++)
    348             {
    349                 cv->chars[y * width + x] = cv->chars[y * old_width + x];
    350                 cv->attr[y * width + x] = cv->attr[y * old_width + x];
    351             }
    352         }
    353     }
    354 
    355     /* Step 3: fill the bottom of the new screen if necessary. */
    356     if(height > old_height)
    357     {
    358         /* Zero the bottom of the screen */
    359         for(x = (height - old_height) * width; x--; )
    360             cv->chars[old_height * width + x] = (uint32_t)' ';
    361         memset(cv->attr + old_height * width, 0,
    362                (height - old_height) * width * 4);
    363     }
    364 
    365     /* Step 4: if new area is smaller, resize memory area now. */
    366     if(new_size <= old_size)
    367     {
    368         cv->chars = realloc(cv->chars, new_size * sizeof(uint32_t));
    369         cv->attr = realloc(cv->attr, new_size * sizeof(uint32_t));
    370     }
    371 
    372     /* Recompute the scratch line and the empty line */
    373     if(width != old_width)
    374     {
    375         cv->empty_line = realloc(cv->empty_line, width + 1);
    376         memset(cv->empty_line, ' ', width);
    377         cv->empty_line[width] = '\0';
    378 
    379         cv->scratch_line = realloc(cv->scratch_line, width + 1);
    380     }
    381 }
    382 
  • libcaca/trunk/cucul/cucul.c

    r811 r813  
    3232 *  This function initialises internal \e libcucul structures and the backend
    3333 *  that will be used for subsequent graphical operations. It must be the
    34  *  first \e libcucul function to be called in a function. cucul_free() should
    35  *  be called at the end of the program to free all allocated resources.
     34 *  first \e libcucul function to be called in a function. cucul_free_canvas()
     35 *  should be called at the end of the program to free all allocated resources.
    3636 *
    3737 *  If one of the desired canvas coordinates is zero, a default canvas size
     
    4242 *  \return A libcucul canvas handle upon success, NULL if an error occurred.
    4343 */
    44 cucul_canvas_t * cucul_create(unsigned int width, unsigned int height)
     44cucul_canvas_t * cucul_create_canvas(unsigned int width, unsigned int height)
    4545{
    4646    cucul_canvas_t *cv = malloc(sizeof(cucul_canvas_t));
     
    6060     * a different size. */
    6161    if(width && height)
    62         _cucul_set_size(cv, width, height);
     62        _cucul_set_canvas_size(cv, width, height);
    6363    else
    64         _cucul_set_size(cv, 80, 32);
     64        _cucul_set_canvas_size(cv, 80, 32);
    6565
    6666    if(_cucul_init_dither())
     
    8282 *  \return A libcucul canvas, or NULL in case of error.
    8383 */
    84 cucul_canvas_t *cucul_load(void *data, unsigned int size)
     84cucul_canvas_t *cucul_load_canvas(void *data, unsigned int size)
    8585{
    8686    cucul_canvas_t *cv;
     
    109109        return NULL;
    110110
    111     cv = cucul_create(width, height);
     111    cv = cucul_create_canvas(width, height);
    112112
    113113    if(!cv)
     
    148148 *  \param height The desired canvas height
    149149 */
    150 void cucul_set_size(cucul_canvas_t *cv, unsigned int width, unsigned int height)
     150void cucul_set_canvas_size(cucul_canvas_t *cv, unsigned int width,
     151                                               unsigned int height)
    151152{
    152153    if(cv->refcount)
    153154        return;
    154155
    155     _cucul_set_size(cv, width, height);
     156    _cucul_set_canvas_size(cv, width, height);
    156157}
    157158
     
    163164 *  \return The canvas width.
    164165 */
    165 unsigned int cucul_get_width(cucul_canvas_t *cv)
     166unsigned int cucul_get_canvas_width(cucul_canvas_t *cv)
    166167{
    167168    return cv->width;
     
    175176 *  \return The canvas height.
    176177 */
    177 unsigned int cucul_get_height(cucul_canvas_t *cv)
     178unsigned int cucul_get_canvas_height(cucul_canvas_t *cv)
    178179{
    179180    return cv->height;
     
    218219/** \brief Uninitialise \e libcucul.
    219220 *
    220  *  This function frees all resources allocated by cucul_create(). After
    221  *  cucul_free() has been called, no other \e libcucul functions may be used
    222  *  unless a new call to cucul_create() is done.
     221 *  This function frees all resources allocated by cucul_create_canvas(). After
     222 *  cucul_free_canvas() has been called, no other \e libcucul functions may be
     223 *  used unless a new call to cucul_create_canvas() is done.
    223224 *
    224225 *  \param cv A libcucul canvas
    225226 */
    226 void cucul_free(cucul_canvas_t *cv)
     227void cucul_free_canvas(cucul_canvas_t *cv)
    227228{
    228229    _cucul_end_dither();
     
    248249}
    249250
    250 /** \brief Get the buffer size.
    251  *
    252  *  This function returns the length (in bytes) of the memory area stored
    253  *  in the given \e libcucul buffer.
    254  *
    255  *  \param buf A \e libcucul buffer
    256  *  \return The buffer data length.
    257  */
    258 unsigned long int cucul_get_buffer_size(cucul_buffer_t *buf)
    259 {
    260     return buf->size;
    261 }
    262 
    263 /** \brief Get the buffer data.
    264  *
    265  *  This function returns a pointer to the memory area stored in the given
    266  *  \e libcucul buffer.
    267  *
    268  *  \param buf A \e libcucul buffer
    269  *  \return A pointer to the buffer memory area.
    270  */
    271 void * cucul_get_buffer_data(cucul_buffer_t *buf)
    272 {
    273     return buf->data;
    274 }
    275 
    276 /** \brief Free a buffer.
    277  *
    278  *  This function frees the structures associated with the given
    279  *  \e libcucul buffer.
    280  *
    281  *  \param buf A \e libcucul buffer
    282  */
    283 void cucul_free_buffer(cucul_buffer_t *buf)
    284 {
    285     free(buf->data);
    286     free(buf);
    287 }
    288 
    289251/*
    290252 * XXX: The following functions are local.
    291253 */
    292254
    293 void _cucul_set_size(cucul_canvas_t *cv, unsigned int width,
    294                                          unsigned int height)
     255void _cucul_set_canvas_size(cucul_canvas_t *cv, unsigned int width,
     256                                                unsigned int height)
    295257{
    296258    unsigned int x, y, old_width, old_height, new_size, old_size;
  • libcaca/trunk/cucul/cucul.h

    r810 r813  
    7474 *
    7575 *  @{ */
    76 cucul_canvas_t * cucul_create(unsigned int, unsigned int);
    77 cucul_canvas_t * cucul_load(void *, unsigned int);
    78 void cucul_set_size(cucul_canvas_t *, unsigned int, unsigned int);
    79 unsigned int cucul_get_width(cucul_canvas_t *);
    80 unsigned int cucul_get_height(cucul_canvas_t *);
    81 void cucul_free(cucul_canvas_t *);
     76cucul_canvas_t * cucul_create_canvas(unsigned int, unsigned int);
     77cucul_canvas_t * cucul_load_canvas(void *, unsigned int);
     78void cucul_set_canvas_size(cucul_canvas_t *, unsigned int, unsigned int);
     79unsigned int cucul_get_canvas_width(cucul_canvas_t *);
     80unsigned int cucul_get_canvas_height(cucul_canvas_t *);
     81void cucul_free_canvas(cucul_canvas_t *);
    8282int cucul_rand(int, int);
    8383/*  @} */
  • libcaca/trunk/cucul/cucul_internals.h

    r810 r813  
    5252
    5353/* Canvas functions */
    54 extern void _cucul_set_size(cucul_canvas_t *, unsigned int, unsigned int);
     54extern void _cucul_set_canvas_size(cucul_canvas_t *, unsigned int, unsigned int);
    5555extern void _cucul_putchar32(cucul_canvas_t *, int, int, uint32_t);
    5656
  • libcaca/trunk/cucul/export.c

    r811 r813  
    615615    f = cucul_load_font(fontlist[0], 0);
    616616
    617     w = cucul_get_width(cv) * cucul_get_font_width(f);
    618     h = cucul_get_height(cv) * cucul_get_font_height(f);
     617    w = cucul_get_canvas_width(cv) * cucul_get_font_width(f);
     618    h = cucul_get_canvas_height(cv) * cucul_get_font_height(f);
    619619
    620620    ex->size = w * h * 4 + 18; /* 32 bpp + 18 bytes for the header */
  • libcaca/trunk/cucul/font.c

    r811 r813  
    260260 *  font. The pixel format is fixed (32-bit ARGB, 8 bits for each component).
    261261 *
    262  *  The required image width can be computed using \e cucul_get_width(cv) and
    263  *  \e cucul_get_font_width(f). The required height can be computed using
    264  *  \e cucul_get_height(cv) and \e cucul_get_font_height(f).
     262 *  The required image width can be computed using
     263 *  \e cucul_get_canvas_width(cv) and \e cucul_get_font_width(f). The required
     264 *  height can be computed using \e cucul_get_canvas_height(cv) and
     265 *  \e cucul_get_font_height(f).
    265266 *
    266267 *  Glyphs that do not fit in the image buffer are currently not rendered at
  • libcaca/trunk/src/aafire.c

    r811 r813  
    101101
    102102#ifdef LIBCACA
    103   cv = cucul_create(80, 32);
     103  cv = cucul_create_canvas(80, 32);
    104104  if (!cv)
    105105    {
     
    114114    }
    115115  caca_set_delay(dp, 10000);
    116   XSIZ = cucul_get_width(cv) * 2;
    117   YSIZ = cucul_get_height(cv) * 2 - 4;
     116  XSIZ = cucul_get_canvas_width(cv) * 2;
     117  YSIZ = cucul_get_canvas_height(cv) * 2 - 4;
    118118#else
    119119  context = aa_autoinit (&aa_defparams);
     
    143143  cucul_dither = cucul_create_dither(8, XSIZ, YSIZ - 2, XSIZ, 0, 0, 0, 0);
    144144  cucul_set_dither_palette(cucul_dither, r, g, b, a);
    145   bitmap = malloc(4 * cucul_get_width(cv) * cucul_get_height(cv) * sizeof(char));
    146   memset(bitmap, 0, 4 * cucul_get_width(cv) * cucul_get_height(cv));
     145  bitmap = malloc(4 * cucul_get_canvas_width(cv)
     146                    * cucul_get_canvas_height(cv));
     147  memset(bitmap, 0, 4 * cucul_get_canvas_width(cv)
     148                      * cucul_get_canvas_height(cv));
    147149#else
    148150  aa_hidecursor (context);
     
    154156#ifdef LIBCACA
    155157  caca_detach(dp);
    156   cucul_free(cv);
     158  cucul_free_canvas(cv);
    157159#else
    158160  aa_close (context);
     
    236238#ifdef LIBCACA
    237239paused:
    238   cucul_dither_bitmap(cv, 0, 0,
    239                       cucul_get_width(cv) - 1, cucul_get_height(cv) - 1,
    240                       cucul_dither, bitmap);
     240  cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv) - 1,
     241                      cucul_get_canvas_height(cv) - 1, cucul_dither, bitmap);
    241242  cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
    242   cucul_putstr(cv, cucul_get_width(cv) - 30, cucul_get_height(cv) - 2,
    243                " -=[ Powered by libcaca ]=- ");
     243  cucul_putstr(cv, cucul_get_canvas_width(cv) - 30,
     244               cucul_get_canvas_height(cv) - 2, " -=[ Powered by libcaca ]=- ");
    244245 
    245246  caca_display(dp);
  • libcaca/trunk/src/cacaball.c

    r811 r813  
    5454    double frameOffset80[360];
    5555
    56     cv = cucul_create(0, 0);
     56    cv = cucul_create_canvas(0, 0);
    5757    if(!cv)
    5858        return 1;
     
    155155        /* Draw our virtual buffer to screen, letting libcucul resize it */
    156156        cucul_dither_bitmap(cv, 0, 0,
    157                           cucul_get_width(cv) - 1, cucul_get_height(cv) - 1,
     157                          cucul_get_canvas_width(cv) - 1,
     158                          cucul_get_canvas_height(cv) - 1,
    158159                          cucul_dither, pixels + (METASIZE / 2) * (1 + XSIZ));
    159160        cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
    160         cucul_putstr(cv, cucul_get_width(cv) - 30, cucul_get_height(cv) - 2,
    161                      " -=[ Powered by libcaca ]=- ");
     161        cucul_putstr(cv, cucul_get_canvas_width(cv) - 30,
     162                         cucul_get_canvas_height(cv) - 2,
     163                         " -=[ Powered by libcaca ]=- ");
    162164
    163165        caca_display(dp);
     
    168170    cucul_free_dither(cucul_dither);
    169171    caca_detach(dp);
    170     cucul_free(cv);
     172    cucul_free_canvas(cv);
    171173
    172174    return 0;
  • libcaca/trunk/src/cacamoir.c

    r811 r813  
    4343    int i, x, y, frame = 0, pause = 0;
    4444
    45     cv = cucul_create(0, 0);
     45    cv = cucul_create_canvas(0, 0);
    4646    if(!cv)
    4747        return 1;
     
    108108paused:
    109109        cucul_dither_bitmap(cv, 0, 0,
    110                             cucul_get_width(cv) - 1, cucul_get_height(cv) - 1,
     110                            cucul_get_canvas_width(cv) - 1,
     111                            cucul_get_canvas_height(cv) - 1,
    111112                            dither, screen);
    112113        cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
    113         cucul_putstr(cv, cucul_get_width(cv) - 30, cucul_get_height(cv) - 2,
    114                      " -=[ Powered by libcaca ]=- ");
     114        cucul_putstr(cv, cucul_get_canvas_width(cv) - 30,
     115                         cucul_get_canvas_height(cv) - 2,
     116                         " -=[ Powered by libcaca ]=- ");
    115117        caca_display(dp);
    116118    }
     
    119121    cucul_free_dither(dither);
    120122    caca_detach(dp);
    121     cucul_free(cv);
     123    cucul_free_canvas(cv);
    122124
    123125    return 0;
  • libcaca/trunk/src/cacaplas.c

    r811 r813  
    4747    int i, x, y, frame = 0, pause = 0;
    4848
    49     cv = cucul_create(0, 0);
     49    cv = cucul_create_canvas(0, 0);
    5050    if(!cv)
    5151        return 1;
     
    5656    caca_set_delay(dp, 20000);
    5757
    58     c2 = cucul_create(cucul_get_width(cv), cucul_get_height(cv));
    59     mask = cucul_create(cucul_get_width(cv), cucul_get_height(cv));
     58    c2 = cucul_create_canvas(cucul_get_canvas_width(cv),
     59                             cucul_get_canvas_height(cv));
     60    mask = cucul_create_canvas(cucul_get_canvas_width(cv),
     61                               cucul_get_canvas_height(cv));
    6062
    6163    /* Fill various tables */
     
    121123paused:
    122124        cucul_dither_bitmap(cv, 0, 0,
    123                             cucul_get_width(cv) - 1, cucul_get_height(cv) - 1,
     125                            cucul_get_canvas_width(cv) - 1,
     126                            cucul_get_canvas_height(cv) - 1,
    124127                            dither, screen);
    125128
     
    131134
    132135        cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
    133         cucul_putstr(cv, cucul_get_width(cv) - 30, cucul_get_height(cv) - 2,
    134                      " -=[ Powered by libcaca ]=- ");
     136        cucul_putstr(cv, cucul_get_canvas_width(cv) - 30,
     137                         cucul_get_canvas_height(cv) - 2,
     138                         " -=[ Powered by libcaca ]=- ");
    135139        caca_display(dp);
    136140    }
     
    139143    cucul_free_dither(dither);
    140144    caca_detach(dp);
    141     cucul_free(cv);
     145    cucul_free_canvas(cv);
    142146
    143147    return 0;
  • libcaca/trunk/src/cacaplay.c

    r811 r813  
    5454    buffer = malloc(statbuf.st_size);
    5555    read(fd, buffer, statbuf.st_size);
    56     cv = cucul_load(buffer, statbuf.st_size);
     56    cv = cucul_load_canvas(buffer, statbuf.st_size);
    5757    free(buffer);
    5858
     
    7575    /* Clean up */
    7676    caca_detach(dp);
    77     cucul_free(cv);
     77    cucul_free_canvas(cv);
    7878
    7979    return 0;
  • libcaca/trunk/src/cacaserver.c

    r810 r813  
    225225        /* Free the previous canvas, if any */
    226226        if(server->canvas)
    227             cucul_free(server->canvas);
    228 
    229         server->canvas = cucul_load(buf, size);
     227            cucul_free_canvas(server->canvas);
     228
     229        server->canvas = cucul_load_canvas(buf, size);
    230230
    231231        if(!server->canvas)
  • libcaca/trunk/src/cacaview.c

    r811 r813  
    6969
    7070    /* Initialise libcucul */
    71     cv = cucul_create(0, 0);
     71    cv = cucul_create_canvas(0, 0);
    7272    if(!cv)
    7373    {
     
    8686    caca_set_window_title(dp, "cacaview");
    8787
    88     ww = cucul_get_width(cv);
    89     wh = cucul_get_height(cv);
     88    ww = cucul_get_canvas_width(cv);
     89    wh = cucul_get_canvas_height(cv);
    9090
    9191    /* Fill the zoom table */
     
    305305            cucul_putstr(cv, (ww - strlen(buffer)) / 2, wh / 2, buffer);
    306306            caca_display(dp);
    307             ww = cucul_get_width(cv);
    308             wh = cucul_get_height(cv);
     307            ww = cucul_get_canvas_width(cv);
     308            wh = cucul_get_canvas_height(cv);
    309309
    310310            if(im)
     
    410410        unload_image(im);
    411411    caca_detach(dp);
    412     cucul_free(cv);
     412    cucul_free_canvas(cv);
    413413
    414414    return 0;
     
    473473    if(zoom < -ZOOM_MAX) zoom = -ZOOM_MAX;
    474474
    475     ww = cucul_get_width(cv);
     475    ww = cucul_get_canvas_width(cv);
    476476    height = fullscreen ? wh : wh - 3;
    477477
    478478    xfactor = (zoom < 0) ? 1.0 / zoomtab[-zoom] : zoomtab[zoom];
    479479    yfactor = xfactor * ww / height * im->h / im->w
    480                * cucul_get_height(cv) / cucul_get_width(cv)
     480               * cucul_get_canvas_height(cv) / cucul_get_canvas_width(cv)
    481481               * caca_get_window_width(dp) / caca_get_window_height(dp);
    482482
     
    507507    int xn, yn;
    508508
    509     if(x2 + 1 > (int)cucul_get_width(cv)) x2 = cucul_get_width(cv) - 1;
    510     if(y2 + 1 > (int)cucul_get_height(cv)) y2 = cucul_get_height(cv) - 1;
     509    if(x2 + 1 > (int)cucul_get_canvas_width(cv))
     510        x2 = cucul_get_canvas_width(cv) - 1;
     511    if(y2 + 1 > (int)cucul_get_canvas_height(cv))
     512        y2 = cucul_get_canvas_height(cv) - 1;
    511513
    512514    for(yn = y1 > 0 ? y1 : 0; yn <= y2; yn++)
  • libcaca/trunk/src/img2irc.c

    r811 r813  
    3535    }
    3636
    37     cv = cucul_create(0, 0);
     37    cv = cucul_create_canvas(0, 0);
    3838    if(!cv)
    3939    {
     
    4646    {
    4747        fprintf(stderr, "%s: unable to load %s\n", argv[0], argv[1]);
    48         cucul_free(cv);
     48        cucul_free_canvas(cv);
    4949        return 1;
    5050    }
     
    5353    lines = cols * i->h * 6 / i->w / 10;
    5454
    55     cucul_set_size(cv, cols, lines);
     55    cucul_set_canvas_size(cv, cols, lines);
    5656    cucul_clear(cv);
    5757    cucul_dither_bitmap(cv, 0, 0, cols - 1, lines - 1, i->dither, i->pixels);
     
    6464    cucul_free_buffer(export);
    6565
    66     cucul_free(cv);
     66    cucul_free_canvas(cv);
    6767
    6868    return 0;
  • libcaca/trunk/test/colors.c

    r811 r813  
    2828    int i, j;
    2929
    30     cv = cucul_create(0, 0);
     30    cv = cucul_create_canvas(0, 0);
    3131    if(!cv)
    3232        return 1;
     
    5454
    5555    caca_detach(dp);
    56     cucul_free(cv);
     56    cucul_free_canvas(cv);
    5757
    5858    return 0;
  • libcaca/trunk/test/demo.c

    r811 r813  
    4646    int quit = 0;
    4747
    48     cv = cucul_create(0, 0);
     48    cv = cucul_create_canvas(0, 0);
    4949    if(!cv)
    5050        return 1;
     
    175175
    176176            cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK);
    177             cucul_draw_thin_box(cv, 1, 1, cucul_get_width(cv) - 2, cucul_get_height(cv) - 2);
     177            cucul_draw_thin_box(cv, 1, 1, cucul_get_canvas_width(cv) - 2,
     178                                          cucul_get_canvas_height(cv) - 2);
    178179            cucul_printf(cv, 4, 1, "[%i.%i fps]----",
    179180                         1000000 / caca_get_rendertime(dp),
     
    186187    cucul_free_sprite(sprite);
    187188    caca_detach(dp);
    188     cucul_free(cv);
     189    cucul_free_canvas(cv);
    189190
    190191    return 0;
     
    193194static void display_menu(void)
    194195{
    195     int xo = cucul_get_width(cv) - 2;
    196     int yo = cucul_get_height(cv) - 2;
     196    int xo = cucul_get_canvas_width(cv) - 2;
     197    int yo = cucul_get_canvas_height(cv) - 2;
    197198
    198199    cucul_clear(cv);
     
    240241    /* Draw the sun */
    241242    cucul_set_color(cv, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK);
    242     xo = cucul_get_width(cv) / 4;
    243     yo = cucul_get_height(cv) / 4 + 5 * sin(0.03*i);
     243    xo = cucul_get_canvas_width(cv) / 4;
     244    yo = cucul_get_canvas_height(cv) / 4 + 5 * sin(0.03*i);
    244245
    245246    for(j = 0; j < 16; j++)
     
    257258
    258259    /* Draw the pyramid */
    259     xo = cucul_get_width(cv) * 5 / 8;
     260    xo = cucul_get_canvas_width(cv) * 5 / 8;
    260261    yo = 2;
    261262
    262     xa = cucul_get_width(cv) / 8 + sin(0.03*i) * 5;
    263     ya = cucul_get_height(cv) / 2 + cos(0.03*i) * 5;
    264 
    265     xb = cucul_get_width(cv) - 10 - cos(0.02*i) * 10;
    266     yb = cucul_get_height(cv) * 3 / 4 - 5 + sin(0.02*i) * 5;
    267 
    268     xc = cucul_get_width(cv) / 4 - sin(0.02*i) * 5;
    269     yc = cucul_get_height(cv) * 3 / 4 + cos(0.02*i) * 5;
     263    xa = cucul_get_canvas_width(cv) / 8 + sin(0.03*i) * 5;
     264    ya = cucul_get_canvas_height(cv) / 2 + cos(0.03*i) * 5;
     265
     266    xb = cucul_get_canvas_width(cv) - 10 - cos(0.02*i) * 10;
     267    yb = cucul_get_canvas_height(cv) * 3 / 4 - 5 + sin(0.02*i) * 5;
     268
     269    xc = cucul_get_canvas_width(cv) / 4 - sin(0.02*i) * 5;
     270    yc = cucul_get_canvas_height(cv) * 3 / 4 + cos(0.02*i) * 5;
    270271
    271272    cucul_set_color(cv, CUCUL_COLOR_GREEN, CUCUL_COLOR_BLACK);
     
    288289    ya = 2;
    289290
    290     xb = cucul_get_width(cv) - 3;
    291     yb = cucul_get_height(cv) / 2;
    292 
    293     xc = cucul_get_width(cv) / 3;
    294     yc = cucul_get_height(cv) - 3;
     291    xb = cucul_get_canvas_width(cv) - 3;
     292    yb = cucul_get_canvas_height(cv) / 2;
     293
     294    xc = cucul_get_canvas_width(cv) / 3;
     295    yc = cucul_get_canvas_height(cv) - 3;
    295296
    296297    cucul_set_color(cv, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
    297298    cucul_draw_thin_triangle(cv, xa, ya, xb, yb, xc, yc);
    298299
    299     xo = cucul_get_width(cv) / 2 + cos(0.027*i) * cucul_get_width(cv) / 3;
    300     yo = cucul_get_height(cv) / 2 - sin(0.027*i) * cucul_get_height(cv) / 2;
     300    xo = cucul_get_canvas_width(cv) / 2 + cos(0.027*i) * cucul_get_canvas_width(cv) / 3;
     301    yo = cucul_get_canvas_height(cv) / 2 - sin(0.027*i) * cucul_get_canvas_height(cv) / 2;
    301302
    302303    cucul_draw_thin_line(cv, xa, ya, xo, yo);
     
    312313        int delta = cucul_rand(-5, 5);
    313314        cucul_set_color(cv, cucul_rand(0, 15), cucul_rand(0, 15));
    314         cucul_putchar(cv, cucul_get_width(cv) / 2
    315                     + cos(0.02*j) * (delta + cucul_get_width(cv) / 4),
    316                    cucul_get_height(cv) / 2
    317                     + sin(0.02*j) * (delta + cucul_get_height(cv) / 3),
     315        cucul_putchar(cv, cucul_get_canvas_width(cv) / 2
     316                    + cos(0.02*j) * (delta + cucul_get_canvas_width(cv) / 4),
     317                   cucul_get_canvas_height(cv) / 2
     318                    + sin(0.02*j) * (delta + cucul_get_canvas_height(cv) / 3),
    318319                   '#');
    319320    }
    320321
    321322    /* Draw foreground sprite */
    322     cucul_draw_sprite(cv, cucul_get_width(cv) / 2 + cos(0.02*i) * cucul_get_width(cv) / 4,
    323                    cucul_get_height(cv) / 2 + sin(0.02*i) * cucul_get_height(cv) / 3,
     323    cucul_draw_sprite(cv, cucul_get_canvas_width(cv) / 2 + cos(0.02*i) * cucul_get_canvas_width(cv) / 4,
     324                   cucul_get_canvas_height(cv) / 2 + sin(0.02*i) * cucul_get_canvas_height(cv) / 3,
    324325                   sprite, 0);
    325326}
     
    327328static void demo_dots(void)
    328329{
    329     int xmax = cucul_get_width(cv) - 1;
    330     int ymax = cucul_get_height(cv) - 1;
     330    int xmax = cucul_get_canvas_width(cv) - 1;
     331    int ymax = cucul_get_canvas_height(cv) - 1;
    331332    int i;
    332333    static char chars[10] =
     
    365366static void demo_lines(void)
    366367{
    367     int w = cucul_get_width(cv);
    368     int h = cucul_get_height(cv);
     368    int w = cucul_get_canvas_width(cv);
     369    int h = cucul_get_canvas_height(cv);
    369370    int xa, ya, xb, yb;
    370371
     
    389390static void demo_boxes(void)
    390391{
    391     int w = cucul_get_width(cv);
    392     int h = cucul_get_height(cv);
     392    int w = cucul_get_canvas_width(cv);
     393    int h = cucul_get_canvas_height(cv);
    393394    int xa, ya, xb, yb;
    394395
     
    416417static void demo_ellipses(void)
    417418{
    418     int w = cucul_get_width(cv);
    419     int h = cucul_get_height(cv);
     419    int w = cucul_get_canvas_width(cv);
     420    int h = cucul_get_canvas_height(cv);
    420421    int x, y, a, b;
    421422
     
    447448static void demo_triangles(void)
    448449{
    449     int w = cucul_get_width(cv);
    450     int h = cucul_get_height(cv);
     450    int w = cucul_get_canvas_width(cv);
     451    int h = cucul_get_canvas_height(cv);
    451452    int xa, ya, xb, yb, xc, yc;
    452453
     
    477478static void demo_sprites(void)
    478479{
    479     cucul_draw_sprite(cv, cucul_rand(0, cucul_get_width(cv) - 1),
    480                    cucul_rand(0, cucul_get_height(cv) - 1), sprite, 0);
     480    cucul_draw_sprite(cv, cucul_rand(0, cucul_get_canvas_width(cv) - 1),
     481                   cucul_rand(0, cucul_get_canvas_height(cv) - 1), sprite, 0);
    481482}
    482483
     
    504505    //dither = cucul_create_dither(16, 256, 256, 2 * 256, 0xf800, 0x07e0, 0x001f, 0x0000);
    505506    dither = cucul_create_dither(32, 256, 256, 4 * 256, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
    506     cucul_dither_bitmap(cv, 0, 0, cucul_get_width(cv) - 1, cucul_get_height(cv) - 1,
     507    cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv) - 1, cucul_get_canvas_height(cv) - 1,
    507508                     dither, buffer);
    508509    cucul_free_dither(dither);
     
    549550    dither = cucul_create_dither(32, 256, 256, 4 * 256, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
    550551 cucul_set_dither_invert(dither, 1);
    551     cucul_dither_bitmap(cv, 0, 0, cucul_get_width(cv) - 1, cucul_get_height(cv) - 1, dither, (char *)buffer);
     552    cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv) - 1, cucul_get_canvas_height(cv) - 1, dither, (char *)buffer);
    552553    cucul_free_dither(dither);
    553554}
  • libcaca/trunk/test/dithering.c

    r811 r813  
    4141    int x, y;
    4242
    43     cv = cucul_create(0, 0);
     43    cv = cucul_create_canvas(0, 0);
    4444    dp = caca_attach(cv);
    4545
     
    119119        cucul_set_color(cv, points[nearb], points[neara]);
    120120
    121         cucul_putchar(cv, x * cucul_get_width(cv) / 100,
    122                           (100 - y) * cucul_get_height(cv) / 100, ch);
     121        cucul_putchar(cv, x * cucul_get_canvas_width(cv) / 100,
     122                          (100 - y) * cucul_get_canvas_height(cv) / 100, ch);
    123123    }
    124124
     
    128128
    129129    caca_detach(dp);
    130     cucul_free(cv);
     130    cucul_free_canvas(cv);
    131131
    132132    return 0;
  • libcaca/trunk/test/event.c

    r811 r813  
    3131    int i, h, quit;
    3232
    33     cv = cucul_create(0, 0);
     33    cv = cucul_create_canvas(0, 0);
    3434    if(!cv)
    3535        return 1;
     
    3838        return 1;
    3939
    40     h = cucul_get_height(cv) - 1;
     40    h = cucul_get_canvas_height(cv) - 1;
    4141
    4242    cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
    43     cucul_draw_line(cv, 0, 0, cucul_get_width(cv) - 1, 0, " ");
     43    cucul_draw_line(cv, 0, 0, cucul_get_canvas_width(cv) - 1, 0, " ");
    4444
    45     cucul_draw_line(cv, 0, h, cucul_get_width(cv) - 1, h, " ");
     45    cucul_draw_line(cv, 0, h, cucul_get_canvas_width(cv) - 1, h, " ");
    4646    cucul_putstr(cv, 0, h, "type \"quit\" to exit");
    4747
     
    8686        /* Print current event */
    8787        cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
    88         cucul_draw_line(cv, 0, 0, cucul_get_width(cv) - 1, 0, " ");
     88        cucul_draw_line(cv, 0, 0, cucul_get_canvas_width(cv) - 1, 0, " ");
    8989        print_event(0, 0, events);
    9090
    91         cucul_draw_line(cv, 0, h, cucul_get_width(cv) - 1, h, " ");
     91        cucul_draw_line(cv, 0, h, cucul_get_canvas_width(cv) - 1, h, " ");
    9292        cucul_printf(cv, 0, h, "type \"quit\" to exit: %s", quit_string[quit]);
    9393
     
    102102    /* Clean up */
    103103    caca_detach(dp);
    104     cucul_free(cv);
     104    cucul_free_canvas(cv);
    105105
    106106    return 0;
  • libcaca/trunk/test/export.c

    r811 r813  
    6666    }
    6767
    68     cv = cucul_create(WIDTH, HEIGHT);
     68    cv = cucul_create_canvas(WIDTH, HEIGHT);
    6969
    7070    for(y = 0; y < 256; y++)
     
    8181    dither = cucul_create_dither(32, 256, 256, 4 * 256,
    8282                                 0x00ff0000, 0x0000ff00, 0x000000ff, 0x0);
    83     cucul_dither_bitmap(cv, 0, 0,
    84                         cucul_get_width(cv) - 1, cucul_get_height(cv) - 1,
    85                         dither, pixels);
     83    cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv) - 1,
     84                        cucul_get_canvas_height(cv) - 1, dither, pixels);
    8685    cucul_free_dither(dither);
    8786
     
    108107    cucul_free_buffer(buffer);
    109108
    110     cucul_free(cv);
     109    cucul_free_canvas(cv);
    111110
    112111    return 0;
  • libcaca/trunk/test/font.c

    r811 r813  
    4545
    4646    /* Create a canvas */
    47     cv = cucul_create(8, 2);
     47    cv = cucul_create_canvas(8, 2);
    4848
    4949    /* Draw stuff on our canvas */
     
    7070
    7171    /* Create our bitmap buffer (32-bit ARGB) */
    72     w = cucul_get_width(cv) * cucul_get_font_width(f);
    73     h = cucul_get_height(cv) * cucul_get_font_height(f);
     72    w = cucul_get_canvas_width(cv) * cucul_get_font_width(f);
     73    h = cucul_get_canvas_height(cv) * cucul_get_font_height(f);
    7474    buf = malloc(4 * w * h);
    7575
     
    7878
    7979    /* Just for fun, render the image using libcaca */
    80     cucul_set_size(cv, 80, 32);
     80    cucul_set_canvas_size(cv, 80, 32);
    8181    dp = caca_attach(cv);
    8282
     
    9494                                0x0000ff00, 0x00ff0000, 0xff000000, 0x000000ff);
    9595
    96     cucul_dither_bitmap(cv, 0, 0, cucul_get_width(cv) - 1,
    97                                   cucul_get_height(cv) - 1, d, buf);
     96    cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv) - 1,
     97                                  cucul_get_canvas_height(cv) - 1, d, buf);
    9898    caca_display(dp);
    9999
     
    105105    cucul_free_dither(d);
    106106    cucul_free_font(f);
    107     cucul_free(cv);
     107    cucul_free_canvas(cv);
    108108
    109109    return 0;
  • libcaca/trunk/test/gamma.c

    r811 r813  
    4141    int x;
    4242
    43     cv = cucul_create(0, 0);
     43    cv = cucul_create_canvas(0, 0);
    4444    dp = caca_attach(cv);
    4545
    46     cw = cucul_create(cucul_get_width(cv), cucul_get_height(cv));
    47     mask = cucul_create(cucul_get_width(cv), cucul_get_height(cv));
     46    cw = cucul_create_canvas(cucul_get_canvas_width(cv), cucul_get_canvas_height(cv));
     47    mask = cucul_create_canvas(cucul_get_canvas_width(cv), cucul_get_canvas_height(cv));
    4848
    4949    for(x = 0; x < 256; x++)
     
    7878
    7979        /* Resize the spare canvas, just in case the main one changed */
    80         cucul_set_size(cw, cucul_get_width(cv), cucul_get_height(cv));
    81         cucul_set_size(mask, cucul_get_width(cv), cucul_get_height(cv));
     80        cucul_set_canvas_size(cw, cucul_get_canvas_width(cv), cucul_get_canvas_height(cv));
     81        cucul_set_canvas_size(mask, cucul_get_canvas_width(cv), cucul_get_canvas_height(cv));
    8282
    8383        /* Draw the regular dither on the main canvas */
    84         cucul_dither_bitmap(cv, 0, 0,
    85                             cucul_get_width(cv) - 1, cucul_get_height(cv) - 1,
    86                             left, buffer);
     84        cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv) - 1,
     85                            cucul_get_canvas_height(cv) - 1, left, buffer);
    8786
    8887        /* Draw the gamma-modified dither on the spare canvas */
    8988        cucul_set_dither_gamma(right, gam);
    90         cucul_dither_bitmap(cw, 0, 0,
    91                             cucul_get_width(cw) - 1, cucul_get_height(cw) - 1,
    92                             right, buffer);
     89        cucul_dither_bitmap(cw, 0, 0, cucul_get_canvas_width(cw) - 1,
     90                            cucul_get_canvas_height(cw) - 1, right, buffer);
    9391
    9492        /* Draw something on the mask */
     
    9694        cucul_set_color(mask, CUCUL_COLOR_WHITE, CUCUL_COLOR_WHITE);
    9795        cucul_fill_ellipse(mask, (1.0 + sin(0.05 * (float)x))
    98                                    * 0.5 * cucul_get_width(mask),
     96                                   * 0.5 * cucul_get_canvas_width(mask),
    9997                                 (1.0 + cos(0.05 * (float)x))
    100                                    * 0.5 * cucul_get_height(mask),
    101                                  cucul_get_width(mask) / 2,
    102                                  cucul_get_height(mask) / 2, "#");
     98                                   * 0.5 * cucul_get_canvas_height(mask),
     99                                 cucul_get_canvas_width(mask) / 2,
     100                                 cucul_get_canvas_height(mask) / 2, "#");
    103101
    104102        /* Blit the spare canvas onto the first one */
     
    116114
    117115    caca_detach(dp);
    118     cucul_free(cv);
     116    cucul_free_canvas(cv);
    119117
    120118    return 0;
  • libcaca/trunk/test/hsv.c

    r811 r813  
    3636    int x, y;
    3737
    38     cv = cucul_create(0, 0);
     38    cv = cucul_create_canvas(0, 0);
    3939    dp = caca_attach(cv);
    4040
     
    4747    dither = cucul_create_dither(32, 256, 256, 4 * 256,
    4848                                 0x00ff0000, 0x0000ff00, 0x000000ff, 0x0);
    49     cucul_dither_bitmap(cv, 0, 0,
    50                         cucul_get_width(cv) - 1, cucul_get_height(cv) - 1,
    51                         dither, buffer);
     49    cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv) - 1,
     50                        cucul_get_canvas_height(cv) - 1, dither, buffer);
    5251    cucul_free_dither(dither);
    5352
     
    5756
    5857    caca_detach(dp);
    59     cucul_free(cv);
     58    cucul_free_canvas(cv);
    6059
    6160    return 0;
  • libcaca/trunk/test/spritedit.c

    r811 r813  
    3838    }
    3939
    40     cv = cucul_create(0, 0);
     40    cv = cucul_create_canvas(0, 0);
    4141    if(!cv)
    4242        return 1;
     
    5050    {
    5151        caca_detach(dp);
    52         cucul_free(cv);
     52        cucul_free_canvas(cv);
    5353        fprintf(stderr, "%s: could not open `%s'.\n", argv[0], argv[1]);
    5454        return 1;
     
    104104
    105105        cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK);
    106         cucul_draw_thin_box(cv, 0, 0, cucul_get_width(cv) - 1, cucul_get_height(cv) - 1);
     106        cucul_draw_thin_box(cv, 0, 0, cucul_get_canvas_width(cv) - 1,
     107                            cucul_get_canvas_height(cv) - 1);
    107108
    108109        cucul_putstr(cv, 3, 0, "[ Sprite editor for libcaca ]");
     
    137138    /* Clean up */
    138139    caca_detach(dp);
    139     cucul_free(cv);
     140    cucul_free_canvas(cv);
    140141
    141142    return 0;
  • libcaca/trunk/test/transform.c

    r811 r813  
    5555    int i;
    5656
    57     cv = cucul_create(0, 0);
     57    cv = cucul_create_canvas(0, 0);
    5858    dp = caca_attach(cv);
    5959
    60     normal = cucul_create(70, 6);
    61     flip = cucul_create(70, 6);
    62     flop = cucul_create(70, 6);
    63     rotate = cucul_create(70, 6);
     60    normal = cucul_create_canvas(70, 6);
     61    flip = cucul_create_canvas(70, 6);
     62    flop = cucul_create_canvas(70, 6);
     63    rotate = cucul_create_canvas(70, 6);
    6464
    6565    cucul_set_color(normal, CUCUL_COLOR_LIGHTMAGENTA, CUCUL_COLOR_BLACK);
     
    112112
    113113    caca_detach(dp);
    114     cucul_free(rotate);
    115     cucul_free(flop);
    116     cucul_free(flip);
    117     cucul_free(normal);
    118     cucul_free(cv);
     114    cucul_free_canvas(rotate);
     115    cucul_free_canvas(flop);
     116    cucul_free_canvas(flip);
     117    cucul_free_canvas(normal);
     118    cucul_free_canvas(cv);
    119119
    120120    return 0;
  • libcaca/trunk/test/truecolor.c

    r811 r813  
    3333    int x, y;
    3434
    35     cv = cucul_create(32, 16);
     35    cv = cucul_create_canvas(32, 16);
    3636    dp = caca_attach(cv);
    3737
     
    5454
    5555    caca_detach(dp);
    56     cucul_free(cv);
     56    cucul_free_canvas(cv);
    5757
    5858    return 0;
  • libcaca/trunk/test/unicode.c

    r811 r813  
    3131    caca_display_t *dp;
    3232
    33     cv = cucul_create(0, 0);
     33    cv = cucul_create_canvas(0, 0);
    3434    dp = caca_attach(cv);
    3535
     
    9191
    9292    caca_detach(dp);
    93     cucul_free(cv);
     93    cucul_free_canvas(cv);
    9494
    9595    return 0;
Note: See TracChangeset for help on using the changeset viewer.