Method: Gosu::Image#draw_rot

Defined in:
lib/gosu_android/graphics/image.rb

#draw_rot(x, y, z, angle, center_x = 0.5, center_y = 0.5, factor_x = 1.0, factor_y = 1.0, c = Color::WHITE, mode = :default) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/gosu_android/graphics/image.rb', line 90

def draw_rot(x, y, z, angle, center_x = 0.5, center_y = 0.5, factor_x = 1.0,
  factor_y = 1.0, c = Color::WHITE, mode = :default)

  size_y = width  * factor_x
  size_y = height * factor_y
  offs_x = Gosu::offset_x(angle, 1)
  offs_y = Gosu::offset_y(angle, 1)

  #Offset to the centers of the original Image's edges when it is rotated
  #by <angle> degrees.
  dist_to_left_x   = +offs_y * size_y * center_x
  dist_to_left_y   = -offs_x * size_y * center_x
  dist_to_right_x  = -offs_y * size_y * (1 - center_x)
  dist_to_right_y  = +offs_x * size_y * (1 - center_x)
  dist_to_top_x    = +offs_x * size_y * center_y
  dist_to_top_y    = +offs_y * size_y * center_y
  dist_to_bottom_x = -offs_x * size_y * (1 - center_y)
  dist_to_bottom_y = -offs_y * size_y * (1 - center_y)

  @data.draw(x + dist_to_left_x  + dist_to_top_x,
    y + dist_to_left_y  + dist_to_top_y, c,
    x + dist_to_right_x + dist_to_top_x,
    y + dist_to_right_y + dist_to_top_y, c,
    x + dist_to_left_x  + dist_to_bottom_x,
    y + dist_to_left_y  + dist_to_bottom_y, c,
    x + dist_to_right_x + dist_to_bottom_x,
    y + dist_to_right_y + dist_to_bottom_y,
    c, z, AM_MODES[mode])
end