diff --git a/lib/squib/api/text.rb b/lib/squib/api/text.rb index 746536d..8f69c58 100644 --- a/lib/squib/api/text.rb +++ b/lib/squib/api/text.rb @@ -34,18 +34,19 @@ module Squib # @option opts justify [Boolean] (false) toggles whether or not the text is justified or not. # @option opts valign [:top, :middle, :bottom] (:top) When width and height are set, align text vertically according to the ink extents of the text. # @option opts ellipsize [:none, :start, :middle, :end, true, false] (:end) When width and height are set, determines the behavior of overflowing text. Also: `true` maps to `:end` and `false` maps to `:none`. Default `:end` + # @option opts angle [FixNum] (0) Rotation of the text in radians. # @option opts hint [String] (:nil) draw a rectangle around the text with the given color. Overrides global hints (see {Deck#hint}). # @return [nil] Returns nothing # @api public def text(opts = {}) opts = needs(opts, [:range, :str, :font, :font_size, :x, :y, :width, :height, :color, :wrap, - :align, :justify, :spacing, :valign, :markup, :ellipsize, :hint, :layout, :rotation]) + :align, :justify, :spacing, :valign, :markup, :ellipsize, :hint, :layout, :angle]) opts[:range].each do |i| @cards[i].text(opts[:str][i], opts[:font][i], opts[:font_size][i], opts[:color][i], opts[:x][i], opts[:y][i], opts[:width][i], opts[:height][i], opts[:markup][i], opts[:justify][i], opts[:wrap][i], opts[:ellipsize][i], opts[:spacing][i], opts[:align][i], - opts[:valign][i], opts[:hint][i], opts[:rotation][i]) + opts[:valign][i], opts[:hint][i], opts[:angle][i]) end end diff --git a/lib/squib/constants.rb b/lib/squib/constants.rb index 2b09400..7d0abfb 100644 --- a/lib/squib/constants.rb +++ b/lib/squib/constants.rb @@ -5,6 +5,7 @@ module Squib SYSTEM_DEFAULTS = { :align => :left, :alpha => 1.0, + :angle => 0, :blend => :none, :color => :black, :default_font => 'Arial 36', @@ -26,7 +27,6 @@ module Squib :progress_bar => false, :range => :all, :rotate => false, - :rotation => 0, :sheet => 0, :spacing => 0, :str => '', @@ -71,6 +71,7 @@ module Squib EXPANDING_PARAMS = { :align => :align, :alpha => :alpha, + :angle => :angle, :blend => :blend, :circle_radius => :radius, :color => :color, @@ -86,7 +87,6 @@ module Squib :layout => :layout, :markup => :markup, :rect_radius => :radius, - :rotation => :rotation, :spacing => :spacing, :str => :str, :stroke_color => :stroke_color, diff --git a/lib/squib/graphics/text.rb b/lib/squib/graphics/text.rb index f8843c0..c74ba5d 100644 --- a/lib/squib/graphics/text.rb +++ b/lib/squib/graphics/text.rb @@ -88,12 +88,12 @@ module Squib def text(str, font, font_size, color, x, y, width, height, markup, justify, wrap, ellipsize, - spacing, align, valign, hint, rotation) - Squib.logger.debug {"Placing '#{str}'' with font '#{font}' @ #{x}, #{y}, color: #{color}, etc."} + spacing, align, valign, hint, angle) + Squib.logger.debug {"Placing '#{str}'' with font '#{font}' @ #{x}, #{y}, color: #{color}, rotate: #{rotation} etc."} use_cairo do |cc| cc.set_source_color(color) cc.move_to(x,y) - cc.rotate(rotation) + cc.rotate(angle) layout = cc.create_pango_layout font_desc = Pango::FontDescription.new(font) font_desc.size = font_size * Pango::SCALE unless font_size.nil? diff --git a/samples/text_options.rb b/samples/text_options.rb index e193e78..2c8cee5 100644 --- a/samples/text_options.rb +++ b/samples/text_options.rb @@ -48,7 +48,7 @@ Squib::Deck.new(width: 825, height: 1125, cards: 3) do font: 'Arial 22' text str: "Rotated", - x: 565, y: 675, rotation: 0.1, + x: 565, y: 675, angle: 0.1, font: 'Arial 18' text str: longtext, font: 'Arial 16',