Class: Cheers::Texture
- Inherits:
-
ImageComponent
- Object
- Component
- ImageComponent
- Cheers::Texture
- Defined in:
- lib/cheers/texture.rb
Constant Summary collapse
- IMAGES =
%w( texture.png )
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#image ⇒ Object
readonly
Returns the value of attribute image.
Attributes inherited from ImageComponent
#canvas, #color_randomizer, #image_randomizer
Attributes inherited from Component
Instance Method Summary collapse
- #apply ⇒ Object
-
#initialize(canvas, color_randomizer, element_randomizer = nil) ⇒ Texture
constructor
A new instance of Texture.
Methods inherited from Component
#base_image, #colored_image, #composite_with_mask, #extract_background_color, #image_path
Constructor Details
#initialize(canvas, color_randomizer, element_randomizer = nil) ⇒ Texture
Returns a new instance of Texture.
8 9 10 11 12 |
# File 'lib/cheers/texture.rb', line 8 def initialize(canvas, color_randomizer, element_randomizer = nil) super @image = IMAGES.sample random: element_randomizer end |
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
6 7 8 |
# File 'lib/cheers/texture.rb', line 6 def color @color end |
#image ⇒ Object (readonly)
Returns the value of attribute image.
6 7 8 |
# File 'lib/cheers/texture.rb', line 6 def image @image end |
Instance Method Details
#apply ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/cheers/texture.rb', line 14 def apply texture = MiniMagick::Image.open(image_path(image)) canvas.composite(texture) do |c| c.compose "Over" # OverCompositeOp c.geometry "+0+0" end end |