class ImageParadise::TextOnImage
Constants
- NAMESPACE
#¶ ↑
NAMESPACE
¶ ↑#¶ ↑
Public Class Methods
new( i = ARGV, run_already = true ) { || ... }
click to toggle source
#¶ ↑
initialize¶ ↑
#¶ ↑
# File lib/image_paradise/utility_scripts/text_on_image.rb, line 30 def initialize( i = ARGV, run_already = true ) reset set_commandline_arguments(i) # ======================================================================= # # === Handle blocks next # ======================================================================= # if block_given? yielded = yield case yielded # ===================================================================== # # === :do_not_run_yet # ===================================================================== # when :do_not_run_yet run_already = false end end run if run_already end
Public Instance Methods
colour_to_use?()
click to toggle source
coordinates?()
click to toggle source
determine_on_which_files_to_act()
click to toggle source
do_process_the_given_files( _ = @internal_hash[:work_on_these_files] )
click to toggle source
#¶ ↑
do_process_the_given_files
¶ ↑
#¶ ↑
# File lib/image_paradise/utility_scripts/text_on_image.rb, line 275 def do_process_the_given_files( _ = @internal_hash[:work_on_these_files] ) unless _.empty? _.each {|work_on_this_file| cmd_to_use = ''.dup cmd_to_use << 'convert ' if size? and !size?.empty? cmd_to_use << "-pointsize #{size?} " end if colour_to_use? and !colour_to_use?.empty? cmd_to_use << "-fill #{colour_to_use?} " end # =================================================================== # # Next let's draw the text. # =================================================================== # cmd_to_use << '-draw "text '+coordinates?+" '"+text?+"'"+'" ' cmd_to_use << "#{work_on_this_file} " if strokewidth? cmd_to_use << '-strokewidth '+strokewidth?.to_s+' ' end cmd_to_use << 'output_file.png' esystem(cmd_to_use.squeeze(' ')) } end if _ end
notify_the_user_whether_any_file_could_be_found_or_not()
click to toggle source
parse_the_hyphened_commandline_arguments( i = commandline_arguments? )
click to toggle source
#¶ ↑
parse_the_hyphened_commandline_arguments
(menu tag)¶ ↑
#¶ ↑
# File lib/image_paradise/utility_scripts/text_on_image.rb, line 173 def parse_the_hyphened_commandline_arguments( i = commandline_arguments? ) html_colours = Colours.html_colours.map {|entry| Regexp.new("^-?-?#{entry}$") } i.select {|entry| entry.start_with? '--' }.each {|entry| case entry # ===================================================================== # # === --darkblue # ===================================================================== # when *html_colours set_use_this_colour(entry) # ===================================================================== # # === --strokewidth="abc def" # ===================================================================== # when /^-?-?strokewidth=(.+)/ set_use_this_strokewidth($1) # ===================================================================== # # === --text="abc def" # ===================================================================== # when /^-?-?text=(.+)/ set_use_this_text($1) # ===================================================================== # # === --colour=steelblue # ===================================================================== # when /^-?-?colou?r=(.+)/ set_use_this_colour($1) # ===================================================================== # # === --font-size=3 # ===================================================================== # when /^-?-?font(-|_)size=(.+)/ # We grab the second entry here. set_use_this_font_size($2) # ===================================================================== # # === --position=3 # ===================================================================== # when /^-?-?position=(.+)/ set_use_this_position($1) else if File.exist? entry # ================================================================= # # Existing local files will be captured here. # ================================================================= # set_filename(entry) end end } i.each {|entry| set_filename(entry) if File.exist?(entry) } end
Also aliased as: menu
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
# File lib/image_paradise/utility_scripts/text_on_image.rb, line 55 def reset # ======================================================================= # # === @namespace # ======================================================================= # @namespace = NAMESPACE # ======================================================================= # # === @internal_hash # ======================================================================= # @internal_hash = {} # ======================================================================= # # === :write_this_text # # This variable keeps track as to which text is to be written. # ======================================================================= # @internal_hash[:write_this_text] = ''.dup # ======================================================================= # # === :use_this_colour # ======================================================================= # @internal_hash[:use_this_colour] = nil # ======================================================================= # # === :strokewidth # ======================================================================= # @internal_hash[:strokewidth] = nil # ======================================================================= # # Set up some default values next past this point. # ======================================================================= # set_use_this_position end
run()
click to toggle source
set_files(i)
click to toggle source
#¶ ↑
set_files
¶ ↑
#¶ ↑
# File lib/image_paradise/utility_scripts/text_on_image.rb, line 238 def set_files(i) @internal_hash[:work_on_these_files] = [i].flatten.compact end
Also aliased as: set_file, set_filename
set_use_this_colour(i)
click to toggle source
set_use_this_font_size(i = :default)
click to toggle source
#¶ ↑
set_use_this_font_size
¶ ↑
#¶ ↑
# File lib/image_paradise/utility_scripts/text_on_image.rb, line 261 def set_use_this_font_size(i = :default) case i # ======================================================================= # # === :default # ======================================================================= # when :default i = 35 end @internal_hash[:use_this_font_size] = i.to_s.dup.to_i end
Also aliased as: set_font_size
set_use_this_position( i = :default )
click to toggle source
#¶ ↑
set_use_this_position
¶ ↑
#¶ ↑
# File lib/image_paradise/utility_scripts/text_on_image.rb, line 117 def set_use_this_position( i = :default ) case i # ======================================================================= # # === :default # ======================================================================= # when :default i = ::ImageParadise.default_position? end @internal_hash[:use_this_position] = i.to_s.dup end
set_use_this_strokewidth(i)
click to toggle source
set_use_this_text( i, optional_change_stuff = nil )
click to toggle source
#¶ ↑
set_use_this_text
¶ ↑
#¶ ↑
# File lib/image_paradise/utility_scripts/text_on_image.rb, line 147 def set_use_this_text( i, optional_change_stuff = nil ) if i.is_a? Array case optional_change_stuff # ===================================================================== # # === :without_hyphened_arguments # ===================================================================== # when :without_hyphened_arguments i = i.reject {|entry| entry.start_with?('--') } end i = i.join(' ') end @internal_hash[:write_this_text] = i.to_s.dup end
Also aliased as: set_text
size?()
click to toggle source
strokewidth?()
click to toggle source
text?()
click to toggle source