Ignore:
Timestamp:
Sep 27, 2008, 3:12:46 PM (11 years ago)
Author:
Sam Hocevar
Message:

Starting refactoring to get rid of libcucul. The initial reason for the
split is rendered moot by the plugin system: when enabled, binaries do
not link directly with libX11 or libGL. I hope this is a step towards
more consisteny and clarity.

File:
1 copied

Legend:

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

    r2819 r2821  
    11/*
    2  *  libcucul      Canvas for ultrafast compositing of Unicode letters
     2 *  libcaca       Colour ASCII-Art library
    33 *  Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
    44 *                All Rights Reserved
     
    2424#endif
    2525
    26 #include "cucul.h"
    27 #include "cucul_internals.h"
     26#include "caca.h"
     27#include "caca_internals.h"
    2828
    2929#if !defined(_DOXYGEN_SKIP_ME)
     
    3333    int x2, y2;
    3434    uint32_t ch;
    35     void (*draw) (cucul_canvas_t *, struct line*);
     35    void (*draw) (caca_canvas_t *, struct line*);
    3636};
    3737#endif
    3838
    39 static void clip_line(cucul_canvas_t*, struct line*);
    40 static uint8_t clip_bits(cucul_canvas_t*, int, int);
    41 static void draw_solid_line(cucul_canvas_t*, struct line*);
    42 static void draw_thin_line(cucul_canvas_t*, struct line*);
     39static void clip_line(caca_canvas_t*, struct line*);
     40static uint8_t clip_bits(caca_canvas_t*, int, int);
     41static void draw_solid_line(caca_canvas_t*, struct line*);
     42static void draw_thin_line(caca_canvas_t*, struct line*);
    4343
    4444/** \brief Draw a line on the canvas using the given character.
     
    4646 *  This function never fails.
    4747 *
    48  *  \param cv The handle to the libcucul canvas.
     48 *  \param cv The handle to the libcaca canvas.
    4949 *  \param x1 X coordinate of the first point.
    5050 *  \param y1 Y coordinate of the first point.
     
    5454 *  \return This function always returns 0.
    5555 */
    56 int cucul_draw_line(cucul_canvas_t *cv, int x1, int y1, int x2, int y2,
     56int caca_draw_line(caca_canvas_t *cv, int x1, int y1, int x2, int y2,
    5757                    uint32_t ch)
    5858{
     
    7878 *  This function never fails.
    7979 *
    80  *  \param cv The handle to the libcucul canvas.
     80 *  \param cv The handle to the libcaca canvas.
    8181 *  \param x Array of X coordinates. Must have \p n + 1 elements.
    8282 *  \param y Array of Y coordinates. Must have \p n + 1 elements.
     
    8585 *  \return This function always returns 0.
    8686 */
    87 int cucul_draw_polyline(cucul_canvas_t *cv, int const x[], int const y[],
     87int caca_draw_polyline(caca_canvas_t *cv, int const x[], int const y[],
    8888                        int n, uint32_t ch)
    8989{
     
    109109 *  This function never fails.
    110110 *
    111  *  \param cv The handle to the libcucul canvas.
     111 *  \param cv The handle to the libcaca canvas.
    112112 *  \param x1 X coordinate of the first point.
    113113 *  \param y1 Y coordinate of the first point.
     
    116116 *  \return This function always returns 0.
    117117 */
    118 int cucul_draw_thin_line(cucul_canvas_t *cv, int x1, int y1, int x2, int y2)
     118int caca_draw_thin_line(caca_canvas_t *cv, int x1, int y1, int x2, int y2)
    119119{
    120120    struct line s;
     
    138138 *  This function never fails.
    139139 *
    140  *  \param cv The handle to the libcucul canvas.
     140 *  \param cv The handle to the libcaca canvas.
    141141 *  \param x Array of X coordinates. Must have \p n + 1 elements.
    142142 *  \param y Array of Y coordinates. Must have \p n + 1 elements.
     
    144144 *  \return This function always returns 0.
    145145 */
    146 int cucul_draw_thin_polyline(cucul_canvas_t *cv, int const x[], int const y[],
     146int caca_draw_thin_polyline(caca_canvas_t *cv, int const x[], int const y[],
    147147                             int n)
    148148{
     
    168168
    169169/* Generic Cohen-Sutherland line clipping function. */
    170 static void clip_line(cucul_canvas_t *cv, struct line* s)
     170static void clip_line(caca_canvas_t *cv, struct line* s)
    171171{
    172172    uint8_t bits1, bits2;
     
    220220
    221221/* Helper function for clip_line(). */
    222 static uint8_t clip_bits(cucul_canvas_t *cv, int x, int y)
     222static uint8_t clip_bits(caca_canvas_t *cv, int x, int y)
    223223{
    224224    uint8_t b = 0;
     
    239239/* Solid line drawing function, using Bresenham's mid-point line
    240240 * scan-conversion algorithm. */
    241 static void draw_solid_line(cucul_canvas_t *cv, struct line* s)
     241static void draw_solid_line(caca_canvas_t *cv, struct line* s)
    242242{
    243243    int x1, y1, x2, y2;
     
    261261        for(; dx>=0; dx--)
    262262        {
    263             cucul_put_char(cv, x1, y1, s->ch);
     263            caca_put_char(cv, x1, y1, s->ch);
    264264            if(delta > 0)
    265265            {
     
    283283        for(; dy >= 0; dy--)
    284284        {
    285             cucul_put_char(cv, x1, y1, s->ch);
     285            caca_put_char(cv, x1, y1, s->ch);
    286286            if(delta > 0)
    287287            {
     
    301301/* Thin line drawing function, using Bresenham's mid-point line
    302302 * scan-conversion algorithm and ASCII art graphics. */
    303 static void draw_thin_line(cucul_canvas_t *cv, struct line* s)
     303static void draw_thin_line(caca_canvas_t *cv, struct line* s)
    304304{
    305305    uint32_t charmapx[2], charmapy[2];
     
    348348            if(delta > 0)
    349349            {
    350                 cucul_put_char(cv, x1, y1, charmapy[1]);
     350                caca_put_char(cv, x1, y1, charmapy[1]);
    351351                x1++;
    352352                y1 += yinc;
     
    357357            {
    358358                if(prev)
    359                     cucul_put_char(cv, x1, y1, charmapy[0]);
     359                    caca_put_char(cv, x1, y1, charmapy[0]);
    360360                else
    361                     cucul_put_char(cv, x1, y1, '-');
     361                    caca_put_char(cv, x1, y1, '-');
    362362                x1++;
    363363                delta += dpr;
     
    376376            if(delta > 0)
    377377            {
    378                 cucul_put_char(cv, x1, y1, charmapx[0]);
    379                 cucul_put_char(cv, x1 + 1, y1, charmapx[1]);
     378                caca_put_char(cv, x1, y1, charmapx[0]);
     379                caca_put_char(cv, x1 + 1, y1, charmapx[1]);
    380380                x1++;
    381381                y1 += yinc;
     
    384384            else
    385385            {
    386                 cucul_put_char(cv, x1, y1, '|');
     386                caca_put_char(cv, x1, y1, '|');
    387387                y1 += yinc;
    388388                delta += dpr;
Note: See TracChangeset for help on using the changeset viewer.