Changeset 1329 for libcaca/trunk/cucul/box.c
 Timestamp:
 Nov 11, 2006, 8:56:30 AM (14 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

libcaca/trunk/cucul/box.c
r982 r1329 100 100 101 101 /* Draw corners */ 102 if(x1 >= 0 && y1 >= 0) 103 cucul_putchar(cv, x1, y1, ','); 104 105 if(x1 >= 0 && y2 <= ymax) 106 cucul_putchar(cv, x1, y2, '`'); 107 108 if(x2 <= xmax && y1 >= 0) 109 cucul_putchar(cv, x2, y1, '.'); 110 111 if(x2 <= xmax && y2 <= ymax) 112 cucul_putchar(cv, x2, y2, '\''); 102 cucul_putchar(cv, x1, y1, ','); 103 cucul_putchar(cv, x1, y2, '`'); 104 cucul_putchar(cv, x2, y1, '.'); 105 cucul_putchar(cv, x2, y2, '\''); 106 107 return 0; 108 } 109 110 /** \brief Draw a box on the canvas using CP437 characters. 111 * 112 * This function never fails. 113 * 114 * \param cv The handle to the libcucul canvas. 115 * \param x1 X coordinate of the upperleft corner of the box. 116 * \param y1 Y coordinate of the upperleft corner of the box. 117 * \param x2 X coordinate of the lowerright corner of the box. 118 * \param y2 Y coordinate of the lowerright corner of the box. 119 * \return This function always returns 0. 120 */ 121 int cucul_draw_cp437_box(cucul_canvas_t *cv, int x1, int y1, int x2, int y2) 122 { 123 int x, y, xmax, ymax; 124 125 if(x1 > x2) 126 { 127 int tmp = x1; 128 x1 = x2; x2 = tmp; 129 } 130 131 if(y1 > y2) 132 { 133 int tmp = y1; 134 y1 = y2; y2 = tmp; 135 } 136 137 xmax = cv>width  1; 138 ymax = cv>height  1; 139 140 if(x2 < 0  y2 < 0  x1 > xmax  y1 > ymax) 141 return 0; 142 143 /* Draw edges */ 144 if(y1 >= 0) 145 for(x = x1 < 0 ? 1 : x1 + 1; x < x2 && x < xmax; x++) 146 cucul_putchar(cv, x, y1, 0x2500); /* ─ */ 147 148 if(y2 <= ymax) 149 for(x = x1 < 0 ? 1 : x1 + 1; x < x2 && x < xmax; x++) 150 cucul_putchar(cv, x, y2, 0x2500); /* ─ */ 151 152 if(x1 >= 0) 153 for(y = y1 < 0 ? 1 : y1 + 1; y < y2 && y < ymax; y++) 154 cucul_putchar(cv, x1, y, 0x2502); /* │ */ 155 156 if(x2 <= xmax) 157 for(y = y1 < 0 ? 1 : y1 + 1; y < y2 && y < ymax; y++) 158 cucul_putchar(cv, x2, y, 0x2502); /* │ */ 159 160 /* Draw corners */ 161 cucul_putchar(cv, x1, y1, 0x250c); /* ┌ */ 162 cucul_putchar(cv, x1, y2, 0x2514); /* └ */ 163 cucul_putchar(cv, x2, y1, 0x2510); /* ┐ */ 164 cucul_putchar(cv, x2, y2, 0x2518); /* ┘ */ 113 165 114 166 return 0;
Note: See TracChangeset
for help on using the changeset viewer.