IceDragon200

[RUBY]DrawCircle

Apr 15th, 2012
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.69 KB | None | 0 0
  1. class Bitmap
  2.   # // 04/15/2012
  3.   def draw_circle(circle,color,fill=false)
  4.     x, y = nil, nil
  5.     mcircle = circle.clone
  6.     for i in 0...360
  7.       if(fill)
  8.         x, y = circle.get_angle_xy(i)
  9.         set_pixel(x,y,color)
  10.       else  
  11.         circle = mcircle.clone
  12.         for r in 0...mcircle.radius
  13.           circle.radius = r
  14.           x, y = circle.get_angle_xy(i)
  15.           set_pixel(x,y,color)
  16.         end  
  17.       end  
  18.     end
  19.   end    
  20. end
  21. # // Test
  22. MouseEx.init
  23. bmp = Bitmap.new(256,256)
  24. circle = Circle.new(128,128,98)
  25. bmp.draw_circle(circle,Pallete[:sys_orange])
  26. spr = Sprite.new()
  27. spr.bitmap = bmp
  28. spr.salign(1,1)
  29. loop do
  30.   Main.update
  31.   spr.update
  32. end
Advertisement
Add Comment
Please, Sign In to add comment