Guest User

Untitled

a guest
Apr 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. public static void fillCircleAlpha(int posX, int posY, int radius, int colour, int alpha)//draw circle? - used for highlighting the map symbols ;D
  2. {
  3. /*
  4. * looks like they used this as there base model
  5. * for(float i = -RADIUS; i < RADIUS; i +=RADIUS/NUM_LINES)
  6. * {
  7. * ycoord = i;
  8. * xcoord1 = sqrt(RADIUS^2 - i^2);
  9. * xcoord2 = -xcoord1;
  10. * }
  11. */
  12. int dest_intensity = 256 - alpha;
  13. int src_red = (colour >> 16 & 0xff) * alpha;
  14. int src_green = (colour >> 8 & 0xff) * alpha;
  15. int src_blue = (colour & 0xff) * alpha;
  16. int i3 = posY - radius;
  17. if(i3 < 0)
  18. i3 = 0;
  19. int j3 = posY + radius;
  20. if(j3 >= height)
  21. j3 = height - 1;
  22. for(int y = i3; y <= j3; y++)
  23. {
  24. int l3 = y - posY;
  25. int i4 = (int)Math.sqrt(radius * radius - l3 * l3);
  26. int x = posX - i4;
  27. if(x < 0)
  28. x = 0;
  29. int k4 = posX + i4;
  30. if(k4 >= width)
  31. k4 = width - 1;
  32. int pixel_offset = x + y * width;
  33. for(int i5 = x; i5 <= k4; i5++)
  34. {
  35. int dest_red = (pixels[pixel_offset] >> 16 & 0xff) * dest_intensity;
  36. int dest_green = (pixels[pixel_offset] >> 8 & 0xff) * dest_intensity;
  37. int dest_blue = (pixels[pixel_offset] & 0xff) * dest_intensity;
  38. int result_rgb = ((src_red + dest_red >> 8) << 16) + ((src_green + dest_green >> 8) << 8) + (src_blue + dest_blue >> 8);
  39. pixels[pixel_offset++] = result_rgb;
  40. }
  41.  
  42. }
  43.  
  44. }
  45. public static void fillCircle(int posX, int posY, int radius, int colour)
  46. {
  47. int i3 = posY - radius;
  48. if(i3 < 0)
  49. i3 = 0;
  50. int j3 = posY + radius;
  51. if(j3 >= height)
  52. j3 = height - 1;
  53. for(int y = i3; y <= j3; y++)
  54. {
  55. int l3 = y - posY;
  56. int i4 = (int)Math.sqrt(radius * radius - l3 * l3);
  57. int x = posX - i4;
  58. if(x < 0)
  59. x = 0;
  60. int k4 = posX + i4;
  61. if(k4 >= width)
  62. k4 = width - 1;
  63. int pixel_offset = x + y * width;
  64. for(int i5 = x; i5 <= k4; i5++)
  65. {
  66.  
  67. pixels[pixel_offset++] = colour;
  68. }
  69.  
  70. }
  71.  
  72. }
Add Comment
Please, Sign In to add comment