Changeset 2821 for libcaca/trunk/caca/line.c
- Timestamp:
- Sep 27, 2008, 3:12:46 PM (12 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/caca/line.c
r2819 r2821 1 1 /* 2 * libc ucul Canvas for ultrafast compositing of Unicode letters2 * libcaca Colour ASCII-Art library 3 3 * Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org> 4 4 * All Rights Reserved … … 24 24 #endif 25 25 26 #include "c ucul.h"27 #include "c ucul_internals.h"26 #include "caca.h" 27 #include "caca_internals.h" 28 28 29 29 #if !defined(_DOXYGEN_SKIP_ME) … … 33 33 int x2, y2; 34 34 uint32_t ch; 35 void (*draw) (c ucul_canvas_t *, struct line*);35 void (*draw) (caca_canvas_t *, struct line*); 36 36 }; 37 37 #endif 38 38 39 static void clip_line(c ucul_canvas_t*, struct line*);40 static uint8_t clip_bits(c ucul_canvas_t*, int, int);41 static void draw_solid_line(c ucul_canvas_t*, struct line*);42 static void draw_thin_line(c ucul_canvas_t*, struct line*);39 static void clip_line(caca_canvas_t*, struct line*); 40 static uint8_t clip_bits(caca_canvas_t*, int, int); 41 static void draw_solid_line(caca_canvas_t*, struct line*); 42 static void draw_thin_line(caca_canvas_t*, struct line*); 43 43 44 44 /** \brief Draw a line on the canvas using the given character. … … 46 46 * This function never fails. 47 47 * 48 * \param cv The handle to the libc uculcanvas.48 * \param cv The handle to the libcaca canvas. 49 49 * \param x1 X coordinate of the first point. 50 50 * \param y1 Y coordinate of the first point. … … 54 54 * \return This function always returns 0. 55 55 */ 56 int c ucul_draw_line(cucul_canvas_t *cv, int x1, int y1, int x2, int y2,56 int caca_draw_line(caca_canvas_t *cv, int x1, int y1, int x2, int y2, 57 57 uint32_t ch) 58 58 { … … 78 78 * This function never fails. 79 79 * 80 * \param cv The handle to the libc uculcanvas.80 * \param cv The handle to the libcaca canvas. 81 81 * \param x Array of X coordinates. Must have \p n + 1 elements. 82 82 * \param y Array of Y coordinates. Must have \p n + 1 elements. … … 85 85 * \return This function always returns 0. 86 86 */ 87 int c ucul_draw_polyline(cucul_canvas_t *cv, int const x[], int const y[],87 int caca_draw_polyline(caca_canvas_t *cv, int const x[], int const y[], 88 88 int n, uint32_t ch) 89 89 { … … 109 109 * This function never fails. 110 110 * 111 * \param cv The handle to the libc uculcanvas.111 * \param cv The handle to the libcaca canvas. 112 112 * \param x1 X coordinate of the first point. 113 113 * \param y1 Y coordinate of the first point. … … 116 116 * \return This function always returns 0. 117 117 */ 118 int c ucul_draw_thin_line(cucul_canvas_t *cv, int x1, int y1, int x2, int y2)118 int caca_draw_thin_line(caca_canvas_t *cv, int x1, int y1, int x2, int y2) 119 119 { 120 120 struct line s; … … 138 138 * This function never fails. 139 139 * 140 * \param cv The handle to the libc uculcanvas.140 * \param cv The handle to the libcaca canvas. 141 141 * \param x Array of X coordinates. Must have \p n + 1 elements. 142 142 * \param y Array of Y coordinates. Must have \p n + 1 elements. … … 144 144 * \return This function always returns 0. 145 145 */ 146 int c ucul_draw_thin_polyline(cucul_canvas_t *cv, int const x[], int const y[],146 int caca_draw_thin_polyline(caca_canvas_t *cv, int const x[], int const y[], 147 147 int n) 148 148 { … … 168 168 169 169 /* Generic Cohen-Sutherland line clipping function. */ 170 static void clip_line(c ucul_canvas_t *cv, struct line* s)170 static void clip_line(caca_canvas_t *cv, struct line* s) 171 171 { 172 172 uint8_t bits1, bits2; … … 220 220 221 221 /* Helper function for clip_line(). */ 222 static uint8_t clip_bits(c ucul_canvas_t *cv, int x, int y)222 static uint8_t clip_bits(caca_canvas_t *cv, int x, int y) 223 223 { 224 224 uint8_t b = 0; … … 239 239 /* Solid line drawing function, using Bresenham's mid-point line 240 240 * scan-conversion algorithm. */ 241 static void draw_solid_line(c ucul_canvas_t *cv, struct line* s)241 static void draw_solid_line(caca_canvas_t *cv, struct line* s) 242 242 { 243 243 int x1, y1, x2, y2; … … 261 261 for(; dx>=0; dx--) 262 262 { 263 c ucul_put_char(cv, x1, y1, s->ch);263 caca_put_char(cv, x1, y1, s->ch); 264 264 if(delta > 0) 265 265 { … … 283 283 for(; dy >= 0; dy--) 284 284 { 285 c ucul_put_char(cv, x1, y1, s->ch);285 caca_put_char(cv, x1, y1, s->ch); 286 286 if(delta > 0) 287 287 { … … 301 301 /* Thin line drawing function, using Bresenham's mid-point line 302 302 * scan-conversion algorithm and ASCII art graphics. */ 303 static void draw_thin_line(c ucul_canvas_t *cv, struct line* s)303 static void draw_thin_line(caca_canvas_t *cv, struct line* s) 304 304 { 305 305 uint32_t charmapx[2], charmapy[2]; … … 348 348 if(delta > 0) 349 349 { 350 c ucul_put_char(cv, x1, y1, charmapy[1]);350 caca_put_char(cv, x1, y1, charmapy[1]); 351 351 x1++; 352 352 y1 += yinc; … … 357 357 { 358 358 if(prev) 359 c ucul_put_char(cv, x1, y1, charmapy[0]);359 caca_put_char(cv, x1, y1, charmapy[0]); 360 360 else 361 c ucul_put_char(cv, x1, y1, '-');361 caca_put_char(cv, x1, y1, '-'); 362 362 x1++; 363 363 delta += dpr; … … 376 376 if(delta > 0) 377 377 { 378 c ucul_put_char(cv, x1, y1, charmapx[0]);379 c ucul_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]); 380 380 x1++; 381 381 y1 += yinc; … … 384 384 else 385 385 { 386 c ucul_put_char(cv, x1, y1, '|');386 caca_put_char(cv, x1, y1, '|'); 387 387 y1 += yinc; 388 388 delta += dpr;
Note: See TracChangeset
for help on using the changeset viewer.