class Vissen::Output::VixelBuffer
TODO: Document this class.
Attributes
intensity[RW]
@return [Float] the global intensity of the buffer.
palette[RW]
@return [Integer] the palette number currently in use.
Public Class Methods
new(context, palette: 0, intensity: 1.0)
click to toggle source
@param context [Context] the context in which the buffer exists. @param palette [Integer] the palette number to use when rendering. @param intensity [Numeric] the global intensity at which to render.
Calls superclass method
Vissen::Output::Buffer::new
# File lib/vissen/output/vixel_buffer.rb, line 24 def initialize(context, palette: 0, intensity: 1.0) super(context, Vixel) @palette = palette @intensity = intensity end
Public Instance Methods
render(buffer, intensity: 1.0)
click to toggle source
Render the layer vixels to the given buffer.
@param buffer [PixelBuffer] the buffer to store the resulting colors of
each point in.
@param intensity [Numeric] the intensity to scale the vixels intensity
with.
@return [PixelBuffer] the same buffer that was given as a parameter.
# File lib/vissen/output/vixel_buffer.rb, line 38 def render(buffer, intensity: 1.0) palette = context.palettes[@palette] buffer.each_with_index do |color, index| vixel = vixels[index] next unless vixel.i.positive? ratio = vixel.i * intensity * @intensity color.mix_with! palette[vixel.p], ratio end buffer end
vixel_count()
click to toggle source
@return [Integer] the number of vixels in the buffer.
# File lib/vissen/output/vixel_buffer.rb, line 51 def vixel_count vixels.length end