Sha256: 90785e69f83bd8792df99c5a8e1f510fc3e86c4a17be2491fac05920c5ae4a3c

Contents?: true

Size: 1.24 KB

Versions: 9

Compression:

Stored size: 1.24 KB

Contents

module Bioshogi
  module CoverImage
    concern :MainTextMethods do
      class_methods do
        def default_params
          super.merge({
              :font_size    => 80,
              :density      => "72x84", # xおよびy方向のテキスト密度。少し縦長にしておく。デフォルトは「72x72」
              :pull_to_top  => 0.02,    # 上にずらす割り合い。中央は下がって見えるため少し上に上げておく
            })
        end
      end

      private

      def main_text_render
        gc = Magick::Draw.new
        gc.font      = params[:font_regular].to_s
        gc.fill      = params[:font_color]
        gc.pointsize = params[:font_size]
        gc.density   = params[:density]
        gc.gravity   = Magick::CenterGravity # 中央
        # gc.interword_spacing = 0 # 半角スペースをさらに広げる場合に指定
        # gc.kerning = 0           # 文字間隔
        # gc.decorate = Magick::OverlineDecoration
        x = 0
        y = @canvas_layer.rows * -1 * params[:pull_to_top] # 高さ x pull_to_top のぶんだけ持ち上げる
        gc.annotate(@canvas_layer, 0, 0, x, y, text)
      end

      def text
        @text ||= text_normalize(params[:text])
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
bioshogi-0.0.15 lib/bioshogi/cover_image/main_text_methods.rb
bioshogi-0.0.14 lib/bioshogi/cover_image/main_text_methods.rb
bioshogi-0.0.10 lib/bioshogi/cover_image/main_text_methods.rb
bioshogi-0.0.9 lib/bioshogi/cover_image/main_text_methods.rb
bioshogi-0.0.8 lib/bioshogi/cover_image/main_text_methods.rb
bioshogi-0.0.7 lib/bioshogi/cover_image/main_text_methods.rb
bioshogi-0.0.5 lib/bioshogi/cover_image/main_text_methods.rb
bioshogi-0.0.4 lib/bioshogi/cover_image/main_text_methods.rb
bioshogi-0.0.3 lib/bioshogi/cover_image/main_text_methods.rb