Class: Compass::Magick::Types::Solid
- Inherits:
-
Compass::Magick::Type
- Object
- Compass::Magick::Type
- Compass::Magick::Types::Solid
- Includes:
- Utils
- Defined in:
- lib/magick/types/solid.rb
Overview
A type that generates a Canvas from a region filled with a solid color.
Instance Attribute Summary collapse
-
#color ⇒ Sass::Script::Color
readonly
The solid background color.
Attributes included from Scriptable
Instance Method Summary collapse
-
#initialize(color) ⇒ Solid
constructor
Initializes a new Solid instance.
- #to_canvas(width, height) ⇒ Object
Methods included from Utils
#assert_one_of, #assert_type, #to_chunky_color, #value_of
Constructor Details
#initialize(color) ⇒ Solid
Initializes a new Solid instance.
18 19 20 21 |
# File 'lib/magick/types/solid.rb', line 18 def initialize(color) assert_type 'color', color, Sass::Script::Color @color = color end |
Instance Attribute Details
#color ⇒ Sass::Script::Color (readonly)
Returns The solid background color.
24 25 26 |
# File 'lib/magick/types/solid.rb', line 24 def color @color end |
Instance Method Details
#to_canvas(width, height) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/magick/types/solid.rb', line 26 def to_canvas(width, height) assert_type 'width', width, Sass::Script::Number assert_type 'height', height, Sass::Script::Number color = to_chunky_color(@color) canvas = Canvas.new(width, height) (0...canvas.height).each do |y| (0...canvas.width).each do |x| canvas.set_pixel(x, y, color) end end canvas end |