Advertisement
Guest User

Color.inc

a guest
Jun 28th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.83 KB | None | 0 0
  1. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  2. Include:
  3.  
  4. 6:56 p.m, 24/09/2007
  5. color.inc, Simon Campbell
  6. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  7.  
  8. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  9. Global
  10. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  11.  
  12. #if defined __color__included
  13. #endinput
  14. #endif
  15.  
  16. #define __color__included
  17.  
  18. /* -- Colours
  19. */
  20.  
  21. #if !defined _COLOR_BLACK
  22. #define _COLOR_BLACK 0x000000FF
  23. #endif
  24.  
  25. #if !defined _COLOR_NAVY
  26. #define _COLOR_NAVY 0x000080FF
  27. #endif
  28.  
  29. #if !defined _COLOR_BLUE
  30. #define _COLOR_BLUE 0x0000FFFF
  31. #endif
  32.  
  33. #if !defined _COLOR_GREEN
  34. #define _COLOR_GREEN 0x008000FF
  35. #endif
  36.  
  37. #if !defined _COLOR_TEAL
  38. #define _COLOR_TEAL 0x008080FF
  39. #endif
  40.  
  41. #if !defined _COLOR_LIME
  42. #define _COLOR_LIME 0x00FF00FF
  43. #endif
  44.  
  45. #if !defined _COLOR_AQUA
  46. #define _COLOR_AQUA 0x00FFFFFF
  47. #endif
  48.  
  49. #if !defined _COLOR_CYAN
  50. #define _COLOR_CYAN 0x00FFFFFF
  51. #endif
  52.  
  53. #if !defined _COLOR_MAROON
  54. #define _COLOR_MAROON 0x800000FF
  55. #endif
  56.  
  57. #if !defined _COLOR_PURPLE
  58. #define _COLOR_PURPLE 0x800080FF
  59. #endif
  60.  
  61. #if !defined _COLOR_OLIVE
  62. #define _COLOR_OLIVE 0x808000FF
  63. #endif
  64.  
  65. #if !defined _COLOR_GRAY
  66. #define _COLOR_GRAY 0x808080FF
  67. #endif
  68.  
  69. #if !defined _COLOR_GREY
  70. #define _COLOR_GREY 0x808080FF
  71. #endif
  72.  
  73. #if !defined _COLOR_SILVER
  74. #define _COLOR_SILVER 0xC0C0C0FF
  75. #endif
  76.  
  77. #if !defined _COLOR_RED
  78. #define _COLOR_RED 0xFF0000FF
  79. #endif
  80.  
  81. #if !defined _COLOR_FUCHSIA
  82. #define _COLOR_FUCHSIA 0xFF00FFFF
  83. #endif
  84.  
  85. #if !defined _COLOR_PINK
  86. #define _COLOR_PINK 0xFF00FFFF
  87. #endif
  88.  
  89. #if !defined _COLOR_YELLOW
  90. #define _COLOR_YELLOW 0xFFFF00FF
  91. #endif
  92.  
  93. #if !defined _COLOR_WHITE
  94. #define _COLOR_WHITE 0xFFFFFFFF
  95. #endif
  96.  
  97.  
  98. /* -- Other
  99. */
  100.  
  101. #define NO_SET -1
  102.  
  103. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  104. Functions
  105. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  106.  
  107. stock setRed( color, red ) // Set the red intensity on a colour.
  108. {
  109. if ( red > 0xFF )
  110. red = 0xFF;
  111. else if ( red < 0x00 )
  112. red = 0x00;
  113.  
  114. return ( color & 0x00FFFFFF ) | ( red << 24 );
  115. }
  116.  
  117. stock setGreen( color, green ) // Set the green intensity on a colour.
  118. {
  119. if ( green > 0xFF )
  120. green = 0xFF;
  121. else if ( green < 0x00 )
  122. green = 0x00;
  123.  
  124. return ( color & 0xFF00FFFF ) | ( green << 16 );
  125. }
  126.  
  127. stock setBlue( color, blue ) // Set the blue intensity on a colour.
  128. {
  129. if ( blue > 0xFF )
  130. blue = 0xFF;
  131. else if ( blue < 0x00 )
  132. blue = 0x00;
  133.  
  134. return ( color & 0xFFFF00FF ) | ( blue << 8 );
  135. }
  136.  
  137. stock setAlpha( color, alpha ) // Set the alpha intensity on a colour.
  138. {
  139. if ( alpha > 0xFF )
  140. alpha = 0xFF;
  141. else if ( alpha < 0x00 )
  142. alpha = 0x00;
  143.  
  144. return ( color & 0xFFFFFF00 ) | alpha;
  145. }
  146.  
  147. stock stripRed( color ) // Remove all red from a colour.
  148. return ( color ) & 0x00FFFFFF;
  149.  
  150. stock stripGreen( color ) // Remove all green from a colour.
  151. return ( color ) & 0xFF00FFFF;
  152.  
  153. stock stripBlue( color ) // Remove all blue from a colour.
  154. return ( color ) & 0xFFFF00FF;
  155.  
  156. stock stripAlpha( color ) // Remove all alpha from a colour.
  157. return ( color ) & 0xFFFFFF00;
  158.  
  159. stock fillRed( color ) // Fill all red in a colour.
  160. return ( color ) | 0xFF000000;
  161.  
  162. stock fillGreen( color ) // Fill all green in a colour.
  163. return ( color ) | 0x00FF0000;
  164.  
  165. stock fillBlue( color ) // Fill all blue in a colour.
  166. return ( color ) | 0x0000FF00;
  167.  
  168. stock fillAlpha( color ) // Fill all alpha in a colour.
  169. return ( color ) | 0x000000FF;
  170.  
  171. stock getRed( color ) // Get the intensity of red in a colour.
  172. return ( color >> 24 ) & 0x000000FF;
  173.  
  174. stock getGreen( color ) // Get the intensity of green in a colour.
  175. return ( color >> 16 ) & 0x000000FF;
  176.  
  177. stock getBlue( color ) // Get the intensity of blue in a colour.
  178. return ( color >> 8 ) & 0x000000FF;
  179.  
  180. stock getAlpha( color ) // Get the intensity of alpha in a colour.
  181. return ( color ) & 0x000000FF;
  182.  
  183. stock makeColor( red=0, green=0, blue=0, alpha=0 ) // Make a colour with the specified intensities.
  184. return ( setAlpha( setBlue( setGreen( setRed( 0x00000000, red ), green ), blue ), alpha ) );
  185.  
  186. stock setColor( color, red = NO_SET, green = NO_SET, blue = NO_SET, alpha = NO_SET ) // Set the properties of a colour.
  187. {
  188. if ( red != NO_SET )
  189. color = setRed ( color, red );
  190. if ( green != NO_SET )
  191. color = setGreen ( color, green );
  192. if ( blue != NO_SET )
  193. color = setBlue ( color, blue );
  194. if ( alpha != NO_SET )
  195. color = setAlpha ( color, alpha );
  196.  
  197. return color;
  198. }
  199.  
  200. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  201. End Of Include: color.inc, Simon Campbell
  202. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement