class Ellipsoid attr_reader :columns, :rows def initialize radius @columns = @rows = radius * 2 lower_half = (0...radius).map do |y| x = Math.sqrt(1 - y**2/radius**2).floor 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 def to_blob @blob end end