Class: Axon::Solid
- Inherits:
-
Object
- Object
- Axon::Solid
- Defined in:
- lib/axon/generators.rb
Overview
A Solid Color Image Generator
Axon::Solid will generate images with a solid color value.
Example
Axon::Solid.new(100, 200, "\x0A\x14\x69")
Instance Attribute Summary collapse
-
#components ⇒ Object
readonly
The components in the generated image.
-
#height ⇒ Object
readonly
The height of the generated image.
-
#lineno ⇒ Object
readonly
The index of the next line that will be fetched by gets, starting at 0.
-
#width ⇒ Object
readonly
The width of the generated image.
Instance Method Summary collapse
-
#gets ⇒ Object
Gets the next scanline from the generated image.
-
#initialize(width, height, color = nil) ⇒ Solid
constructor
:call-seq: Solid.new(width, height, color = “x00x00x00”, color_model = :RGB).
Constructor Details
#initialize(width, height, color = nil) ⇒ Solid
:call-seq:
Solid.new(width, height, color = "\x00\x00\x00", color_model = :RGB)
Creates a new solid color image object with dimensions width x height.
The optional argument color is the binary value that will be assigned to each pixel.
85 86 87 88 89 90 |
# File 'lib/axon/generators.rb', line 85 def initialize(width, height, color=nil) @width, @height = width, height @color = color || "\x00\x00\x00" @components = @color.size @lineno = 0 end |
Instance Attribute Details
#components ⇒ Object (readonly)
The components in the generated image.
72 73 74 |
# File 'lib/axon/generators.rb', line 72 def components @components end |
#height ⇒ Object (readonly)
The height of the generated image.
69 70 71 |
# File 'lib/axon/generators.rb', line 69 def height @height end |
#lineno ⇒ Object (readonly)
The index of the next line that will be fetched by gets, starting at 0.
75 76 77 |
# File 'lib/axon/generators.rb', line 75 def lineno @lineno end |
#width ⇒ Object (readonly)
The width of the generated image.
66 67 68 |
# File 'lib/axon/generators.rb', line 66 def width @width end |
Instance Method Details
#gets ⇒ Object
Gets the next scanline from the generated image.
94 95 96 97 98 |
# File 'lib/axon/generators.rb', line 94 def gets return nil if @lineno >= @height @lineno += 1 @color * width end |