Class: Textorize::Saver
Instance Attribute Summary collapse
-
#png ⇒ Object
readonly
Returns the value of attribute png.
Instance Method Summary collapse
-
#initialize(renderer) ⇒ Saver
constructor
A new instance of Saver.
- #write_to_file(file) ⇒ Object
Constructor Details
#initialize(renderer) ⇒ Saver
Returns a new instance of Saver.
6 7 8 9 |
# File 'lib/textorize/saver.rb', line 6 def initialize(renderer) @bitmap = renderer.bitmap @png = @bitmap.representationUsingType_properties(NSPNGFileType, nil) end |
Instance Attribute Details
#png ⇒ Object (readonly)
Returns the value of attribute png.
4 5 6 |
# File 'lib/textorize/saver.rb', line 4 def png @png end |
Instance Method Details
#write_to_file(file) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/textorize/saver.rb', line 11 def write_to_file(file) @png.writeToFile_atomically(file, true) cg = @bitmap.CGImage w, h = CGImageGetWidth(cg), CGImageGetHeight(cg) puts "\n{\n background: url(#{file});\n width: #{w}px;\n height: #{h}px;\n}\n" end |