Class: String

Inherits:
Object show all
Defined in:
lib/Miyako/API/color.rb,
lib/Miyako/API/shape.rb

Instance Method Summary collapse

Instance Method Details

#to_miyako_colorObject

:nodoc:


134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/Miyako/API/color.rb', line 134

def to_miyako_color #:nodoc:
  case self
  when /\A\[\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\,\s*(\d+)\s*\]\z/    #4要素の配列形式

    return [$1.to_i, $2.to_i, $3.to_i, $4.to_i]
  when /\A\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\z/    #4個の数列形式

    return [$1.to_i, $2.to_i, $3.to_i, $4.to_i]
  when /\A\#([\da-fA-F]{8})\z/      #HTML形式(#RRGGBBAA)

      return [$1[0,2].hex, $1[2,2].hex, $1[4,2].hex, $1[6,2].hex]
  when /\A\[\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\]\z/    #3要素の配列形式

    return [$1.to_i, $2.to_i, $3.to_i, 255]
  when /\A\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\z/    #3個の数列方式

    [$1.to_i, $2.to_i, $3.to_i, 255]
  when /\A\#([\da-fA-F]{6})\z/    #HTML形式(#RRGGBB)

    return [$1[0,2].hex, $1[2,2].hex, $1[4,2].hex, 255]
  else return self.to_sym.to_miyako_color
  end
end

#to_sprite(data) {|sprite| ... } ⇒ Object

data

描画するフォント(Fontクラスのインスタンス)

Yields:

  • (sprite)

439
440
441
442
443
# File 'lib/Miyako/API/shape.rb', line 439

def to_sprite(data)
  sprite = Miyako::Shape.text({:text => self, :font => data})
  yield sprite if block_given?
  return sprite
end