- Timestamp:
- Nov 13, 2006, 10:42:15 PM (16 years ago)
- Location:
- libcaca/trunk/cxx
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/cxx/cucul++.cpp
r1277 r1388 56 56 } 57 57 58 Cucul::Cucul(Buffer *b, char const *format)59 {60 cv = cucul_import_canvas(b->getBuffer(), format);61 if(!cv) throw -1;62 }63 64 58 Cucul::~Cucul() 65 59 { … … 100 94 void Cucul::putChar(int x, int y, unsigned long int ch) 101 95 { 102 cucul_put char(cv, x, y, ch);96 cucul_put_char(cv, x, y, ch); 103 97 } 104 98 105 99 unsigned long int Cucul::getChar(int x, int y) 106 100 { 107 return cucul_get char(cv, x, y);101 return cucul_get_char(cv, x, y); 108 102 } 109 103 110 104 void Cucul::putStr(int x, int y, char *str) 111 105 { 112 cucul_put str(cv, x, y, str);113 } 114 115 void Cucul::Printf(int x, int y, char const * format, ...)106 cucul_put_str(cv, x, y, str); 107 } 108 109 void Cucul::Printf(int x, int y, char const * format, ...) 116 110 { 117 111 char tmp[BUFSIZ]; … … 162 156 } 163 157 164 void Cucul::drawLine(int x1, int y1, int x2, int y2, char const *ch)158 void Cucul::drawLine(int x1, int y1, int x2, int y2, unsigned long int ch) 165 159 { 166 160 cucul_draw_line(cv, x1, y1, x2, y2, ch); 167 161 } 168 162 169 void Cucul::drawPolyline(int const x[], int const y[], int f, char const *ch)163 void Cucul::drawPolyline(int const x[], int const y[], int f, unsigned long int ch) 170 164 { 171 165 cucul_draw_polyline(cv, x, y, f, ch); … … 182 176 } 183 177 184 void Cucul::drawCircle(int x, int y, int d, char const *ch)178 void Cucul::drawCircle(int x, int y, int d, unsigned long int ch) 185 179 { 186 180 cucul_draw_circle(cv, x, y, d, ch); 187 181 } 188 182 189 void Cucul::drawEllipse(int x, int y, int d1, int d2, char const *ch)183 void Cucul::drawEllipse(int x, int y, int d1, int d2, unsigned long int ch) 190 184 { 191 185 cucul_draw_ellipse(cv, x, y, d1, d2, ch); … … 197 191 } 198 192 199 void Cucul::fillEllipse(int x, int y, int d1, int d2, char const *ch)193 void Cucul::fillEllipse(int x, int y, int d1, int d2, unsigned long int ch) 200 194 { 201 195 cucul_fill_ellipse(cv, x, y, d1, d2, ch); 202 196 } 203 197 204 void Cucul::drawBox(int x, int y, int w, int h, char const *ch)198 void Cucul::drawBox(int x, int y, int w, int h, unsigned long int ch) 205 199 { 206 200 cucul_draw_box(cv, x, y, w, h, ch); … … 212 206 } 213 207 214 void Cucul::fillBox(int x, int y, int w, int h, char const *ch) 208 void Cucul::drawCP437Box(int x, int y, int w, int h) 209 { 210 cucul_draw_cp437_box(cv, x, y, w, h); 211 } 212 213 void Cucul::fillBox(int x, int y, int w, int h, unsigned long int ch) 215 214 { 216 215 cucul_fill_box(cv, x, y, w, h, ch); 217 216 } 218 217 219 void Cucul::drawTriangle(int x1, int y1, int x2, int y2, int x3, int y3, char const *ch)218 void Cucul::drawTriangle(int x1, int y1, int x2, int y2, int x3, int y3, unsigned long int ch) 220 219 { 221 220 cucul_draw_triangle(cv, x1, y1, x2, y2, x3, y3, ch); … … 227 226 } 228 227 229 void Cucul::fillTriangle(int x1, int y1, int x2, int y2, int x3, int y3, const char *ch)228 void Cucul::fillTriangle(int x1, int y1, int x2, int y2, int x3, int y3, unsigned long int ch) 230 229 { 231 230 cucul_fill_triangle(cv, x1, y1, x2, y2, x3, y3, ch); … … 270 269 } 271 270 271 char const *const * Cucul::getImportList(void) 272 { 273 return cucul_get_import_list(); 274 } 275 276 long int Cucul::importMemory(void const *buf, unsigned long int len, char const *fmt) 277 { 278 return cucul_import_memory(cv, buf, len, fmt); 279 } 280 281 long int Cucul::importFile(char const *file, char const *fmt) 282 { 283 return cucul_import_file(cv, file, fmt); 284 } 285 286 char const *const * Cucul::getExportList(void) 287 { 288 return cucul_get_export_list(); 289 } 290 291 void *Cucul::exportMemory(char const *fmt, unsigned long int *len) 292 { 293 return cucul_export_memory(cv, fmt, len); 294 } 295 272 296 Dither::Dither(unsigned int v1, unsigned int v2, unsigned int v3, unsigned int v4, unsigned int v5, unsigned int v6, unsigned int v7, unsigned int v8) 273 297 { … … 385 409 } 386 410 387 Buffer::Buffer()388 {389 buffer_ = NULL;390 }391 392 Buffer::~Buffer()393 {394 if(buffer_)395 cucul_free_buffer(buffer_);396 }397 398 char const *const * Buffer::getExportList(void)399 {400 return cucul_get_export_list();401 }402 403 void *Buffer::getData(void)404 {405 return cucul_get_buffer_data(buffer_);406 }407 408 void Buffer::loadMemory(void *buf, unsigned long int size)409 {410 buffer_ = cucul_load_memory(buf, size);411 if(buffer_ == NULL)412 throw -1;413 }414 415 void Buffer::loadFile(char const *filename)416 {417 buffer_ = cucul_load_file(filename);418 if(buffer_ == NULL)419 throw -1;420 }421 422 unsigned long int Buffer::getSize()423 {424 return cucul_get_buffer_size(buffer_);425 }426 427 cucul_buffer *Buffer::getBuffer()428 {429 return buffer_;430 } -
libcaca/trunk/cxx/cucul++.h
r1278 r1388 26 26 #include <cucul.h> 27 27 28 29 28 class Cucul; 30 31 29 32 30 class Charset … … 37 35 unsigned long int cp437ToUtf32(unsigned char); 38 36 }; 39 40 41 42 43 37 44 38 /* Ugly, I know */ … … 51 45 unsigned int getWidth(); 52 46 unsigned int getHeight(); 53 void renderCanvas(Cucul *, unsigned char *, unsigned int, unsigned int, unsigned int); 47 void renderCanvas(Cucul *, unsigned char *, unsigned int, 48 unsigned int, unsigned int); 54 49 unsigned long int const *getBlocks(); 55 50 56 51 private: 57 52 cucul_font *font; 58 59 53 }; 60 54 … … 62 56 { 63 57 public: 64 Dither(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int); 58 Dither(unsigned int, unsigned int, unsigned int, unsigned int, 59 unsigned int, unsigned int, unsigned int, unsigned int); 65 60 ~Dither(); 66 61 67 void setPalette(unsigned int r[], unsigned int g[], unsigned int b[], unsigned int a[]); 62 void setPalette(unsigned int r[], unsigned int g[], 63 unsigned int b[], unsigned int a[]); 68 64 void setBrightness(float); 69 65 void setGamma(float); … … 82 78 private: 83 79 cucul_dither *dither; 84 85 80 }; 86 87 class Buffer88 {89 friend class Cucul;90 public:91 Buffer();92 ~Buffer();93 char const *const * getExportList(void);94 void *getData(void);95 void loadMemory(void *buf, unsigned long int size);96 void loadFile(char const *filename);97 unsigned long int getSize();98 99 protected:100 cucul_buffer *get_buffer();101 102 private:103 cucul_buffer *buffer_;104 cucul_buffer *getBuffer();105 };106 107 81 108 82 class Cucul … … 111 85 friend class Dither; 112 86 friend class Font; 113 friend class Buffer;114 87 public: 115 88 Cucul(); 116 89 Cucul(int width, int height); 117 Cucul(Buffer *, char const *);118 90 ~Cucul(); 119 91 … … 125 97 int setColorANSI(unsigned char f, unsigned char b); 126 98 int setColorARGB(unsigned int f, unsigned int b); 127 void Printf(int x , int y , char const * format,...);99 void Printf(int x, int y , char const * format, ...); 128 100 void putChar(int x, int y, unsigned long int ch); 129 101 unsigned long int getChar(int, int); … … 135 107 void Flop(); 136 108 void Rotate(); 137 void drawLine(int, int, int, int, char const *);138 void drawPolyline(int const x[], int const y[], int, char const *);109 void drawLine(int, int, int, int, unsigned long int); 110 void drawPolyline(int const x[], int const y[], int, unsigned long int); 139 111 void drawThinLine(int, int, int, int); 140 112 void drawThinPolyline(int const x[], int const y[], int); 141 void drawCircle(int, int, int, char const *);142 void drawEllipse(int, int, int, int, char const *);113 void drawCircle(int, int, int, unsigned long int); 114 void drawEllipse(int, int, int, int, unsigned long int); 143 115 void drawThinEllipse(int, int, int, int); 144 void fillEllipse(int, int, int, int, char const *);145 void drawBox(int, int, int, int, char const *);116 void fillEllipse(int, int, int, int, unsigned long int); 117 void drawBox(int, int, int, int, unsigned long int); 146 118 void drawThinBox(int, int, int, int); 147 void fillBox(int, int, int, int, char const *); 148 void drawTriangle(int, int, int, int, int, int, char const *); 119 void drawCP437Box(int, int, int, int); 120 void fillBox(int, int, int, int, unsigned long int); 121 void drawTriangle(int, int, int, int, int, int, unsigned long int); 149 122 void drawThinTriangle(int, int, int, int, int, int); 150 void fillTriangle(int, int, int, int, int, int, char const *);123 void fillTriangle(int, int, int, int, int, int, unsigned long int); 151 124 int Rand(int, int); 152 int setBoundaries(cucul_canvas_t *, int, int, 153 unsigned int, unsigned int); 125 int setBoundaries(cucul_canvas_t *, int, int, unsigned int, unsigned int); 154 126 unsigned int getFrameCount(); 155 127 int setFrame(unsigned int); 156 128 int createFrame(unsigned int); 157 129 int freeFrame(unsigned int); 130 131 char const * const * getImportList(void); 132 long int importMemory(void const *, unsigned long int, char const *); 133 long int importFile(char const *, char const *); 134 char const * const * getExportList(void); 135 void *exportMemory(char const *, unsigned long int *); 158 136 159 137 protected: … … 164 142 }; 165 143 166 167 144 #endif /* _CUCUL_PP_H */ -
libcaca/trunk/cxx/cxxtest.cpp
r1310 r1388 65 65 try { 66 66 // Import buffer into a canvas 67 Buffer *buf = new Buffer(); 68 buf->loadMemory((void *)pigstring, strlen(pigstring)); 69 pig = new Cucul(buf, "text"); 70 delete buf; 71 // Change colour to magenta 67 pig = new Cucul(); 72 68 pig->setColorANSI(CUCUL_LIGHTMAGENTA, CUCUL_TRANSPARENT); 73 for(int y = 0; y < pig->getHeight(); y++) 74 for(int x = 0; x < pig->getWidth(); x++) 75 pig->putChar(x, y, pig->getChar(x, y)); 69 pig->importMemory(pigstring, strlen(pigstring), "text"); 76 70 } 77 71 catch(int e) {
Note: See TracChangeset
for help on using the changeset viewer.