Class: Vissen::Output::Vixel

Inherits:
Object
  • Object
show all
Defined in:
lib/vissen/output/vixel.rb

Overview

The ‘Vixel` (Vissen pixel) represents the two dimensional representation of each grid pixel, for each grid. Each vixel has an intensity (i) and a palette position (p), both with values in the range 0..1.

TODO: How do we want the vixel to saturate? When written or when read?

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(i = 0.0, p = 0.0) ⇒ Vixel

Returns a new instance of Vixel.

Parameters:

  • i (Numeric) (defaults to: 0.0)

    the vixel intensity.

  • p (Numeric) (defaults to: 0.0)

    the vixel palette position.



19
20
21
22
# File 'lib/vissen/output/vixel.rb', line 19

def initialize(i = 0.0, p = 0.0)
  self.i = i
  self.p = p
end

Instance Attribute Details

#iFloat

Returns the vixel intensity.

Returns:

  • (Float)

    the vixel intensity.



12
13
14
# File 'lib/vissen/output/vixel.rb', line 12

def i
  @i
end

#pFloat

Returns the vixel palette position.

Returns:

  • (Float)

    the vixel palette position.



15
16
17
# File 'lib/vissen/output/vixel.rb', line 15

def p
  @p
end

Instance Method Details

#==(other) ⇒ true, false

Returns true if the other object has the same intensity and palette position.

Parameters:

  • other (Object)

    the object to check equality against.

Returns:

  • (true, false)

    true if the other object has the same intensity and palette position.



27
28
29
30
31
# File 'lib/vissen/output/vixel.rb', line 27

def ==(other)
  @i == other.i && @p == other.p
rescue NoMethodError
  false
end

#inspectString

Returns a string representation of the vixel.

Returns:

  • (String)

    a string representation of the vixel.



34
35
36
# File 'lib/vissen/output/vixel.rb', line 34

def inspect
  format '(%.1f, %.1f)', @i, @p
end