Sha256: fa67a819064e852251ea306709e5fa505059ea01206f9f4a237a0e231ec79224

Contents?: true

Size: 932 Bytes

Versions: 1

Compression:

Stored size: 932 Bytes

Contents

module Gosu
  ##
  # Draw a filled circled around point X and Y.
  #
  # @param x X position.
  # @param y Y position.
  # @param radius radius of circle, in pixels.
  # @param step_size resolution of circle, more steps will apear smoother, less will appear jagged.
  # @param color color to draw circle with.
  # @param mode blend mode.
  #
  # @return [void]
  def self.draw_circle(x, y, radius, step_size = 36, color = Gosu::Color::WHITE, z = 0, mode = :default)
    step_size = (360.0 / step_size).floor

    0.step(359, step_size) do |angle|
      angle2 = angle + step_size

      point_lx = x + Gosu.offset_x(angle, radius)
      point_ly = y + Gosu.offset_y(angle, radius)
      point_rx = x + Gosu.offset_x(angle2, radius)
      point_ry = y + Gosu.offset_y(angle2, radius)

      Gosu.draw_triangle(
        point_lx, point_ly, color,
	      point_rx, point_ry, color,
	      x, y, color, z, mode
      )
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gosu_more_drawables-0.3.1 lib/gosu_more_drawables/draw_circle.rb