Ignore:
Timestamp:
Nov 28, 2007, 5:43:32 PM (12 years ago)
Author:
Pascal Terjan
Message:
  • Improve Cucul::Canvas creation
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/ruby/cucul-canvas.c

    r2093 r2094  
    4141static VALUE canvas_alloc(VALUE klass)
    4242{
     43    VALUE obj;   
     44    obj = Data_Wrap_Struct(klass, 0, canvas_free, NULL);
     45    return obj;
     46}
     47
     48VALUE canvas_create(cucul_canvas_t *canvas)
     49{
     50    return Data_Wrap_Struct(cCanvas, 0, canvas_free, canvas);
     51}
     52
     53static VALUE canvas_initialize(VALUE self, VALUE width, VALUE height)
     54{
    4355    cucul_canvas_t *canvas;
    44     VALUE obj;
    45    
    46     canvas = cucul_create_canvas(0, 0);
    47     obj = Data_Wrap_Struct(klass, 0, canvas_free, canvas);
    48    
    49     return obj;
    50 }
    51 
    52 VALUE canvas_create(cucul_canvas_t *canvas)
    53 {
    54     return Data_Wrap_Struct(cCanvas, 0, canvas_free, canvas);
    55 }
    56 
    57 static VALUE canvas_initialize(VALUE self, VALUE width, VALUE height)
    58 {
    59     unsigned int w, h;
    60 
    61     w = NUM2INT(width);
    62     h = NUM2INT(height);
    63    
    64     cucul_set_canvas_size(_SELF, w, h);
    65    
     56
     57    canvas = cucul_create_canvas(NUM2INT(width), NUM2INT(height));
     58
     59    if(canvas == NULL)
     60    {
     61        rb_raise(rb_eRuntimeError, strerror(errno));
     62    }
     63
     64    _SELF = canvas;
     65
    6666    return self;
    6767}
Note: See TracChangeset for help on using the changeset viewer.