Class: SFML::BlendMode
- Inherits:
-
Object
- Object
- SFML::BlendMode
- Defined in:
- ext/graphics/blend_mode.c,
ext/graphics/blend_mode.c
Overview
Describes how the colors of a drawn object are combined with the colors already in the render target, via two triples of (source factor, destination factor, equation) -- one for the color/RGB channels, one for the alpha channel.
Constant Summary collapse
- NONE =
source pixels overwrite destination pixels unchanged (One, Zero, Add for both the color and alpha channels).
No blending
- ALPHA =
the source is blended over the destination using the source alpha (SrcAlpha, OneMinusSrcAlpha, Add for color; One, OneMinusSrcAlpha, Add for alpha). The default blend mode.
Standard alpha blending
- ADD =
the source color, scaled by its alpha, is added to the destination (SrcAlpha, One, Add for color; One, One, Add for alpha).
Additive blending
- MULTIPLY =
source and destination colors are multiplied together (DstColor, Zero, Add for both the color and alpha channels).
Multiplicative blending
- MIN =
Component-wise minimum of the source and destination colors (One, One, Min for both the color and alpha channels).
rb_obj_freeze(BlendMode_wrap(sfBlendMin))
- MAX =
Component-wise maximum of the source and destination colors (One, One, Max for both the color and alpha channels).
rb_obj_freeze(BlendMode_wrap(sfBlendMax))
Instance Attribute Summary collapse
-
#alpha_dst_factor ⇒ Symbol
Returns the destination blend factor for alpha.
-
#alpha_equation ⇒ Symbol
Returns the blend equation for alpha.
-
#alpha_src_factor ⇒ Symbol
Returns the source blend factor for alpha.
-
#color_dst_factor ⇒ Symbol
Returns the destination blend factor for color components.
-
#color_equation ⇒ Symbol
Returns the blend equation for color components.
-
#color_src_factor ⇒ Symbol
Returns the source blend factor for color components.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Returns
trueif the two objects are equal. -
#initialize(*args) ⇒ BlendMode
constructor
alpha_dst_factor, alpha_equation) -> BlendMode.
Constructor Details
#new ⇒ BlendMode(ALPHA) #new(color_src_factor, color_dst_factor, color_equation, alpha_src_factor) ⇒ BlendMode
alpha_dst_factor, alpha_equation) -> BlendMode
Each factor argument is a Symbol (one of :zero, :one, :src_color,
:one_minus_src_color, :dst_color, :one_minus_dst_color,
:src_alpha, :one_minus_src_alpha, :dst_alpha,
:one_minus_dst_alpha) or the equivalent Integer. Each equation argument
is a Symbol (+:add+, :subtract, :reverse_subtract, :min, :max) or
the equivalent Integer.
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'ext/graphics/blend_mode.c', line 110
static VALUE BlendMode_initialize(int argc, VALUE* argv, VALUE self) {
sfBlendMode mode = sfBlendAlpha;
if (argc == 6) {
mode = (sfBlendMode){factor_from_rb(argv[0]), factor_from_rb(argv[1]),
equation_from_rb(argv[2]), factor_from_rb(argv[3]),
factor_from_rb(argv[4]), equation_from_rb(argv[5])};
} else if (argc != 0) {
raise_invalid_arguments_excepted(6, argc);
}
((BlendMode*)Get_BlendMode_Struct(self))->mode = mode;
return self;
}
|
Instance Attribute Details
#alpha_dst_factor ⇒ Symbol
Returns the destination blend factor for alpha.
292 293 294 295 |
# File 'ext/graphics/blend_mode.c', line 292
static VALUE BlendMode_get_alpha_dst_factor(VALUE self) {
return ID2SYM(
rb_intern(factor_names[((BlendMode*)Get_BlendMode_Struct(self))->mode.alphaDstFactor]));
}
|
#alpha_equation ⇒ Symbol
Returns the blend equation for alpha.
292 293 294 295 |
# File 'ext/graphics/blend_mode.c', line 292
static VALUE BlendMode_get_alpha_equation(VALUE self) {
return ID2SYM(
rb_intern(equation_names[((BlendMode*)Get_BlendMode_Struct(self))->mode.alphaEquation]));
}
|
#alpha_src_factor ⇒ Symbol
Returns the source blend factor for alpha.
292 293 294 295 |
# File 'ext/graphics/blend_mode.c', line 292
static VALUE BlendMode_get_alpha_src_factor(VALUE self) {
return ID2SYM(
rb_intern(factor_names[((BlendMode*)Get_BlendMode_Struct(self))->mode.alphaSrcFactor]));
}
|
#color_dst_factor ⇒ Symbol
Returns the destination blend factor for color components.
292 293 294 295 |
# File 'ext/graphics/blend_mode.c', line 292
static VALUE BlendMode_get_color_dst_factor(VALUE self) {
return ID2SYM(
rb_intern(factor_names[((BlendMode*)Get_BlendMode_Struct(self))->mode.colorDstFactor]));
}
|
#color_equation ⇒ Symbol
Returns the blend equation for color components.
292 293 294 295 |
# File 'ext/graphics/blend_mode.c', line 292
static VALUE BlendMode_get_color_equation(VALUE self) {
return ID2SYM(
rb_intern(equation_names[((BlendMode*)Get_BlendMode_Struct(self))->mode.colorEquation]));
}
|
#color_src_factor ⇒ Symbol
Returns the source blend factor for color components.
292 293 294 295 |
# File 'ext/graphics/blend_mode.c', line 292
static VALUE BlendMode_get_color_src_factor(VALUE self) {
return ID2SYM(
rb_intern(factor_names[((BlendMode*)Get_BlendMode_Struct(self))->mode.colorSrcFactor]));
}
|
Instance Method Details
#==(other) ⇒ Boolean
Returns true if the two objects are equal.
277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
# File 'ext/graphics/blend_mode.c', line 277
static VALUE BlendMode_eql(VALUE self, VALUE rb_other) {
sfBlendMode a = ((BlendMode*)Get_BlendMode_Struct(self))->mode;
sfBlendMode b;
if (!rb_obj_is_kind_of(rb_other, rb_cBlendMode)) {
return Qfalse;
}
b = ((BlendMode*)Get_BlendMode_Struct(rb_other))->mode;
return BOOL2RB(a.colorSrcFactor == b.colorSrcFactor && a.colorDstFactor == b.colorDstFactor &&
a.colorEquation == b.colorEquation && a.alphaSrcFactor == b.alphaSrcFactor &&
a.alphaDstFactor == b.alphaDstFactor && a.alphaEquation == b.alphaEquation);
}
|