Class: Hornetseye::RGB_

Inherits:
Composite show all
Defined in:
docs/multiarray/lib/multiarray/rgb.rb

Overview

Class for representing native RGB values

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Element

fetch

Methods inherited from Node

#<=>, ===, #[], #[]=, #allocate, #b=, #b_with_decompose, #basetype, #between?, bool, #check_shape, #clip, coercion_bool, coercion_byte, coercion_maxint, #collect, #components, cond, #conditional, #convolve, #decompose, #dilate, dimension, #dimension, #downsample, #each, #empty?, #eq_with_multiarray, #erode, #fill!, #flip, float_scalar, floating, #fmod_with_float, #g=, #g_with_decompose, #gauss_blur, #gauss_gradient, #height, #histogram, #histogram_with_rgb, #if, #if_else, #imag=, #imag_with_decompose, indgen, #inject, #inspect, #integral, #lut, #lut_with_rgb, #mask, #matched?, #max, #mean, #memorise, #memory, #min, #normalise, #orig_to_cvmat, #orig_to_type_with_frame, #prod, #r=, #r_with_decompose, #range, #real=, #real_with_decompose, #reshape, #rgb?, #roll, #save_dfloat, #save_dfloatrgb, #save_magick, #save_openexr, #save_sfloat, #save_sfloatrgb, #save_ubyte, #save_ubytergb, #save_uint, #save_uintrgb, #save_usint, #save_usintrgb, scalar, shape, #shape, #shift, #show, #size, #sobel, #stretch, #sum, #swap_rgb_with_scalar, #to_a, #to_cvmat, #to_magick, #to_narray, to_type, #to_type, #to_type_with_frame, #to_type_with_identity, #to_type_with_rgb, #transpose, typecode, #typecode, #unmask, #unroll, #warp, #width

Constructor Details

#initialize(value = self.class.default) ⇒ RGB_

Constructor for native RGB value

Parameters:

  • value (RGB) (defaults to: self.class.default)

    Initial RGB value.



392
393
394
395
396
397
398
399
400
401
402
# File 'docs/multiarray/lib/multiarray/rgb.rb', line 392

def initialize( value = self.class.default )
  if Thread.current[ :function ].nil? or
     [ value.r, value.g, value.b ].all? { |c| c.is_a? GCCValue }
    @value = value
  else
    r = GCCValue.new Thread.current[ :function ], value.r.to_s
    g = GCCValue.new Thread.current[ :function ], value.g.to_s
    b = GCCValue.new Thread.current[ :function ], value.b.to_s
    @value = RGB.new r, g, b
  end
end

Class Method Details

.==(other) ⇒ Boolean

Test equality of classes

Parameters:

  • other (Object)

    Object to compare with.

Returns:

  • (Boolean)

    Boolean indicating whether classes are equal.



355
356
357
358
# File 'docs/multiarray/lib/multiarray/rgb.rb', line 355

def ==(other)
  other.is_a? Class and other < RGB_ and
    element_type == other.element_type
end

.inherit(element_type) ⇒ Object



245
246
247
248
249
# File 'docs/multiarray/lib/multiarray/rgb.rb', line 245

def inherit(element_type)
  retval = Class.new self
  retval.element_type = element_type
  retval
end

.inspectString

Diplay information about this class

Returns:

  • (String)

    Text with information about this class (e.g. “DFLOATRGB”).



290
291
292
293
294
295
296
# File 'docs/multiarray/lib/multiarray/rgb.rb', line 290

def inspect
  unless element_type.nil?
    IDENTIFIER[ element_type ] || "RGB(#{element_type.inspect})"
  else
    super
  end
end

.rgb?Boolean

Check whether this object is an RGB value

Returns:

  • (Boolean)

    Returns true.



383
384
385
# File 'docs/multiarray/lib/multiarray/rgb.rb', line 383

def rgb?
  true
end

Instance Method Details

#dupRGB_

Duplicate object

Returns:

  • (RGB_)

    Duplicate of self.



407
408
409
410
411
412
413
414
415
416
417
418
419
# File 'docs/multiarray/lib/multiarray/rgb.rb', line 407

def dup
  if Thread.current[ :function ]
    r = Thread.current[ :function ].variable self.class.element_type, 'v'
    g = Thread.current[ :function ].variable self.class.element_type, 'v'
    b = Thread.current[ :function ].variable self.class.element_type, 'v'
    r.assign @value.r
    g.assign @value.g
    b.assign @value.b
    self.class.new RGB.new( r, g, b )
  else
    self.class.new get
  end
end