Class: RedBird::Color

Inherits:
Data
  • Object
show all
Defined in:
ext/red_bird/color.c,
ext/red_bird/color.c

Overview

A color represented by red, green, blue, and alpha (transparency) values.

Instance Method Summary collapse

Constructor Details

#initialize(red, green, blue, alpha) ⇒ Object

Create a new color based in the RGBA color model.

Parameters:

  • red (Integer)

    the amount of red (between 0 and 255).

  • green (Integer)

    the amount of green (between 0 and 255).

  • blue (Integer)

    the amount of blue (between 0 and 255).

  • alpha (Integer)

    the amount of transparency (between 0 and 255). 0 is transparent, 255 is opaque.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'ext/red_bird/color.c', line 58

VALUE
bird_cColor_initialize(VALUE self, VALUE red, VALUE green, VALUE blue,
                       VALUE alpha)
{
  struct bird_color_data *ptr;

  RB_INTEGER_TYPE_P(red);
  RB_INTEGER_TYPE_P(green);
  RB_INTEGER_TYPE_P(blue);
  RB_INTEGER_TYPE_P(alpha);

  TypedData_Get_Struct(self, struct bird_color_data, &bird_color_type, ptr);

  ptr->data.r = NUM2UINT(red);
  ptr->data.g = NUM2UINT(green);
  ptr->data.b = NUM2UINT(blue);
  ptr->data.a = NUM2UINT(alpha);

  return self;
}