Class: MemeCaptain::TextPos
- Inherits:
-
Object
- Object
- MemeCaptain::TextPos
- Defined in:
- lib/meme_captain/text_pos.rb
Overview
Text to put on an image with position and style options.
Instance Attribute Summary collapse
-
#draw_options ⇒ Object
Returns the value of attribute draw_options.
-
#height ⇒ Object
Returns the value of attribute height.
-
#max_lines ⇒ Object
Returns the value of attribute max_lines.
-
#min_pointsize ⇒ Object
Returns the value of attribute min_pointsize.
-
#text ⇒ Object
Returns the value of attribute text.
-
#width ⇒ Object
Returns the value of attribute width.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
-
#initialize(text, x, y, width, height, options = {}) ⇒ TextPos
constructor
x and y are the coordinates of the top left corner of the text bounding rectangle.
Constructor Details
#initialize(text, x, y, width, height, options = {}) ⇒ TextPos
x and y are the coordinates of the top left corner of the text bounding rectangle.
width and height are the width and height of the text bounding rectangle.
x, y, width and height can be in pixels or a float that represents a percentage of the width and height of the image the text is put onto.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/meme_captain/text_pos.rb', line 18 def initialize(text, x, y, width, height, = {}) @text = text @x = x @y = y @width = width @height = height @max_lines = .delete(:max_lines) || 16 @min_pointsize = .delete(:min_pointsize) || 12 @draw_options = { fill: 'white', font: 'Impact', gravity: Magick::CenterGravity, stroke: 'black', stroke_width: 8, }.merge() end |
Instance Attribute Details
#draw_options ⇒ Object
Returns the value of attribute draw_options.
44 45 46 |
# File 'lib/meme_captain/text_pos.rb', line 44 def @draw_options end |
#height ⇒ Object
Returns the value of attribute height.
41 42 43 |
# File 'lib/meme_captain/text_pos.rb', line 41 def height @height end |
#max_lines ⇒ Object
Returns the value of attribute max_lines.
42 43 44 |
# File 'lib/meme_captain/text_pos.rb', line 42 def max_lines @max_lines end |
#min_pointsize ⇒ Object
Returns the value of attribute min_pointsize.
43 44 45 |
# File 'lib/meme_captain/text_pos.rb', line 43 def min_pointsize @min_pointsize end |
#text ⇒ Object
Returns the value of attribute text.
37 38 39 |
# File 'lib/meme_captain/text_pos.rb', line 37 def text @text end |
#width ⇒ Object
Returns the value of attribute width.
40 41 42 |
# File 'lib/meme_captain/text_pos.rb', line 40 def width @width end |
#x ⇒ Object
Returns the value of attribute x.
38 39 40 |
# File 'lib/meme_captain/text_pos.rb', line 38 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
39 40 41 |
# File 'lib/meme_captain/text_pos.rb', line 39 def y @y end |