Changeset 1995 for libcaca/trunk/ruby
- Timestamp:
- Nov 16, 2007, 11:24:35 PM (13 years ago)
- Location:
- libcaca/trunk/ruby
- Files:
-
- 4 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/ruby/Makefile.am
r1983 r1995 8 8 9 9 cucul_la_CPPFLAGS = -I$(top_srcdir)/cucul -I$(RUBY_ARCHDIR) 10 cucul_la_SOURCES = cucul.c cucul-canvas.c 10 cucul_la_SOURCES = cucul.c cucul-canvas.c cucul-font.c 11 11 cucul_la_LDFLAGS = -module -avoid-version -shared -L$(RUBY_LIBDIR) -l$(RUBY_SO_NAME) 12 12 cucul_la_LIBADD = ../cucul/libcucul.la 13 13 14 14 EXTRA_DIST = cucul-canvas.h \ 15 cucul-canvas.h \ 16 common.h \ 15 17 test.rb \ 16 18 t/tc_frame.rb \ -
libcaca/trunk/ruby/cucul-canvas.c
r1964 r1995 13 13 #include <cucul.h> 14 14 #include <errno.h> 15 #include "cucul-canvas.h" 16 17 #define _SELF (DATA_PTR(self)) 15 #include "cucul-font.h" 16 #include "common.h" 17 18 VALUE cCanvas; 18 19 19 20 #define simple_func(x) \ … … 202 203 Check_Type(x, T_FIXNUM); 203 204 Check_Type(y, T_FIXNUM); 205 //FIXME rather check that class is cCanvas 204 206 Check_Type(src, TYPE(self)); 205 207 Data_Get_Struct(src, cucul_canvas_t, csrc); 206 208 if(!NIL_P(mask)) 207 209 { 210 //FIXME rather check that class is cCanvas 208 211 Check_Type(mask, TYPE(self)); 209 212 Data_Get_Struct(mask, cucul_canvas_t, cmask); … … 485 488 /****/ 486 489 490 static VALUE render_canvas(VALUE self, VALUE font, VALUE width, VALUE height, VALUE pitch) 491 { 492 void *buf; 493 cucul_font_t *f; 494 VALUE b; 495 496 //FIXME rather check that class is cFont 497 Check_Type(font, TYPE(self)); 498 499 buf = malloc(width*height*4); 500 if(buf == NULL) 501 { 502 rb_raise(rb_eNoMemError, "Out of memory"); 503 } 504 505 f = DATA_PTR(font); 506 cucul_render_canvas(_SELF, f, buf, NUM2UINT(width), NUM2UINT(height), NUM2UINT(pitch)); 507 508 b = rb_str_new(buf, width*height*4); 509 free(buf); 510 return b; 511 } 512 487 513 static VALUE import_memory(VALUE self, VALUE data, VALUE format) 488 514 { … … 566 592 void Init_cucul_canvas(VALUE mCucul) 567 593 { 568 VALUEcCanvas = rb_define_class_under(mCucul, "Canvas", rb_cObject);594 cCanvas = rb_define_class_under(mCucul, "Canvas", rb_cObject); 569 595 rb_define_alloc_func(cCanvas, canvas_alloc); 570 596 … … 635 661 rb_define_method(cCanvas, "free_frame", free_frame, 1); 636 662 663 rb_define_method(cCanvas, "render", render_canvas, 4); 637 664 rb_define_method(cCanvas, "import_memory", import_memory, 2); 638 665 rb_define_method(cCanvas, "import_file", import_file, 2); -
libcaca/trunk/ruby/cucul-canvas.h
r1961 r1995 2 2 #define __CUCUL_CANVAS_H__ 3 3 4 #include <ruby.h> 5 6 extern VALUE cCanvas; 4 7 extern void Init_cucul_canvas(VALUE); 5 8 -
libcaca/trunk/ruby/cucul.c
r1961 r1995 14 14 15 15 #include "cucul-canvas.h" 16 17 static VALUE mCucul; 16 #include "cucul-font.h" 18 17 19 18 void Init_cucul() 20 19 { 21 mCucul = rb_define_module("Cucul");20 VALUE mCucul = rb_define_module("Cucul"); 22 21 23 22 rb_define_const(mCucul, "BLACK", INT2FIX(CUCUL_BLACK)); … … 46 45 47 46 Init_cucul_canvas(mCucul); 47 Init_cucul_font(mCucul); 48 48 } -
libcaca/trunk/ruby/t/tc_canvas.rb
r1966 r1995 45 45 assert_equal(42, @c.get_char(1,1)) 46 46 end 47 def test_render 48 c = Cucul::Canvas.new(4,4) 49 c.put_str(0,0,"plop") 50 f = Cucul::Font.new(Cucul::Font.list[0]) 51 assert_not_nil(c.render(f, c.width*f.width, c.height*f.height, c.width*f.width*4)) 52 end 47 53 end
Note: See TracChangeset
for help on using the changeset viewer.