Object
Return the current context.
Example:
ctx = Imlib2::Context.get
VALUE ctx_get(VALUE klass) {
Imlib_Context *ctx;
ctx = (Imlib_Context *) malloc(sizeof(Imlib_Context));
*ctx = imlib_context_get();
return Data_Wrap_Struct(klass, 0, ctx_free, ctx);
}
Return the current context.
Example:
ctx = Imlib2::Context.get
VALUE ctx_get(VALUE klass) {
Imlib_Context *ctx;
ctx = (Imlib_Context *) malloc(sizeof(Imlib_Context));
*ctx = imlib_context_get();
return Data_Wrap_Struct(klass, 0, ctx_free, ctx);
}
Return a new Imlib2::Context.
Example:
ctx = Imlib2::Context.new
VALUE ctx_new(VALUE klass) {
VALUE self;
Imlib_Context *ctx;
ctx = malloc(sizeof(Imlib_Context));
*ctx = imlib_context_new();
self = Data_Wrap_Struct(klass, 0, ctx_free, ctx);
rb_obj_call_init(self, 0, NULL);
return self;
}
Pop the top context off the context stack.
Example:
ctx = Imlib2::Context.pop
VALUE ctx_pop(VALUE klass) {
Imlib_Context *ctx;
ctx = (Imlib_Context *) malloc(sizeof(Imlib_Context));
imlib_context_pop();
*ctx = imlib_context_get();
return Data_Wrap_Struct(klass, 0, ctx_free, ctx);
}
Get the anti_alias flag.
Example:
if ctx.anti_alias == true puts 'anti_alias enabled.' end
static VALUE ctx_aa(VALUE self) {
Imlib_Context *ctx;
VALUE r = Qfalse;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
r = imlib_context_get_anti_alias() ? Qtrue : Qfalse;
imlib_context_pop();
return r;
}
Set the anti_alias flag.
Example:
ctx.anti_alias = true
static VALUE ctx_set_aa(VALUE self, VALUE val) {
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_set_anti_alias(val != Qnil && val != Qfalse);
imlib_context_pop();
return self;
}
Get the text drawing angle.
Example:
if ctx.dir == Imlib2::Direction::ANGLE puts 'the current font angle is ' << ctx.angle end
static VALUE ctx_angle(VALUE self) {
Imlib_Context *ctx;
VALUE r = Qnil;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
r = rb_float_new(imlib_context_get_angle());
imlib_context_pop();
return r;
}
Set the text drawing angle.
Example:
ctx.angle = 76.8
static VALUE ctx_set_angle(VALUE self, VALUE val) {
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_set_angle(NUM2DBL(val));
imlib_context_pop();
return self;
}
Get the anti_alias flag.
Example:
if ctx.anti_alias == true puts 'anti_alias enabled.' end
static VALUE ctx_aa(VALUE self) {
Imlib_Context *ctx;
VALUE r = Qfalse;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
r = imlib_context_get_anti_alias() ? Qtrue : Qfalse;
imlib_context_pop();
return r;
}
Set the anti_alias flag.
Example:
ctx.anti_alias = true
static VALUE ctx_set_aa(VALUE self, VALUE val) {
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_set_anti_alias(val != Qnil && val != Qfalse);
imlib_context_pop();
return self;
}
Get the current X11 Visual.
Note: This method is not available unless Imlib2-Ruby was compiled with X11 support. You can check the constant Imlib2::X11_SUPPORT to see if X11 support is available.
Examples:
visual = context.get_visual visual = context.visual
static VALUE ctx_visual(VALUE self) {
Imlib_Context *ctx;
VALUE vis;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
vis = Data_Wrap_Struct(cVisual, NULL, XFree, imlib_context_get_visual());
imlib_context_pop();
return vis;
}
Get the blend flag.
Example:
if ctx.blend puts 'blend enabled.' end
static VALUE ctx_blend(VALUE self) {
Imlib_Context *ctx;
VALUE r = Qfalse;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
r = imlib_context_get_blend() ? Qtrue : Qfalse;
imlib_context_pop();
return r;
}
Set the blend flag.
Example:
ctx.blend = true
static VALUE ctx_set_blend(VALUE self, VALUE val) {
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_set_blend(val != Qnil && val != Qfalse);
imlib_context_pop();
return self;
}
Get the cliprect.
Example:
x, y, w, h = ctx.cliprect
static VALUE ctx_cliprect(VALUE self) {
Imlib_Context *ctx;
int i, r[4];
VALUE ary;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_get_cliprect(&(r[0]), &(r[1]), &(r[2]), &(r[3]));
imlib_context_pop();
ary = rb_ary_new();
for (i = 0; i < 4; i++);
rb_ary_push(ary, NUM2INT(r[i]));
return ary;
}
Set the cliprect.
Example:
ctx.cliprect = [10, 10, 100, 100]
static VALUE ctx_set_cliprect(VALUE self, VALUE val) {
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_set_cliprect(
NUM2INT(rb_ary_entry(val, 0)),
NUM2INT(rb_ary_entry(val, 1)),
NUM2INT(rb_ary_entry(val, 2)),
NUM2INT(rb_ary_entry(val, 3))
);
imlib_context_pop();
return self;
}
Get the current color modifier (Imlib2::ColorModifier).
Example:
cmod = ctx.cmod
static VALUE ctx_cmod(VALUE self) {
Imlib_Context *ctx;
Imlib_Color_Modifier *cmod;
cmod = malloc(sizeof(Imlib_Color_Modifier));
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
*cmod = imlib_context_get_color_modifier();
imlib_context_pop();
return Data_Wrap_Struct(cColorMod, 0, cmod_free, cmod);
}
Set the current color modifier (Imlib2::ColorModifier).
Example:
ctx.cmod = cmod
static VALUE ctx_set_cmod(VALUE self, VALUE val) {
Imlib_Context *ctx;
Imlib_Color_Modifier *cmod;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
Data_Get_Struct(val, Imlib_Color_Modifier, cmod);
imlib_context_set_color_modifier(*cmod);
imlib_context_pop();
return self;
}
Get the current color (Imlib2::Color::RgbaColor).
Example:
color = ctx.color
static VALUE ctx_color(VALUE self) {
Imlib_Context *ctx;
VALUE argv[4];
int i, r[4];
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_get_color(&(r[0]), &(r[1]), &(r[2]), &(r[3]));
imlib_context_pop();
for (i = 0; i < 4; i++)
argv[i] = INT2NUM(r[i]);
return rgba_color_new(4, argv, cRgbaColor);
}
Set the current color (Imlib2::Color).
Example:
ctx.color = Imlib2::Color::LIGHTGRAY
static VALUE ctx_set_color(VALUE self, VALUE val) {
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
set_context_color(val);
imlib_context_pop();
return self;
}
Get the current color modifier (Imlib2::ColorModifier).
Example:
cmod = ctx.cmod
static VALUE ctx_cmod(VALUE self) {
Imlib_Context *ctx;
Imlib_Color_Modifier *cmod;
cmod = malloc(sizeof(Imlib_Color_Modifier));
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
*cmod = imlib_context_get_color_modifier();
imlib_context_pop();
return Data_Wrap_Struct(cColorMod, 0, cmod_free, cmod);
}
Set the current color modifier (Imlib2::ColorModifier).
Example:
ctx.cmod = cmod
static VALUE ctx_set_cmod(VALUE self, VALUE val) {
Imlib_Context *ctx;
Imlib_Color_Modifier *cmod;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
Data_Get_Struct(val, Imlib_Color_Modifier, cmod);
imlib_context_set_color_modifier(*cmod);
imlib_context_pop();
return self;
}
Get the current font direction (Imlib2::Dir or Imlib2::Direction).
Example:
if ctx.direction != Imlib2::Direction::RIGHT puts 'drawing funny text' end
static VALUE ctx_dir(VALUE self) {
Imlib_Context *ctx;
VALUE r = Qnil;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
r = INT2FIX(imlib_context_get_direction());
imlib_context_pop();
return r;
}
Set the current font direction (Imlib2::Dir or Imlib2::Direction).
Example:
ctx.direction = Imlib2::Direction::LEFT
static VALUE ctx_set_dir(VALUE self, VALUE val) {
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_set_direction(NUM2INT(val));
imlib_context_pop();
return self;
}
Get the current font direction (Imlib2::Dir or Imlib2::Direction).
Example:
if ctx.direction != Imlib2::Direction::RIGHT puts 'drawing funny text' end
static VALUE ctx_dir(VALUE self) {
Imlib_Context *ctx;
VALUE r = Qnil;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
r = INT2FIX(imlib_context_get_direction());
imlib_context_pop();
return r;
}
Set the current font direction (Imlib2::Dir or Imlib2::Direction).
Example:
ctx.direction = Imlib2::Direction::LEFT
static VALUE ctx_set_dir(VALUE self, VALUE val) {
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_set_direction(NUM2INT(val));
imlib_context_pop();
return self;
}
Get the current X11 Display.
Note: This method is not available unless Imlib2-Ruby was compiled with X11 support. You can check the constant Imlib2::X11_SUPPORT to see if X11 support is available.
Examples:
display = context.get_display display = context.display
static VALUE ctx_display(VALUE self) {
Imlib_Context *ctx;
VALUE disp;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
disp = Data_Wrap_Struct(cDisplay, NULL, XFree, imlib_context_get_display());
imlib_context_pop();
return disp;
}
Set the current X11 Display.
Note: This method is not available unless Imlib2-Ruby was compiled with X11 support. You can check the constant Imlib2::X11_SUPPORT to see if X11 support is available.
Examples:
context.set_display display context.display = display
static VALUE ctx_set_display(VALUE self, VALUE display) {
Display *disp;
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
Data_Get_Struct(display, Display, disp);
imlib_context_push(*ctx);
imlib_context_set_display(disp);
imlib_context_pop();
return display;
}
Get the dither flag.
Example:
if ctx.dither puts 'dither enabled.' end
static VALUE ctx_dither(VALUE self) {
Imlib_Context *ctx;
VALUE r = Qfalse;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
r = imlib_context_get_dither() ? Qtrue : Qfalse;
imlib_context_pop();
return r;
}
Set the dither flag.
Example:
ctx.dither = true
static VALUE ctx_set_dither(VALUE self, VALUE val) {
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_set_dither(val != Qnil && val != Qfalse);
imlib_context_pop();
return self;
}
Get the dither_mask flag.
Example:
if ctx.dither_mask == true puts 'dither_mask enabled' end
static VALUE ctx_dither_mask(VALUE self) {
Imlib_Context *ctx;
VALUE r = Qfalse;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
r = imlib_context_get_dither_mask() ? Qtrue : Qfalse;
imlib_context_pop();
return r;
}
Set the dither_mask flag.
Example:
ctx.dither_mask = true
static VALUE ctx_set_dither_mask(VALUE self, VALUE val) {
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_set_dither_mask(val != Qnil && val != Qfalse);
imlib_context_pop();
return self;
}
Get the current X11 Drawable.
Note: This method is not available unless Imlib2-Ruby was compiled with X11 support. You can check the constant Imlib2::X11_SUPPORT to see if X11 support is available.
Examples:
drawable = context.get_drawable drawable = context.drawable
static VALUE ctx_drawable(VALUE self) {
Imlib_Context *ctx;
Drawable *draw;
VALUE drawable;
Data_Get_Struct(self, Imlib_Context, ctx);
draw = malloc(sizeof(Drawable));
imlib_context_push(*ctx);
*draw = imlib_context_get_drawable();
drawable = Data_Wrap_Struct(cDrawable, NULL, dont_free, draw);
imlib_context_pop();
return drawable;
}
Set the current X11 Drawable.
Note: This method is not available unless Imlib2-Ruby was compiled with X11 support. You can check the constant Imlib2::X11_SUPPORT to see if X11 support is available.
Examples:
context.set_drawable drawable context.drawable = drawable
static VALUE ctx_set_drawable(VALUE self, VALUE drawable) {
Drawable *draw;
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
Data_Get_Struct(drawable, Drawable, draw);
imlib_context_push(*ctx);
imlib_context_set_drawable(*draw);
imlib_context_pop();
return drawable;
}
Get the current TrueType Font Encoding.
Example:
if ctx.encoding == Imlib2::Encoding::ISO_8859_1 puts 'using ISO-8859-1 encoding' end
static VALUE ctx_encoding(VALUE self) {
Imlib_Context *ctx;
VALUE r = Qnil;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
r = INT2FIX(imlib_context_get_TTF_encoding());
imlib_context_pop();
return r;
}
Set the current TrueType Font Encoding.
Example:
ctx.encoding = Imlib2::Encoding::ISO_8859_5
static VALUE ctx_set_encoding(VALUE self, VALUE val) {
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_set_TTF_encoding(NUM2INT(val));
imlib_context_pop();
return self;
}
Get the current font (Imlib2::Font).
Example:
font = ctx.font
static VALUE ctx_font(VALUE self) {
Imlib_Context *ctx;
VALUE r = Qnil;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
r = Data_Wrap_Struct(cFont, 0, font_free, imlib_context_get_font());
imlib_context_pop();
return r;
}
Set the current font (Imlib2::Font).
Example:
ctx.font = Imlib2::Font.new 'helvetica/12'
static VALUE ctx_set_font(VALUE self, VALUE val) {
Imlib_Context *ctx;
Imlib_Font *font;
font = malloc(sizeof(Imlib_Font));
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
Data_Get_Struct(val, Imlib_Font, font);
imlib_context_set_font(*font);
imlib_context_pop();
return self;
}
Get the text drawing angle.
Example:
if ctx.dir == Imlib2::Direction::ANGLE puts 'the current font angle is ' << ctx.angle end
static VALUE ctx_angle(VALUE self) {
Imlib_Context *ctx;
VALUE r = Qnil;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
r = rb_float_new(imlib_context_get_angle());
imlib_context_pop();
return r;
}
Get the anti_alias flag.
Example:
if ctx.anti_alias == true puts 'anti_alias enabled.' end
static VALUE ctx_aa(VALUE self) {
Imlib_Context *ctx;
VALUE r = Qfalse;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
r = imlib_context_get_anti_alias() ? Qtrue : Qfalse;
imlib_context_pop();
return r;
}
Get the current X11 Visual.
Note: This method is not available unless Imlib2-Ruby was compiled with X11 support. You can check the constant Imlib2::X11_SUPPORT to see if X11 support is available.
Examples:
visual = context.get_visual visual = context.visual
static VALUE ctx_visual(VALUE self) {
Imlib_Context *ctx;
VALUE vis;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
vis = Data_Wrap_Struct(cVisual, NULL, XFree, imlib_context_get_visual());
imlib_context_pop();
return vis;
}
Get the blend flag.
Example:
if ctx.blend puts 'blend enabled.' end
static VALUE ctx_blend(VALUE self) {
Imlib_Context *ctx;
VALUE r = Qfalse;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
r = imlib_context_get_blend() ? Qtrue : Qfalse;
imlib_context_pop();
return r;
}
Get the cliprect.
Example:
x, y, w, h = ctx.cliprect
static VALUE ctx_cliprect(VALUE self) {
Imlib_Context *ctx;
int i, r[4];
VALUE ary;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_get_cliprect(&(r[0]), &(r[1]), &(r[2]), &(r[3]));
imlib_context_pop();
ary = rb_ary_new();
for (i = 0; i < 4; i++);
rb_ary_push(ary, NUM2INT(r[i]));
return ary;
}
Get the current color (Imlib2::Color::RgbaColor).
Example:
color = ctx.color
static VALUE ctx_color(VALUE self) {
Imlib_Context *ctx;
VALUE argv[4];
int i, r[4];
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_get_color(&(r[0]), &(r[1]), &(r[2]), &(r[3]));
imlib_context_pop();
for (i = 0; i < 4; i++)
argv[i] = INT2NUM(r[i]);
return rgba_color_new(4, argv, cRgbaColor);
}
Get the current color modifier (Imlib2::ColorModifier).
Example:
cmod = ctx.cmod
static VALUE ctx_cmod(VALUE self) {
Imlib_Context *ctx;
Imlib_Color_Modifier *cmod;
cmod = malloc(sizeof(Imlib_Color_Modifier));
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
*cmod = imlib_context_get_color_modifier();
imlib_context_pop();
return Data_Wrap_Struct(cColorMod, 0, cmod_free, cmod);
}
Get the current font direction (Imlib2::Dir or Imlib2::Direction).
Example:
if ctx.direction != Imlib2::Direction::RIGHT puts 'drawing funny text' end
static VALUE ctx_dir(VALUE self) {
Imlib_Context *ctx;
VALUE r = Qnil;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
r = INT2FIX(imlib_context_get_direction());
imlib_context_pop();
return r;
}
Get the current X11 Display.
Note: This method is not available unless Imlib2-Ruby was compiled with X11 support. You can check the constant Imlib2::X11_SUPPORT to see if X11 support is available.
Examples:
display = context.get_display display = context.display
static VALUE ctx_display(VALUE self) {
Imlib_Context *ctx;
VALUE disp;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
disp = Data_Wrap_Struct(cDisplay, NULL, XFree, imlib_context_get_display());
imlib_context_pop();
return disp;
}
Get the dither flag.
Example:
if ctx.dither puts 'dither enabled.' end
static VALUE ctx_dither(VALUE self) {
Imlib_Context *ctx;
VALUE r = Qfalse;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
r = imlib_context_get_dither() ? Qtrue : Qfalse;
imlib_context_pop();
return r;
}
Get the dither_mask flag.
Example:
if ctx.dither_mask == true puts 'dither_mask enabled' end
static VALUE ctx_dither_mask(VALUE self) {
Imlib_Context *ctx;
VALUE r = Qfalse;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
r = imlib_context_get_dither_mask() ? Qtrue : Qfalse;
imlib_context_pop();
return r;
}
Get the current X11 Drawable.
Note: This method is not available unless Imlib2-Ruby was compiled with X11 support. You can check the constant Imlib2::X11_SUPPORT to see if X11 support is available.
Examples:
drawable = context.get_drawable drawable = context.drawable
static VALUE ctx_drawable(VALUE self) {
Imlib_Context *ctx;
Drawable *draw;
VALUE drawable;
Data_Get_Struct(self, Imlib_Context, ctx);
draw = malloc(sizeof(Drawable));
imlib_context_push(*ctx);
*draw = imlib_context_get_drawable();
drawable = Data_Wrap_Struct(cDrawable, NULL, dont_free, draw);
imlib_context_pop();
return drawable;
}
Get the current TrueType Font Encoding.
Example:
if ctx.encoding == Imlib2::Encoding::ISO_8859_1 puts 'using ISO-8859-1 encoding' end
static VALUE ctx_encoding(VALUE self) {
Imlib_Context *ctx;
VALUE r = Qnil;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
r = INT2FIX(imlib_context_get_TTF_encoding());
imlib_context_pop();
return r;
}
Get the current font (Imlib2::Font).
Example:
font = ctx.font
static VALUE ctx_font(VALUE self) {
Imlib_Context *ctx;
VALUE r = Qnil;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
r = Data_Wrap_Struct(cFont, 0, font_free, imlib_context_get_font());
imlib_context_pop();
return r;
}
Get the current gradient (Imlib2::Gradient).
Example:
grad = ctx.gradient
static VALUE ctx_gradient(VALUE self) {
Imlib_Context *ctx;
VALUE r = Qnil;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
r = Data_Wrap_Struct(cGradient, 0, gradient_free, imlib_context_get_color_range());
imlib_context_pop();
return r;
}
Get the current image (Imlib2::Image).
Note that this function is not useful at the moment since all image instance methods blindly blow away the image and color context. So you cannot safely mix image context and image instance methods.
Example:
im = ctx.image
static VALUE ctx_image(VALUE self) {
Imlib_Context *ctx;
ImStruct *im;
VALUE r = Qnil;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
im = malloc(sizeof(ImStruct));
im->im = imlib_context_get_image();
r = Data_Wrap_Struct(cImage, 0, im_struct_free, im);
imlib_context_pop();
return r;
}
Get the current X11 Mask.
Note: This method is not available unless Imlib2-Ruby was compiled with X11 support. You can check the constant Imlib2::X11_SUPPORT to see if X11 support is available.
Examples:
mask = context.get_mask mask = context.mask
static VALUE ctx_mask(VALUE self) {
Imlib_Context *ctx;
Pixmap *pmap;
VALUE mask;
Data_Get_Struct(self, Imlib_Context, ctx);
pmap = malloc(sizeof(Pixmap));
imlib_context_push(*ctx);
*pmap = imlib_context_get_mask();
mask = Data_Wrap_Struct(cPixmap, NULL, pmap_free, pmap);
imlib_context_pop();
return mask;
}
Get the current operation (Imlib2::Op or Imlib2::Operation).
Example:
if ctx.op == Imlib2::Op::COPY puts 'copy operation' end
static VALUE ctx_op(VALUE self) {
Imlib_Context *ctx;
VALUE r = Qnil;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
r = INT2FIX(imlib_context_get_operation());
imlib_context_pop();
return r;
}
Get the progress callback granularity.
This function is not useful at the moment since you cannot specify progress callbacks from within Ruby (this is a TODO item).
Example:
granularity = ctx.progress_granularity
static VALUE ctx_progress_granularity(VALUE self) {
Imlib_Context *ctx;
VALUE r = Qnil;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
r = INT2FIX(imlib_context_get_progress_granularity());
imlib_context_pop();
return r;
}
Get the current TrueType Font Encoding.
Example:
if ctx.encoding == Imlib2::Encoding::ISO_8859_1 puts 'using ISO-8859-1 encoding' end
static VALUE ctx_encoding(VALUE self) {
Imlib_Context *ctx;
VALUE r = Qnil;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
r = INT2FIX(imlib_context_get_TTF_encoding());
imlib_context_pop();
return r;
}
Get the current X11 Visual.
Note: This method is not available unless Imlib2-Ruby was compiled with X11 support. You can check the constant Imlib2::X11_SUPPORT to see if X11 support is available.
Examples:
visual = context.get_visual visual = context.visual
static VALUE ctx_visual(VALUE self) {
Imlib_Context *ctx;
VALUE vis;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
vis = Data_Wrap_Struct(cVisual, NULL, XFree, imlib_context_get_visual());
imlib_context_pop();
return vis;
}
Get the current gradient (Imlib2::Gradient).
Example:
grad = ctx.gradient
static VALUE ctx_gradient(VALUE self) {
Imlib_Context *ctx;
VALUE r = Qnil;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
r = Data_Wrap_Struct(cGradient, 0, gradient_free, imlib_context_get_color_range());
imlib_context_pop();
return r;
}
Set the current gradient (Imlib2::Gradient).
Example:
ctx.gradient = grad
static VALUE ctx_set_gradient(VALUE self, VALUE val) {
Imlib_Context *ctx;
Imlib_Color_Range *gradient;
gradient = malloc(sizeof(Imlib_Color_Range));
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
Data_Get_Struct(val, Imlib_Color_Range, gradient);
imlib_context_set_color_range(*gradient);
imlib_context_pop();
return self;
}
Get the current image (Imlib2::Image).
Note that this function is not useful at the moment since all image instance methods blindly blow away the image and color context. So you cannot safely mix image context and image instance methods.
Example:
im = ctx.image
static VALUE ctx_image(VALUE self) {
Imlib_Context *ctx;
ImStruct *im;
VALUE r = Qnil;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
im = malloc(sizeof(ImStruct));
im->im = imlib_context_get_image();
r = Data_Wrap_Struct(cImage, 0, im_struct_free, im);
imlib_context_pop();
return r;
}
Set the current image (Imlib2::Image).
Note that this function is not useful at the moment since all image instance methods blindly blow away the image and color context. So you cannot safely mix image context and image instance methods.
Example:
ctx.image = image
static VALUE ctx_set_image(VALUE self, VALUE val) {
Imlib_Context *ctx;
ImStruct *im;
im = malloc(sizeof(ImStruct));
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
GET_AND_CHECK_IMAGE(val, im);
imlib_context_set_image(im->im);
imlib_context_pop();
return self;
}
Get the current X11 Mask.
Note: This method is not available unless Imlib2-Ruby was compiled with X11 support. You can check the constant Imlib2::X11_SUPPORT to see if X11 support is available.
Examples:
mask = context.get_mask mask = context.mask
static VALUE ctx_mask(VALUE self) {
Imlib_Context *ctx;
Pixmap *pmap;
VALUE mask;
Data_Get_Struct(self, Imlib_Context, ctx);
pmap = malloc(sizeof(Pixmap));
imlib_context_push(*ctx);
*pmap = imlib_context_get_mask();
mask = Data_Wrap_Struct(cPixmap, NULL, pmap_free, pmap);
imlib_context_pop();
return mask;
}
Set the current X11 Mask.
Note: This method is not available unless Imlib2-Ruby was compiled with X11 support. You can check the constant Imlib2::X11_SUPPORT to see if X11 support is available.
Examples:
context.set_mask mask context.mask = mask
static VALUE ctx_set_mask(VALUE self, VALUE mask_o) {
Pixmap *mask;
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
Data_Get_Struct(mask_o, Pixmap, mask);
imlib_context_push(*ctx);
imlib_context_set_mask(*mask);
imlib_context_pop();
return mask_o;
}
Get the current operation (Imlib2::Op or Imlib2::Operation).
Example:
if ctx.op == Imlib2::Op::COPY puts 'copy operation' end
static VALUE ctx_op(VALUE self) {
Imlib_Context *ctx;
VALUE r = Qnil;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
r = INT2FIX(imlib_context_get_operation());
imlib_context_pop();
return r;
}
Set the current operation (Imlib2::Op or Imlib2::Operation).
Example:
ctx.operation = Imlib2::Op::COPY
static VALUE ctx_set_op(VALUE self, VALUE val) {
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_set_operation(NUM2INT(val));
imlib_context_pop();
return self;
}
Get the current operation (Imlib2::Op or Imlib2::Operation).
Example:
if ctx.op == Imlib2::Op::COPY puts 'copy operation' end
static VALUE ctx_op(VALUE self) {
Imlib_Context *ctx;
VALUE r = Qnil;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
r = INT2FIX(imlib_context_get_operation());
imlib_context_pop();
return r;
}
Set the current operation (Imlib2::Op or Imlib2::Operation).
Example:
ctx.operation = Imlib2::Op::COPY
static VALUE ctx_set_op(VALUE self, VALUE val) {
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_set_operation(NUM2INT(val));
imlib_context_pop();
return self;
}
Get the progress callback granularity.
This function is not useful at the moment since you cannot specify progress callbacks from within Ruby (this is a TODO item).
Example:
granularity = ctx.progress_granularity
static VALUE ctx_progress_granularity(VALUE self) {
Imlib_Context *ctx;
VALUE r = Qnil;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
r = INT2FIX(imlib_context_get_progress_granularity());
imlib_context_pop();
return r;
}
Set the progress callback granularity.
This function is not useful at the moment since you cannot specify progress callbacks from within ruby (this is a TODO item).
Example:
ctx.progress_granularity = 10
static VALUE ctx_set_progress_granularity(VALUE self, VALUE val) {
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_set_progress_granularity(NUM2INT(val));
imlib_context_pop();
return self;
}
Push this context onto the context stack.
Example:
ctx.push
static VALUE ctx_push(VALUE self) {
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
return self;
}
Set the text drawing angle.
Example:
ctx.angle = 76.8
static VALUE ctx_set_angle(VALUE self, VALUE val) {
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_set_angle(NUM2DBL(val));
imlib_context_pop();
return self;
}
Set the anti_alias flag.
Example:
ctx.anti_alias = true
static VALUE ctx_set_aa(VALUE self, VALUE val) {
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_set_anti_alias(val != Qnil && val != Qfalse);
imlib_context_pop();
return self;
}
Set the blend flag.
Example:
ctx.blend = true
static VALUE ctx_set_blend(VALUE self, VALUE val) {
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_set_blend(val != Qnil && val != Qfalse);
imlib_context_pop();
return self;
}
Set the cliprect.
Example:
ctx.cliprect = [10, 10, 100, 100]
static VALUE ctx_set_cliprect(VALUE self, VALUE val) {
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_set_cliprect(
NUM2INT(rb_ary_entry(val, 0)),
NUM2INT(rb_ary_entry(val, 1)),
NUM2INT(rb_ary_entry(val, 2)),
NUM2INT(rb_ary_entry(val, 3))
);
imlib_context_pop();
return self;
}
Set the current color (Imlib2::Color).
Example:
ctx.color = Imlib2::Color::LIGHTGRAY
static VALUE ctx_set_color(VALUE self, VALUE val) {
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
set_context_color(val);
imlib_context_pop();
return self;
}
Set the current color modifier (Imlib2::ColorModifier).
Example:
ctx.cmod = cmod
static VALUE ctx_set_cmod(VALUE self, VALUE val) {
Imlib_Context *ctx;
Imlib_Color_Modifier *cmod;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
Data_Get_Struct(val, Imlib_Color_Modifier, cmod);
imlib_context_set_color_modifier(*cmod);
imlib_context_pop();
return self;
}
Set the current font direction (Imlib2::Dir or Imlib2::Direction).
Example:
ctx.direction = Imlib2::Direction::LEFT
static VALUE ctx_set_dir(VALUE self, VALUE val) {
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_set_direction(NUM2INT(val));
imlib_context_pop();
return self;
}
Set the current X11 Display.
Note: This method is not available unless Imlib2-Ruby was compiled with X11 support. You can check the constant Imlib2::X11_SUPPORT to see if X11 support is available.
Examples:
context.set_display display context.display = display
static VALUE ctx_set_display(VALUE self, VALUE display) {
Display *disp;
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
Data_Get_Struct(display, Display, disp);
imlib_context_push(*ctx);
imlib_context_set_display(disp);
imlib_context_pop();
return display;
}
Set the dither flag.
Example:
ctx.dither = true
static VALUE ctx_set_dither(VALUE self, VALUE val) {
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_set_dither(val != Qnil && val != Qfalse);
imlib_context_pop();
return self;
}
Set the dither_mask flag.
Example:
ctx.dither_mask = true
static VALUE ctx_set_dither_mask(VALUE self, VALUE val) {
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_set_dither_mask(val != Qnil && val != Qfalse);
imlib_context_pop();
return self;
}
Set the current X11 Drawable.
Note: This method is not available unless Imlib2-Ruby was compiled with X11 support. You can check the constant Imlib2::X11_SUPPORT to see if X11 support is available.
Examples:
context.set_drawable drawable context.drawable = drawable
static VALUE ctx_set_drawable(VALUE self, VALUE drawable) {
Drawable *draw;
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
Data_Get_Struct(drawable, Drawable, draw);
imlib_context_push(*ctx);
imlib_context_set_drawable(*draw);
imlib_context_pop();
return drawable;
}
Set the current TrueType Font Encoding.
Example:
ctx.encoding = Imlib2::Encoding::ISO_8859_5
static VALUE ctx_set_encoding(VALUE self, VALUE val) {
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_set_TTF_encoding(NUM2INT(val));
imlib_context_pop();
return self;
}
Set the current font (Imlib2::Font).
Example:
ctx.font = Imlib2::Font.new 'helvetica/12'
static VALUE ctx_set_font(VALUE self, VALUE val) {
Imlib_Context *ctx;
Imlib_Font *font;
font = malloc(sizeof(Imlib_Font));
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
Data_Get_Struct(val, Imlib_Font, font);
imlib_context_set_font(*font);
imlib_context_pop();
return self;
}
Set the current gradient (Imlib2::Gradient).
Example:
ctx.gradient = grad
static VALUE ctx_set_gradient(VALUE self, VALUE val) {
Imlib_Context *ctx;
Imlib_Color_Range *gradient;
gradient = malloc(sizeof(Imlib_Color_Range));
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
Data_Get_Struct(val, Imlib_Color_Range, gradient);
imlib_context_set_color_range(*gradient);
imlib_context_pop();
return self;
}
Set the current image (Imlib2::Image).
Note that this function is not useful at the moment since all image instance methods blindly blow away the image and color context. So you cannot safely mix image context and image instance methods.
Example:
ctx.image = image
static VALUE ctx_set_image(VALUE self, VALUE val) {
Imlib_Context *ctx;
ImStruct *im;
im = malloc(sizeof(ImStruct));
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
GET_AND_CHECK_IMAGE(val, im);
imlib_context_set_image(im->im);
imlib_context_pop();
return self;
}
Set the current X11 Mask.
Note: This method is not available unless Imlib2-Ruby was compiled with X11 support. You can check the constant Imlib2::X11_SUPPORT to see if X11 support is available.
Examples:
context.set_mask mask context.mask = mask
static VALUE ctx_set_mask(VALUE self, VALUE mask_o) {
Pixmap *mask;
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
Data_Get_Struct(mask_o, Pixmap, mask);
imlib_context_push(*ctx);
imlib_context_set_mask(*mask);
imlib_context_pop();
return mask_o;
}
Set the current operation (Imlib2::Op or Imlib2::Operation).
Example:
ctx.operation = Imlib2::Op::COPY
static VALUE ctx_set_op(VALUE self, VALUE val) {
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_set_operation(NUM2INT(val));
imlib_context_pop();
return self;
}
Set the progress callback granularity.
This function is not useful at the moment since you cannot specify progress callbacks from within ruby (this is a TODO item).
Example:
ctx.progress_granularity = 10
static VALUE ctx_set_progress_granularity(VALUE self, VALUE val) {
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_set_progress_granularity(NUM2INT(val));
imlib_context_pop();
return self;
}
Set the current TrueType Font Encoding.
Example:
ctx.encoding = Imlib2::Encoding::ISO_8859_5
static VALUE ctx_set_encoding(VALUE self, VALUE val) {
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
imlib_context_set_TTF_encoding(NUM2INT(val));
imlib_context_pop();
return self;
}
Set the current X11 Visual.
Note: This method is not available unless Imlib2-Ruby was compiled with X11 support. You can check the constant Imlib2::X11_SUPPORT to see if X11 support is available.
Examples:
context.set_visual visual context.visual = visual
static VALUE ctx_set_visual(VALUE self, VALUE visual) {
Visual *vis;
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
Data_Get_Struct(visual, Visual, vis);
imlib_context_push(*ctx);
imlib_context_set_visual(vis);
imlib_context_pop();
return visual;
}
Get the current X11 Visual.
Note: This method is not available unless Imlib2-Ruby was compiled with X11 support. You can check the constant Imlib2::X11_SUPPORT to see if X11 support is available.
Examples:
visual = context.get_visual visual = context.visual
static VALUE ctx_visual(VALUE self) {
Imlib_Context *ctx;
VALUE vis;
Data_Get_Struct(self, Imlib_Context, ctx);
imlib_context_push(*ctx);
vis = Data_Wrap_Struct(cVisual, NULL, XFree, imlib_context_get_visual());
imlib_context_pop();
return vis;
}
Set the current X11 Visual.
Note: This method is not available unless Imlib2-Ruby was compiled with X11 support. You can check the constant Imlib2::X11_SUPPORT to see if X11 support is available.
Examples:
context.set_visual visual context.visual = visual
static VALUE ctx_set_visual(VALUE self, VALUE visual) {
Visual *vis;
Imlib_Context *ctx;
Data_Get_Struct(self, Imlib_Context, ctx);
Data_Get_Struct(visual, Visual, vis);
imlib_context_push(*ctx);
imlib_context_set_visual(vis);
imlib_context_pop();
return visual;
}
Generated with the Darkfish Rdoc Generator 2.