Guest User

Untitled

a guest
Jun 20th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. require 'rubygems'
  2. require 'gosu'
  3.  
  4. class Circle
  5. attr_reader :columns, :rows
  6.  
  7. def initialize radius
  8. @columns = @rows = radius * 2
  9. lower_half = (0...radius).map do |y|
  10. x = Math.sqrt(radius**2 - y**2).round
  11. right_half = "#{"\xff" * x}#{"\x00" * (radius - x)}"
  12. "#{right_half.reverse}#{right_half}"
  13. end.join
  14. @blob = lower_half.reverse + lower_half
  15. @blob.gsub!(/./) { |alpha| "\xff\xff\xff#{alpha}"}
  16. end
  17.  
  18. def to_blob
  19. @blob
  20. end
  21. end
  22.  
  23. class TestWin < Gosu::Window
  24. def initialize
  25. super 400, 400, false
  26.  
  27. @img = Gosu::Image.new(self, Circle.new(200), false)
  28. end
  29.  
  30. def draw
  31. @img.draw 0, 0, 0
  32. end
  33. end
  34.  
  35. TestWin.new.show
Add Comment
Please, Sign In to add comment