Class: Ray::Color
- Inherits:
-
Object
- Object
- Ray::Color
- Defined in:
- ext/color.c,
lib/ray/color.rb,
ext/color.c
Overview
Represents a color, which does not rely on the pixel format of any surfaces.
Class Method Summary collapse
- .black ⇒ Object
- .blue ⇒ Object
- .cyan ⇒ Object
- .fuschia ⇒ Object
- .gray ⇒ Object
- .green ⇒ Object
- .none ⇒ Object
- .red ⇒ Object
- .white ⇒ Object
- .yellow ⇒ Object
Instance Method Summary collapse
- #==(obj) ⇒ Object
-
#a ⇒ Integer
(also: #alpha)
Alpha intensity.
-
#a=(val) ⇒ Object
(also: #alpha=)
Sets the alpha intensity.
-
#b ⇒ Integer
(also: #blue)
Blue intensity.
-
#b=(val) ⇒ Object
(also: #blue=)
Sets the blue intensity.
-
#g ⇒ Integer
(also: #green)
Green intensity.
-
#g=(val) ⇒ Object
(also: #green=)
Sets the green intensity.
-
#initialize(red, green, blue, alpha = 255) ⇒ Object
constructor
Creates a new color.
- #inspect ⇒ Object
-
#r ⇒ Integer
(also: #red)
Red intensity.
-
#r=(val) ⇒ Object
(also: #red=)
Sets the red intensity.
- #to_color ⇒ Object
Constructor Details
#initialize(red, green, blue, alpha = 255) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'ext/color.c', line 42
VALUE ray_init_color(int argc, VALUE *argv, VALUE self) {
VALUE r, g, b, a;
rb_scan_args(argc, argv, "31", &r, &g, &b, &a);
if (a == Qnil) a = INT2FIX(255);
ray_color *ret = NULL;
Data_Get_Struct(self, ray_color, ret);
ret->r = NUM2INT(r);
ret->g = NUM2INT(g);
ret->b = NUM2INT(b);
ret->a = NUM2INT(a);
return Qnil;
}
|
Class Method Details
.black ⇒ Object
7 |
# File 'lib/ray/color.rb', line 7 def black; new(0, 0,0); end |
.blue ⇒ Object
6 |
# File 'lib/ray/color.rb', line 6 def blue; new(0, 0, 255); end |
.cyan ⇒ Object
11 |
# File 'lib/ray/color.rb', line 11 def cyan; new(0, 255, 255); end |
.fuschia ⇒ Object
13 |
# File 'lib/ray/color.rb', line 13 def fuschia; new(255, 0, 255); end |
.gray ⇒ Object
10 |
# File 'lib/ray/color.rb', line 10 def gray; new(128, 128, 128); end |
.green ⇒ Object
5 |
# File 'lib/ray/color.rb', line 5 def green; new(0, 255, 0); end |
.none ⇒ Object
9 |
# File 'lib/ray/color.rb', line 9 def none; new(0, 0, 0, 0); end |
.red ⇒ Object
4 |
# File 'lib/ray/color.rb', line 4 def red; new(255, 0, 0); end |
.white ⇒ Object
8 |
# File 'lib/ray/color.rb', line 8 def white; new(255, 255, 255); end |
.yellow ⇒ Object
12 |
# File 'lib/ray/color.rb', line 12 def yellow; new(255, 255, 0); end |
Instance Method Details
#==(obj) ⇒ Object
20 21 22 23 |
# File 'lib/ray/color.rb', line 20 def ==(obj) return false unless obj.is_a? Color r == obj.r && g == obj.g && b == obj.b && a == obj.a end |
#a ⇒ Integer Also known as: alpha
Returns alpha intensity.
83 84 85 86 87 88 |
# File 'ext/color.c', line 83
VALUE ray_color_a(VALUE self) {
ray_color *ret;
Data_Get_Struct(self, ray_color, ret);
return INT2FIX(ret->a);
}
|
#a=(val) ⇒ Object Also known as: alpha=
Sets the alpha intensity
118 119 120 121 122 123 124 |
# File 'ext/color.c', line 118
VALUE ray_color_set_a(VALUE self, VALUE val) {
ray_color *ret;
Data_Get_Struct(self, ray_color, ret);
ret->a = NUM2INT(val);
return val;
}
|
#b ⇒ Integer Also known as: blue
Returns blue intensity.
75 76 77 78 79 80 |
# File 'ext/color.c', line 75
VALUE ray_color_b(VALUE self) {
ray_color *ret;
Data_Get_Struct(self, ray_color, ret);
return INT2FIX(ret->b);
}
|
#b=(val) ⇒ Object Also known as: blue=
Sets the blue intensity
109 110 111 112 113 114 115 |
# File 'ext/color.c', line 109
VALUE ray_color_set_b(VALUE self, VALUE val) {
ray_color *ret;
Data_Get_Struct(self, ray_color, ret);
ret->b = NUM2INT(val);
return val;
}
|
#g ⇒ Integer Also known as: green
Returns green intensity.
67 68 69 70 71 72 |
# File 'ext/color.c', line 67
VALUE ray_color_g(VALUE self) {
ray_color *ret;
Data_Get_Struct(self, ray_color, ret);
return INT2FIX(ret->g);
}
|
#g=(val) ⇒ Object Also known as: green=
Sets the green intensity
100 101 102 103 104 105 106 |
# File 'ext/color.c', line 100
VALUE ray_color_set_g(VALUE self, VALUE val) {
ray_color *ret;
Data_Get_Struct(self, ray_color, ret);
ret->g = NUM2INT(val);
return val;
}
|
#inspect ⇒ Object
16 17 18 |
# File 'lib/ray/color.rb', line 16 def inspect "RGBA(#{r}, #{g}, #{b}, #{a})" end |
#r ⇒ Integer Also known as: red
Returns red intensity.
59 60 61 62 63 64 |
# File 'ext/color.c', line 59
VALUE ray_color_r(VALUE self) {
ray_color *ret;
Data_Get_Struct(self, ray_color, ret);
return INT2FIX(ret->r);
}
|
#r=(val) ⇒ Object Also known as: red=
Sets the red intensity
91 92 93 94 95 96 97 |
# File 'ext/color.c', line 91
VALUE ray_color_set_r(VALUE self, VALUE val) {
ray_color *ret;
Data_Get_Struct(self, ray_color, ret);
ret->r = NUM2INT(val);
return val;
}
|
#to_color ⇒ Object
25 26 27 |
# File 'lib/ray/color.rb', line 25 def to_color self end |