class Circle

circle.rb gist.github.com/661266

Attributes

columns[R]
rows[R]

Public Class Methods

new(radius) click to toggle source
# File lib/r2d/circle.rb, line 7
def initialize radius
  @columns = @rows = radius * 2
  lower_half = (0...radius).map do |y|
    x = Math.sqrt(radius**2 - y**2).round
    right_half = "#{"\xff" * x}#{"\x00" * (radius - x)}"
    "#{right_half.reverse}#{right_half}"
  end.join
  @blob = lower_half.reverse + lower_half
  @blob.gsub!(/./) { |alpha| "\xff\xff\xff#{alpha}"}
end

Public Instance Methods

to_blob() click to toggle source
# File lib/r2d/circle.rb, line 18
def to_blob
  @blob
end