Class: Axon::Solid
- Inherits:
-
Object
- Object
- Axon::Solid
- Defined in:
- lib/axon/generators.rb
Overview
Instance Attribute Summary collapse
-
#color_model ⇒ Object
readonly
The color model of the generated image.
-
#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, color_model = nil) ⇒ Solid
constructor
:call-seq: Solid.new(width, height, color = “x00x00x00”, color_model = :RGB).
Constructor Details
#initialize(width, height, color = nil, color_model = 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.
93 94 95 96 97 98 99 |
# File 'lib/axon/generators.rb', line 93 def initialize(width, height, color=nil, color_model=nil) @width, @height = width, height @color = color || "\x00\x00\x00" @color_model = color_model || :RGB @components = @color.size @lineno = 0 end |
Instance Attribute Details
#color_model ⇒ Object (readonly)
The color model of the generated image.
77 78 79 |
# File 'lib/axon/generators.rb', line 77 def color_model @color_model end |
#components ⇒ Object (readonly)
The components in the generated image.
80 81 82 |
# File 'lib/axon/generators.rb', line 80 def components @components end |
#height ⇒ Object (readonly)
The height of the generated image.
74 75 76 |
# File 'lib/axon/generators.rb', line 74 def height @height end |
#lineno ⇒ Object (readonly)
The index of the next line that will be fetched by gets, starting at 0.
83 84 85 |
# File 'lib/axon/generators.rb', line 83 def lineno @lineno end |
#width ⇒ Object (readonly)
The width of the generated image.
71 72 73 |
# File 'lib/axon/generators.rb', line 71 def width @width end |
Instance Method Details
#gets ⇒ Object
Gets the next scanline from the generated image.
103 104 105 106 107 |
# File 'lib/axon/generators.rb', line 103 def gets return nil if @lineno >= @height @lineno += 1 @color * width end |