Class: Miyako::Drawer

Inherits:
Object show all
Includes:
Animation, Layout, SpriteBase
Defined in:
lib/Miyako/EXT/drawer.rb

Overview

SpriteBase, Animation, Layoutモジュールのメソッドが利用可能

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Layout

#add_snap_child, #bottom, #bottom!, #broad_rect, #center, #center!, #centering, #centering!, #copy_layout, #delete_snap_child, #get_snap_children, #get_snap_sprite, #h, #include_snap_child?, #init_layout, #layout_dispose, #left, #left!, #middle, #middle!, #move, #move!, #move_to, #move_to!, #on_move, #outside_bottom, #outside_bottom!, #outside_left, #outside_left!, #outside_right, #outside_right!, #outside_top, #outside_top!, #pos, #relative_move_to, #relative_move_to!, #reset_snap, #right, #right!, #segment, #set_layout_size, #set_snap_children, #set_snap_sprite, #size, #snap, #top, #top!, #update_layout, #update_layout_position, #w, #x, #y

Methods included from Animation

[], []=, anim_hash, #reset, reset, start, #start, #stop, stop, update, update_animation, #update_animation

Methods included from SpriteBase

#bitmap, #hide, #image_rect, #image_size, #oh, #oh=, #ow, #ow=, #ox, #ox=, #oy, #oy=, #part_rect, #render_d, #render_to, #render_xy_to, #show, #to_sprite, #to_unit, #update

Constructor Details

#initialize(hash) ⇒ Drawer

図形描画オブジェクトを作る 引数はハッシュ引数 それぞれのキーは、Drawerクラスオブジェクトのメソッドとしてアクセス可能 :method => メソッドを指定(:fill,:pset,:line,:rect,:circle,:ellipse,:polygon) 省略不可 :base => 描画先スプライト 全メソッドで有効 省略時はScreen(画面) :color => 描画色 全メソッドで有効 省略時は白色() :point => 描画開始座標/円の中心座標(Point構造体) :pset, :circle, :ellipseのみ有効 省略時はPoint(0,0) :rect => 描画矩形(Rect構造体) :line,:rectのみ有効 省略時はRect(0,0,1,1) :points => 座標の配列() :polygonのみ有効 省略時は空の配列 :r => 円の半径(数値) :circleのみ有効 省略時は1 :rx => 楕円の横方向半径 :ellipseのみ有効 省略時は1 :ry => 楕円の縦方向半径 :ellipseのみ有効 省略時は1 :aa => アンチエイリアスを付けるかどうか(true/false) :line, :cirle, :ellipse, :polygonのみ有効 省略時はfalse :fill => 描画色で図形の中を塗りつぶすかどうか(true/false) :rect, :circle, :ellipse, :polygonのみ有効 省略時はfalse

Raises:


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/Miyako/EXT/drawer.rb', line 32

def initialize(hash)
  init_layout
  set_layout_size(1,1)
  @method = hash[:method]
  @base   = hash[:base] || Screen
  @color  = hash[:color] || [255,255,255]
  @point  = hash[:point] ? Point.new(*(hash[:point].to_a)) : Point.new(0,0)
  @rect  = hash[:rect] ? Rect.new(*(hash[:rect].to_a)) : Rect.new(0,0,1,1)
  @points = hash[:points] ? hash[:points].map{|pos| Point.new(*pos.to_a)} : []
  @r = hash[:r] || 1
  @rx = hash[:rx] || 1
  @ry = hash[:ry] || 1
  @aa = hash[:aa] || false
  @fill = hash[:fill] || false
  @visible = true
  @off = Point.new(0,0)
  raise MiyakoError, "set correct method name by symbol!" unless @method
end

Instance Attribute Details

#aaObject

Returns the value of attribute aa


14
15
16
# File 'lib/Miyako/EXT/drawer.rb', line 14

def aa
  @aa
end

#baseObject

Returns the value of attribute base


16
17
18
# File 'lib/Miyako/EXT/drawer.rb', line 16

def base
  @base
end

#colorObject

Returns the value of attribute color


13
14
15
# File 'lib/Miyako/EXT/drawer.rb', line 13

def color
  @color
end

#fill=(value) ⇒ Object

Sets the attribute fill

Parameters:

  • value

    the value to set the attribute fill to.


14
15
16
# File 'lib/Miyako/EXT/drawer.rb', line 14

def fill=(value)
  @fill = value
end

#methodObject

Returns the value of attribute method


13
14
15
# File 'lib/Miyako/EXT/drawer.rb', line 13

def method
  @method
end

#pointObject

Returns the value of attribute point


16
17
18
# File 'lib/Miyako/EXT/drawer.rb', line 16

def point
  @point
end

#pointsObject

Returns the value of attribute points


16
17
18
# File 'lib/Miyako/EXT/drawer.rb', line 16

def points
  @points
end

#rObject

Returns the value of attribute r


14
15
16
# File 'lib/Miyako/EXT/drawer.rb', line 14

def r
  @r
end

#rect=(value) ⇒ Object

Sets the attribute rect

Parameters:

  • value

    the value to set the attribute rect to.


16
17
18
# File 'lib/Miyako/EXT/drawer.rb', line 16

def rect=(value)
  @rect = value
end

#rxObject

Returns the value of attribute rx


14
15
16
# File 'lib/Miyako/EXT/drawer.rb', line 14

def rx
  @rx
end

#ryObject

Returns the value of attribute ry


14
15
16
# File 'lib/Miyako/EXT/drawer.rb', line 14

def ry
  @ry
end

#visibleObject

Returns the value of attribute visible


15
16
17
# File 'lib/Miyako/EXT/drawer.rb', line 15

def visible
  @visible
end

Instance Method Details

#renderObject


51
52
53
54
55
# File 'lib/Miyako/EXT/drawer.rb', line 51

def render
  return self unless @visible
  @off.move_to!(0,0)
  __send__(@method)
end

#render_xy(x, y) ⇒ Object


57
58
59
60
61
# File 'lib/Miyako/EXT/drawer.rb', line 57

def render_xy(x, y)
  return self unless @visible
  @off.move_to!(x,y)
  __send__(@method)
end