oreolek
/
particles
Archived
1
0
Fork 0
This repository has been archived on 2019-04-06. You can view files and clone it, but cannot push or open issues or pull requests.
particles/ellipsoid.rb

19 lines
447 B
Ruby

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