Module: Hornetseye::RGB_::Match
- Included in:
- Node
- Defined in:
- lib/multiarray/rgb.rb
Instance Method Summary collapse
-
#align(context) ⇒ Object
Perform type alignment.
-
#fit(*values) ⇒ Class
Method for matching elements of type RGB_.
Instance Method Details
#align(context) ⇒ Object
Perform type alignment
Align this type to another. This is used to prefer single-precision floating point in certain cases.
434 435 436 437 438 439 440 |
# File 'lib/multiarray/rgb.rb', line 434 def align( context ) if self < RGB_ Hornetseye::RGB element_type.align( context ) else super context end end |
#fit(*values) ⇒ Class
Method for matching elements of type RGB_
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 |
# File 'lib/multiarray/rgb.rb', line 401 def fit( *values ) if values.all? { |value| value.is_a? RGB or value.is_a? Float or value.is_a? Integer } if values.any? { |value| value.is_a? RGB } elements = values.inject( [] ) do |arr,value| if value.is_a? RGB arr + [ value.r, value.g, value.b ] else arr + [ value ] end end element_fit = fit *elements if element_fit == OBJECT super *values else Hornetseye::RGB element_fit end else super *values end else super *values end end |