Ooops
January 26, 2021, 06:42:34 AM

Author Topic: [bb] Colours By Name by Streaksy [ 1+ years ago ]  (Read 504 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Colours By Name by Streaksy [ 1+ years ago ]
« on: June 29, 2017, 12:28:39 AM »
Title : Colours By Name
Author : Streaksy
Posted : 1+ years ago

Description : Instead of using:
Code: [Select]
Color 152,141,121
ClsColor 152,141,121


You can now use:
Code: [Select]
Colour "Magenta"
ClsColour "Burgundy"

(The UK spelling instead of the US spelling.  Easily changed if you don't like it.)

You can supply a brightness aswell.  255 is normal.  Less than that is dark, higher than that is light.  I guess it goes 0-512.  eg. Colour "Red",150

That's useful for the 3D effects on window edges etc., when you want to easily get the lighter/darker equivelents of a colour.

I love my colour list for some reason.  I've nurtured it for a long time. :P
At the start of the code is a constant, Colour_Demo.  If it's set to one, when you run it, you get a colour chart.  If not, the program runs as normal.  It's all arranged as an includable.

It's best to keep the colour chart code in to use as a reference.  Compiled EXEs won't have the code for it anyway as IFs that involve a constant dont get their contents compiled if it the result is false.

I first started on this like 2 years ago because I made a GUI library with colour dialogues to choose the interface's colours etc.  Now I just keep it as a bit of fun mostly that might come in handy.  I've enjoyed making the list and getting the colours right.  

There's a bunch of other colour fuctions aswell.

Edit: Just realised I still had the RGB2HSB code in.  I think it was by `jfk EO-11110'.  I took it out because it's not mine.  (It's great code and if you want it it's in the Algorithms section of the code archives.)
. [/i]

Code :
Code: BlitzBasic
  1. Const Colour_Demo=1         ;run this bb with this const set
  2. as 1 to see the colour chart
  3.  
  4.  
  5. Const ColourLibPresent=1
  6.  
  7. Global BGcolR=-1,BGcolG=-1,BGcolB=-1
  8.  
  9. Global Colours,MaxColours=200
  10. Dim ColourName$(MaxColours)
  11. Dim ColourLen(MaxColours)
  12. Dim ColourR(MaxColours)
  13. Dim ColourG(MaxColours)
  14. Dim ColourB(MaxColours)
  15. Dim ColourRGB(MaxColours)
  16.  
  17. Global sat#,lumin#,hue# ;returned by RGB2HSB()
  18.  
  19. AddColour "Blue"                  ,65,95,255
  20. AddColour "Red"                   ,215,25,25
  21. AddColour "Yellow"                ,255,215,55
  22. AddColour "Green"                 ,75,215,35
  23. AddColour "Orange"                ,245,131,25
  24. AddColour "Brown"                 ,85,45,25
  25. AddColour "Pink"                  ,255,125,165
  26. AddColour "Purple"                ,122,0,100
  27. AddColour "Cyan"                  ,85,195,255
  28. AddColour "Aqua"                  ,85,215,135
  29. AddColour "Indigo"                ,100,38,204
  30. AddColour "Violet"                ,145,65,255
  31. AddColour "Magenta"               ,238,2,128
  32. AddColour "Fuchsia"               ,210,0,90
  33. AddColour "Lilac"                 ,190,150,250
  34. AddColour "Lavender"              ,160,150,250
  35. AddColour "Teal"                  ,0,167,160
  36. AddColour "Turquoise"             ,0,210,170
  37. AddColour "Mauve"                 ,186,126,150
  38. AddColour "Beige"                 ,209,196,174
  39. AddColour "Jade"                  ,53,133,85
  40. AddColour "Cream"                 ,240,225,170
  41. AddColour "Taupe"                 ,174,159,138
  42. AddColour "Buff"                  ,76,86,80
  43. AddColour "Peach"                 ,255,180,80
  44. AddColour "Nutmeg"                ,128,100,70
  45. AddColour "Plum"                  ,70,14,54
  46. AddColour "Salmon"                ,229,107,83
  47. AddColour "Burgundy"              ,65,5,34
  48. AddColour "Tan"                   ,190,130,80
  49. AddColour "Olive"                 ,97,108,53
  50. AddColour "Chestnut"              ,92,32,16
  51. AddColour "Navy Blue"             ,0,38,73
  52. AddColour "Sky Blue"              ,105,135,245
  53. AddColour "Lemon"                 ,255,255,55
  54. AddColour "Lime"                  ,5,205,5
  55. AddColour "Hot Pink"              ,245,0,200
  56. AddColour "Mint"                  ,172,255,172
  57. AddColour "Walnut"                ,163,129,79
  58. AddColour "Coral"                 ,252,125,95
  59. AddColour "Cherry"                ,175,0,30
  60. AddColour "Maroon"                ,88,28,33
  61. AddColour "Azure"                 ,13,119,183
  62. AddColour "Cedar"                 ,163,43,64
  63. AddColour "Safron"                ,255,180,0
  64. AddColour "Crimson"               ,95,0,10
  65. AddColour "Scarlet"               ,135,15,15
  66. AddColour "Royal Purple"          ,70,0,90
  67. AddColour "Slate"                 ,56,59,63
  68. AddColour "Khaki"                 ,154,130,94
  69. AddColour "Oatmeal"               ,215,200,150
  70. AddColour "Raspberry"             ,155,15,65
  71. AddColour "Mahogany"              ,54,22,0
  72. AddColour "Heather"               ,125,85,105
  73. AddColour "Avocado"               ,198,192,116
  74. AddColour "Pea Green"             ,98,143,57
  75. AddColour "Wine"                  ,122,11,56
  76. AddColour "Watermellon"           ,236,91,89
  77. AddColour "Sand"                  ,177,139,88
  78. AddColour "Candy Pink"            ,255,85,195
  79. AddColour "Chocolate"             ,73,50,34
  80. AddColour "Grape"                 ,140,170,100
  81. AddColour "Flamingo"              ,255,62,138
  82. AddColour "Terracotta"            ,225,115,70
  83. AddColour "Auburn"                ,75,23,9
  84. AddColour "Rose"                  ,229,144,150
  85. AddColour "Mustard"               ,200,180,20
  86. AddColour "Caramel"               ,170,110,0
  87. AddColour "Honey"                 ,235,170,46
  88. AddColour "Parchment"             ,225,196,149
  89. AddColour "Kiwi"                  ,112,156,45
  90. AddColour "Cucumber"              ,190,210,99
  91. AddColour "Vanilla"               ,249,241,143
  92. AddColour "Almond"                ,187,167,140
  93. AddColour "Clay"                  ,143,131,114
  94. AddColour "Banana"                ,249,242,80
  95. AddColour "Strawberry"            ,255,95,55
  96. AddColour "Spice"                 ,210,80,0
  97. AddColour "Sorbet"                ,185,85,85
  98. AddColour "Cargo"                 ,100,92,73
  99. AddColour "Milkshake"             ,255,155,175
  100. AddColour "Velvet"                ,171,39,78
  101. AddColour "Amaranth"              ,130,45,90
  102. AddColour "Tomato"                ,203,58,19
  103. AddColour "Amethyst"              ,145,85,165
  104. AddColour "Curry"                 ,165,140,20
  105. AddColour "Butter"                ,254,251,174
  106. AddColour "Toffee"                ,165,85,35
  107. AddColour "Burlap"                ,150,110,60
  108. AddColour "Willow"                ,45,190,100
  109. AddColour "Highlight"             ,225,250,40
  110. AddColour "Menthol"               ,145,255,195
  111. AddColour "Lemon Curd"            ,234,222,116
  112. AddColour "Citrus"                ,255,150,0
  113. AddColour "Buttermilk"            ,255,255,214
  114. AddColour "Moss"                  ,75,90,30
  115. AddColour "Basalt"                ,66,66,55
  116. AddColour "Girly Pink"            ,246,146,217
  117. AddColour "Blush"                 ,255,55,55
  118. AddColour "Morocco"               ,180,40,0
  119. AddColour "Glamour Girl"          ,200,0,140
  120. AddColour "Herbal"                ,100,140,100
  121. AddColour "Soft Blue"             ,55,85,175
  122. AddColour "Tiger Lily"            ,231,60,9
  123. AddColour "Brick"                 ,121,47,36
  124. AddColour "White Chocolate"       ,255,255,193
  125. AddColour "Sour Yellow"           ,225,250,80
  126. AddColour "Soft Orange"           ,255,135,65
  127. AddColour "Denim"                 ,135,165,232
  128. AddColour "Deep Pink"             ,200,80,144
  129. AddColour "Vivid Purple"          ,165,5,255
  130. AddColour "Silver Grey"           ,155,155,177
  131. AddColour "Warm Pink"             ,226,90,110
  132. AddColour "Mud"                   ,125,70,25
  133. AddColour "Desert Camo"           ,190,150,80
  134. AddColour "Cheese"                ,236,185,73
  135. AddColour "Grass"                 ,112,149,38
  136. AddColour "Soft Pink"             ,215,105,125
  137. AddColour "Fern"                  ,40,130,0
  138. AddColour "Gloom"                 ,50,70,60
  139. AddColour "Night Blue"            ,65,65,120
  140. AddColour "Sea Storm"             ,60,100,120
  141. AddColour "Slime"                 ,125,195,35
  142. AddColour "Glow Stick"            ,205,250,100
  143. AddColour "Airy Blue"             ,100,130,150
  144. AddColour "Natural Green"         ,104,125,55
  145. AddColour "Sandstone"             ,115,115,70
  146. AddColour "Bright Blue"           ,185,195,255
  147. AddColour "Bright Green"          ,175,255,135
  148. AddColour "Toxic Yellow"          ,155,155,0
  149. AddColour "Toad"                  ,59,62,40
  150. AddColour "Swamp"                 ,43,48,38
  151. AddColour "Neutral Blue"          ,5,65,85
  152. AddColour "Caucasia"              ,215,170,130
  153. AddColour "Homey"                 ,124,77,59
  154. AddColour "Twilight"              ,28,28,44
  155. AddColour "Sycamore"              ,105,90,40
  156. AddColour "Volcanic"              ,44,28,28
  157. AddColour "Fire"                  ,255,90,14
  158. AddColour "Ice"                   ,125,220,255
  159. AddColour "Troll"                 ,28,44,28
  160. AddColour "Poison"                ,125,250,40
  161. AddColour "Dark Aqua"             ,29,104,100
  162. AddColour "Fog"                   ,139,164,140
  163. AddColour "Metalic"               ,153,172,160
  164. AddColour "Mineral"               ,192,192,160
  165. AddColour "White"                 ,255,255,255
  166. AddColour "Light Grey"            ,165,165,165
  167. AddColour "Grey"                  ,122,122,122
  168. AddColour "Dark Grey"             ,65,65,65
  169. AddColour "Charcoal"              ,24,24,24
  170. AddColour "Opaque Black"          ,2,2,2
  171.  
  172. AddColour "Light Blue"            ,115,145,255
  173. AddColour "Light Red"             ,255,35,35
  174. AddColour "Light Yellow"          ,255,225,95
  175. AddColour "Light Green"           ,115,255,85
  176. AddColour "Light Orange"          ,255,171,75
  177. AddColour "Light Brown"           ,125,85,55
  178. AddColour "Light Pink"            ,255,175,205
  179. AddColour "Light Purple"          ,152,70,170
  180.  
  181. AddColour "Dark Blue"             ,35,30,100
  182. AddColour "Dark Red"              ,115,15,15
  183. AddColour "Dark Yellow"           ,155,115,22
  184. AddColour "Dark Green"            ,39,107,19
  185. AddColour "Dark Orange"           ,145,71,17
  186. AddColour "Dark Brown"            ,42,23,17
  187. AddColour "Dark Pink"             ,165,75,99
  188. AddColour "Dark Purple"           ,62,0,50
  189.  
  190. AddColour "Black"                 ,0,0,0
  191. AddColour "System Red"            ,255,0,0
  192. AddColour "System Green"          ,0,255,0
  193. AddColour "System Yellow"         ,255,255,0
  194. AddColour "System Blue"           ,0,0,255
  195. AddColour "System Magenta"        ,255,0,255
  196. AddColour "System Cyan"           ,0,255,255
  197.  
  198.  
  199. If Colour_Demo Then
  200. ofx=18
  201. ofy=15
  202. sp=10
  203. w=133;230
  204. h=20;33
  205. ;Graphics 1280,1024,32,1
  206. Graphics 1024,768,32,2
  207. SetBuffer BackBuffer()
  208. SetFont LoadFont("tahoma",18) ; lucida console 21
  209. ClsColour "khaki"
  210. Repeat
  211. Cls
  212. mmsx=MouseX()
  213. mmsy=MouseY()
  214. mmd2=MouseDown(2)
  215. x=ofx
  216. y=ofy
  217. For c=1 To colours
  218. colour c
  219. If mmd2=0 Then Rect x,y,w,h,1:Colour c,150:Text x+(w/2)-1,y+1+(h/2),colourname(c),1,1:Colour c,160; Color 0,0,0
  220. Rect x,y,w,h,0
  221. Rect x+1,y+1,w-2,h-2,0
  222. If mmd2=0 Then Colour c,390
  223. Text x+(w/2),y+(h/2)-1,colourname(c),1,1
  224.  
  225. If mmsx=>x And mmsy=>y And mmsx=<x+w And mmsy=<y+h Then Rect x,y,w,h,0:If MouseDown(1) Then ClsColor colourr(c),colourg(c),colourb(c)
  226. y=y+h+sp:If y+h>GraphicsHeight() Then y=ofy:x=x+w+sp
  227. Next
  228. Flip
  229. Until KeyHit(1)
  230. End
  231. EndIf
  232.  
  233.  
  234.  
  235. Global maxremcols=100,remcolat=0
  236. Dim remcolr(maxremcols)
  237. Dim remcolg(maxremcols)
  238. Dim remcolb(maxremcols)
  239. Global cremred,cremgreen,cremblue
  240.  
  241.  
  242. Dim alut(600,3)         ;MIXCOLOURS()
  243. Local r                                
  244. For r=1 To 600
  245. c=r
  246. If c>255 c=255
  247. alut(r,1) = (c And 255) Shl 16
  248. alut(r,2) = (c And 255) Shl 8
  249. alut(r,3) = (c And 255)
  250. Next
  251.  
  252.  
  253.  
  254.  
  255. Function RememberColour()
  256. cremred=ColorRed()
  257. cremgreen=ColorGreen()
  258. cremblue=ColorBlue()
  259. If remcolat=maxremcols Then Return
  260. remcolat=remcolat+1
  261. remcolr(remcolat)=cremred
  262. remcolg(remcolat)=cremgreen
  263. remcolb(remcolat)=cremblue
  264. End Function
  265.  
  266. Function RecallColour()
  267. If remcolat=0 Then Color cremred,cremgreen,cremblue:Return
  268. Color remcolr(remcolat),remcolg(remcolat),remcolb(remcolat)
  269. remcolat=remcolat-1
  270. End Function
  271.  
  272.  
  273.  
  274. Function Alpha(hue)
  275. Return (hue And $FF000000) Shr 24
  276. End Function
  277.  
  278. Function Red(hue)
  279. Return (hue And $00FF0000) Shr 16
  280. End Function
  281.  
  282. Function Green(hue)
  283. Return (hue And $0000FF00) Shr 8
  284. End Function
  285.  
  286. Function Blue(hue)
  287. Return (hue And $000000FF)
  288. End Function
  289.  
  290. Function ARGB(A,R,G,B)
  291. Return RGBA(r,g,b,a)
  292. End Function
  293.  
  294. Function RGBA(R,G,B,A=255)
  295. If a<0 Then Return (R*256*256)+(g*256)+b
  296. Return A Shl 24 Or R Shl 16 Or G Shl 8 Or B; Shl 0
  297. End Function
  298.  
  299. Function MixColours(col1,col2,a#)
  300. Local na#,rr1,gg1,bb1,rr2,gg2,bb2
  301. na#=a
  302. a=1-a
  303. rr1=((col1 Shr 16) And 255) *a
  304. gg1=((col1 Shr 8) And 255) *a
  305. bb1=(col1 And 255) *a
  306. rr2=((col2 Shr 16) And 255) *na
  307. gg2=((col2 Shr 8) And 255) *na
  308. bb2=(col2 And 255) *na
  309. Return $ff000000 Or aLut(rr1+rr2,1) Or aLut(gg1+gg2,2) Or aLut(bb1+bb2,3)
  310. End Function
  311.  
  312.  
  313.  
  314. Function AddColour(N$,R,G,B)
  315. If colours=maxcolours Then RuntimeError "Too many colours."
  316. Colours=Colours+1
  317. ColourName$(Colours)=N$
  318. Colourlen(Colours)=Len(N$)
  319. colourr(colours)=r
  320. colourg(colours)=g
  321. colourb(colours)=b
  322. colourRGB(colours)=rgba(r,g,b,255)
  323. End Function
  324.  
  325. Function FindColour(n$)
  326. n=Lower(n):l=Len(n)
  327. For t=1 To colours
  328. If colourlen(t)+l Then If n=Lower(colourname(t)) Then Return t
  329. Next
  330. End Function
  331.  
  332. Function Colour(n$,bri=255) ;bri goes from 0 to 512 ... 255 is normal!
  333. t=Int(n)
  334. If t=0 Then t=findcolour(n)
  335. If bri=255 Then Color colourr(t),colourg(t),colourb(t):Return t
  336. If bri<255 Then Color (colourr(t)*bri)/255,(colourg(t)*bri)/255,(colourb(t)*bri)/255:Return t
  337. If bri>255 Then tw#=bri-255:tw=tw/255:Color cbetween(colourr(t),255,tw#),cbetween(colourg(t),255,tw#),cbetween(colourb(t),255,tw#):Return t
  338. Return t
  339. End Function
  340. Function cBetween#(v1#,v2#,t#):dif#=v2-v1
  341. Return v1+(dif*t)
  342. End Function
  343.  
  344.  
  345.  
  346. Function CLSColour(n$,bri=255) ;bri goes from 0 to 512 ... 255 is normal!
  347. t=Int(n)
  348. If t=0 Then t=FindColour(n)
  349. If bri=255 Then ClsColor colourr(t),colourg(t),colourb(t):Return t
  350. If bri<255 Then ClsColor (colourr(t)*bri)/255,(colourg(t)*bri)/255,(colourb(t)*bri)/255:Return t
  351. If bri>255 Then tw#=bri-255:tw=tw/255:ClsColor cbetween(colourr(t),255,tw#),cbetween(colourg(t),255,tw#),cbetween(colourb(t),255,tw#):Return t
  352. Return t
  353. End Function
  354.  
  355.  
  356.  
  357. Function SetBGColour(col$):bgcolour col:End Function
  358.  
  359. Function BGColour(col$)
  360. If Lower(c)="transparent" Then bgcolr=-1:bgcolb=-1:bgcolg=-1
  361. c=FindColour(col)
  362. BGcolR=colourr(c)
  363. BGcolG=colourg(c)
  364. BGcolB=colourb(c)
  365. End Function
  366.  
  367.  
  368. Function CStringWidth(tx$)
  369. getting=1
  370. For t=1 To Len(tx)
  371. c$=Mid(tx,t,1)
  372. If c="{" Then getting=0
  373. If c="}" Then getting=1:c=""
  374. If getting Then tx2$=tx2+c
  375. Next
  376. Return StringWidth(tx2)
  377. End Function
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387. Function CText(x,y,tx$,cx=0,cy=0)
  388. Local cod$,cod1$,cod2$
  389. rd=ColorRed():gr=ColorGreen():bl=ColorBlue()
  390. rd3=bgcolr:gr3=bgcolg:bl3=bgcolb
  391. If cx Then x=x-(CStringWidth(tx$)/2)
  392. If cy Then y=y-(FontHeight()/2)
  393. getting=1
  394. For t=1 To Len(tx)
  395. c$=Mid(tx,t,1)
  396. If c="{" Then getting=0:c=""
  397.         If c="}" Then
  398.         getting=1
  399.         c="":cod1$="":cod2$=""
  400.         If Len(cod)>4 Then cod1$=Upper(Left(cod,4)):cod2=Right(cod,Len(cod)-4)
  401.         If cod1="COL:" Then Colour cod2
  402.         If cod1="BGC:" Then BGColour cod2
  403.         cod=""
  404.         EndIf
  405. If getting Then
  406. If bgcolr>-1 Or bgcolg>-1 Or bgcolb>-1 Then rd2=ColorRed():gr2=ColorGreen():bl2=ColorBlue():Color bgcolr,bgcolg,bgcolb:Rect x,y,StringWidth(c),FontHeight(),1:Color rd2,gr2,bl2
  407. Text x,y,c:x=x+StringWidth(c)
  408. EndIf
  409. If getting=0 Then cod$=cod+c$
  410. Next
  411. bgcolr=rd3:bgcolg=gr3:bgcolb=bl3
  412. Color rd,gr,bl
  413. End Function


Comments :


Zeke(Posted 1+ years ago)

 Hi, some of your codes are very usefull.. but unfortunately code is to blitz3d..... BUT this is so easy to convert bmax code.. so, Thanks.


_PJ_(Posted 1+ years ago)

 Wow, how long did that take to wriote out all the colours??? :)If it helps, to make it easier to identify some 'common' aRGB Hex values, I made a few of my own. These were specifically for use with the Blitzsys.dll DLLColor... functions:
Code: [Select]
Const COL_WHITE% = 16777215
Const COL_BLACK% = 16777216

Const COL_RED = 255
Const COL_GREEN=65280
Const COL_BLUE=16711680

Const COL_YELLOW= 65535
Const COL_CYAN=16776960
Const COL_MAGENTA=16711935

Const COL_ORANGE=32303
Const COL_EMERALD=65408
Const COL_AMETHYST=16711808
Const COL_SAPPHIRE=16744448
Const COL_RUBY=8388863
Const COL_AQUA=8453888

Const COL_VIOLET=16744576
Const COL_APPLE=8454016
Const COL_STRAWBERRY=8421631
Const COL_BANANA=8454143
Const COL_PINK=16744703
Const COL_ICE=16777088

Const COL_FLESH=8438015
Const COL_GOLD=49407

Const COL_LEAF=32768
Const COL_BERRY=128

Const COL_BLOOD=63
Const COL_CERULEAN=12615680
Const COL_WOOD=12615680

Const COL_CHARCOAL=4144959
Const COL_LEAD=8421504
Const COL_STEEL=10526880
Const COL_SILVER=12632256



Bobysait(Posted 1+ years ago)

 nice stuff !a litle improvment for the demo-> use an image to grab colours, so we don't draw rects every frame
Code: [Select]
If Colour_Demo Then
ofx=18
ofy=15
sp=10
w=133
h=20
Graphics 1024,768,0,2
SetBuffer BackBuffer()
SetFont LoadFont("tahoma",18) ; lucida console 21

; draw colours to an image
Local ColoursImg = CreateImage(1024,768)
CLSColour "black"
SetBuffer ImageBuffer(ColoursImg)
x=ofx
y=ofy
For c=1 To Colours
Colour c
Rect x,y,w,h,1:Colour c,150:Text x+(w/2)-1,y+1+(h/2),ColourName(c),1,1:Colour c,160
Rect x,y,w,h,0
Rect x+1,y+1,w-2,h-2,0
Colour c,390
Text x+(w/2),y+(h/2)-1,ColourName(c),1,1
y=y+h+sp:If y+h>GraphicsHeight() Then y=ofy:x=x+w+sp
Next
SetBuffer BackBuffer()

CLSColour "khaki"
Repeat
Cls
DrawImage ColoursImg,0,0
mmsx=MouseX()
mmsy=MouseY()
mmd2=MouseDown(2)
x=ofx
y=ofy
For c=1 To Colours
If RectsOverlap(x,y,w,h,mmsx,mmsy,1,1) Then Colour c,390:Rect x,y,w,h,0:If MouseDown(1) Then CLSColour ColourName(c);ClsColor ColourR(c),ColourG(c),ColourB(c)
y=y+h+sp:If y+h>GraphicsHeight() Then y=ofy:x=x+w+sp
Next
Flip
Until KeyHit(1)
FreeImage ColoursImg
End
EndIf



Jesse(Posted 1+ years ago)

 I did something similar to what you did but for Bmax. I got all of the valid html colors and converted the to an object:
Code: [Select]
Type Tcolor
Field _Red :Int
Field _Green :Int
Field _Blue :Int
Field _Alph :Float

Const INDIANRED:Int =0
Const LIGHTCORAL:Int =1
Const SALMON:Int =2
Const DARKSALMON:Int =3
Const CRIMSON:Int =5
Const Red:Int =6
Const FIREBRICK:Int =7
Const DARKRED:Int =8

'Pink colors

Const PINK:Int =10
Const LIGHTPINK:Int =11
Const HOTPINK:Int =12
Const DEEPPINK:Int =13
Const MEDIUMVIOLETRED:Int =14
Const PALEVIOLETRED:Int =15

'Orange colors

Const LIGHTSALMON:Int =17
Const CORAL:Int =18
Const TOMATO:Int =19
Const ORANGERED:Int =20
Const DARKORANGE:Int =21
Const ORANGE:Int =22

'Yellow colors

Const GOLD:Int =24
Const YELLOW:Int =25
Const LIGHTYELLOW:Int =26
Const LEMONCHIFFON:Int =27
Const LIGHTGOLDENRODYELLOW:Int =28
Const PAPAYAWHIP:Int =29
Const MOCCASIN:Int =30
Const PEACHPUFF:Int =31
Const PALEGOLDENROD:Int =32
Const KHAKI:Int =33
Const DARKKHAKI:Int =34

'Purple colors

Const LAVENDER:Int =36
Const THISTLE:Int =37
Const PLUM:Int =38
Const VIOLET:Int =39
Const ORCHID:Int =40
Const FUCHSIA:Int =41
Const MAGENTA:Int =42
Const MEDIUMORCHID:Int =43
Const MEDIUMPURPLE:Int =44
Const AMETHYST:Int =45
Const BLUEVIOLET:Int =46
Const DARKVIOLET:Int =47
Const DARKORCHID:Int =48
Const DARKMAGENTA:Int =49
Const PURPLE:Int =50
Const INDIGO:Int =51
Const SLATEBLUE:Int =52
Const DARKSLATEBLUE:Int =53

'Green colors

Const GREENYELLOW:Int =56
Const CHARTREUSE:Int =57
Const LAWNGREEN:Int =58
Const LIME:Int =59
Const LIMEGREEN:Int =60
Const PALEGREEN:Int =61
Const LIGHTGREEN:Int =62
Const MEDIUMSPRINGGREEN:Int =63
Const SPRINGGREEN:Int =64
Const MEDIUMSEAGREEN:Int =65
Const SEAGREEN:Int =66
Const FORESTGREEN:Int =67
Const Green:Int =68
Const DARKGREEN:Int =69
Const YELLOWGREEN:Int =70
Const OLIVEDRAB:Int =71
Const OLIVE:Int =72
Const DARKOLIVEGREEN:Int =73
Const MEDIUMAQUAMARINE:Int =74
Const DARKSEAGREEN:Int =75
Const LIGHTSEAGREEN:Int =76
Const DARKCYAN:Int =77
Const TEAL:Int =78

'Blue colors

Const AQUA:Int =80
Const CYAN:Int =81
Const LIGHTCYAN:Int =82
Const PALETURQUOISE:Int =83
Const AQUAMARINE:Int =84
Const TURQUOISE:Int =85
Const MEDIUMTURQUOISE:Int =86
Const DARKTURQUOISE:Int =87
Const CADETBLUE:Int =88
Const STEELBLUE:Int =89
Const LIGHTSTEELBLUE:Int =90
Const POWDERBLUE:Int =91
Const LIGHTBLUE:Int =92
Const SKYBLUE:Int =93
Const LIGHTSKYBLUE:Int =94
Const DEEPSKYBLUE:Int =95
Const DODGERBLUE:Int =96
Const CORNFLOWERBLUE:Int =97
Const MEDIUMSLATEBLUE:Int =98
Const ROYALBLUE:Int =99
Const Blue:Int =100
Const MEDIUMBLUE:Int =101
Const DARKBLUE:Int =102
Const NAVY:Int =103
Const MIDNIGHTBLUE:Int =104

'Brown colors

Const CORNSILK:Int =106
Const BLANCHEDALMOND:Int =107
Const BISQUE:Int =108
Const NAVAJOWHITE:Int =109
Const WHEAT:Int =110
Const BURLYWOOD:Int =111
Const _TAN:Int =112
Const ROSYBROWN:Int =113
Const SANDYBROWN:Int =114
Const GOLDENROD:Int =115
Const DARKGOLDENROD:Int =116
Const PERU:Int =117
Const CHOCOLATE:Int =118
Const SADDLEBROWN:Int =119
Const SIENNA:Int =120
Const BROWN:Int =121
Const MAROON:Int =122

'White colors

Const WHITE:Int =124
Const SNOW:Int =125
Const HONEYDEW:Int =126
Const MINTCREAM:Int =127
Const AZURE:Int =128
Const ALICEBLUE:Int =129
Const GHOSTWHITE:Int =130
Const WHITESMOKE:Int =131
Const SEASHELL:Int =132
Const BEIGE:Int =133
Const OLDLACE:Int =134
Const FLORALWHITE:Int =135
Const IVORY:Int =136
Const ANTIQUEWHITE:Int =137
Const LINEN:Int =138
Const LAVENDERBLUSH:Int =139
Const MISTYROSE:Int =140

'Grey colors

Const GAINSBORO:Int =142
Const LIGHTGREY:Int =143
Const SILVER:Int =144
Const DARKGRAY:Int =145
Const GRAY:Int =146
Const DIMGRAY:Int =147
Const LIGHTSLATEGRAY:Int =148
Const SLATEGRAY:Int =149
Const DARKSLATEGRAY:Int =150
Const BLACK:Int =151

Function Create:Tcolor(r:Int,g:Int,b:Int,A:Int = 255)
Local c:Tcolor = New Tcolor
c._Red = r
c._Green = g
c._Blue = b
c._alph = a
Return c
End Function

Method init(r:Int,g:Int,b:Int,a:Int = 1.0)
_red = r
_green = b
_blue = b
_alph = a
End Method

Method set()
SetAlpha _alph
SetColor _Red,_Green,_Blue
End Method

Method get()
_alph = GetAlpha()
GetColor _Red,_Green,_Blue
End Method

Function change(c:Int)
Select c
Case INDIANRED
SetColor 205, 92, 92
Case LIGHTCORAL
SetColor 240, 128, 128
Case SALMON
SetColor 250, 128, 114
Case DARKSALMON
SetColor 233, 150, 122
Case LIGHTSALMON
SetColor 255, 160, 122
Case CRIMSON
SetColor 220, 20, 60
Case Red
SetColor 255, 0, 0
Case FIREBRICK
SetColor 178, 34, 34
Case DARKRED
SetColor 139, 0, 0
'Pink colors
Case PINK
SetColor 255, 192, 203
Case LIGHTPINK
SetColor 255, 182, 193
Case HOTPINK
SetColor 255, 105, 180
Case DEEPPINK
SetColor 255, 20, 147
Case MEDIUMVIOLETRED
SetColor 199, 21, 133
Case PALEVIOLETRED
SetColor 219, 112, 147
'Orange colors
Case LIGHTSALMON
SetColor 255, 160, 122
Case CORAL
SetColor 255, 127, 80
Case TOMATO
SetColor 255, 99, 71
Case ORANGERED
SetColor 255, 69, 0
Case DARKORANGE
SetColor 255, 140, 0
Case ORANGE
SetColor 255, 165, 0
'Yellow colors
Case GOLD
SetColor 255, 215, 0
Case YELLOW
SetColor 255, 255, 0
Case LIGHTYELLOW
SetColor 255, 255, 224
Case LEMONCHIFFON
SetColor 255, 250, 205
Case LIGHTGOLDENRODYELLOW
SetColor 250, 250, 210
Case PAPAYAWHIP
SetColor 255, 239, 213
Case MOCCASIN
SetColor 255, 228, 181
Case PEACHPUFF
SetColor 255, 218, 185
Case PALEGOLDENROD
SetColor 238, 232, 170
Case KHAKI
SetColor 240, 230, 140
Case DARKKHAKI
SetColor 189, 183, 107
'Purple colors
Case LAVENDER
SetColor 230, 230, 250
Case THISTLE
SetColor 216, 191, 216
Case PLUM
SetColor 221, 160, 221
Case VIOLET
SetColor 238, 130, 238
Case ORCHID
SetColor 218, 112, 214
Case FUCHSIA
SetColor 255, 0, 255
Case MAGENTA
SetColor 255, 0, 255
Case MEDIUMORCHID
SetColor 186, 85, 211
Case MEDIUMPURPLE
SetColor 147, 112, 219
Case AMETHYST
SetColor 153, 102, 204
Case BLUEVIOLET
SetColor 138, 43, 226
Case DARKVIOLET
SetColor 148, 0, 211
Case DARKORCHID
SetColor 153, 50, 204
Case DARKMAGENTA
SetColor 139, 0, 139
Case PURPLE
SetColor 128, 0, 128
Case INDIGO
SetColor 75, 0, 130
Case SLATEBLUE
SetColor 106, 90, 205
Case DARKSLATEBLUE
SetColor 72, 61, 139
Case MEDIUMSLATEBLUE
SetColor 123, 104, 238
'Green colors
Case GREENYELLOW
SetColor 173, 255, 47
Case CHARTREUSE
SetColor 127, 255, 0
Case LAWNGREEN
SetColor 124, 252, 0
Case LIME
SetColor 0, 255, 0
Case LIMEGREEN
SetColor 50, 205, 50
Case PALEGREEN
SetColor 152, 251, 152
Case LIGHTGREEN
SetColor 144, 238, 144
Case MEDIUMSPRINGGREEN
SetColor 0, 250, 154
Case SPRINGGREEN
SetColor 0, 255, 127
Case MEDIUMSEAGREEN
SetColor 60, 179, 113
Case SEAGREEN
SetColor 46, 139, 87
Case FORESTGREEN
SetColor 34, 139, 34
Case Green
SetColor 0, 128, 0
Case DARKGREEN
SetColor 0, 100, 0
Case YELLOWGREEN
SetColor 154, 205, 50
Case OLIVEDRAB
SetColor 107, 142, 35
Case OLIVE
SetColor 128, 128, 0
Case DARKOLIVEGREEN
SetColor 85, 107, 47
Case MEDIUMAQUAMARINE
SetColor 102, 205, 170
Case DARKSEAGREEN
SetColor 143, 188, 143
Case LIGHTSEAGREEN
SetColor 32, 178, 170
Case DARKCYAN
SetColor 0, 139, 139
Case TEAL
SetColor 0, 128, 128
'Blue colors
Case AQUA
SetColor 0, 255, 255
Case CYAN
SetColor 0, 255, 255
Case LIGHTCYAN
SetColor 224, 255, 255
Case PALETURQUOISE
SetColor 175, 238, 238
Case AQUAMARINE
SetColor 127, 255, 212
Case TURQUOISE
SetColor 64, 224, 208
Case MEDIUMTURQUOISE
SetColor 72, 209, 204
Case DARKTURQUOISE
SetColor 0, 206, 209
Case CADETBLUE
SetColor 95, 158, 160
Case STEELBLUE
SetColor 70, 130, 180
Case LIGHTSTEELBLUE
SetColor 176, 196, 222
Case POWDERBLUE
SetColor 176, 224, 230
Case LIGHTBLUE
SetColor 173, 216, 230
Case SKYBLUE
SetColor 135, 206, 235
Case LIGHTSKYBLUE
SetColor 135, 206, 250
Case DEEPSKYBLUE
SetColor 0, 191, 255
Case DODGERBLUE
SetColor 30, 144, 255
Case CORNFLOWERBLUE
SetColor 100, 149, 237
Case MEDIUMSLATEBLUE
SetColor 123, 104, 238
Case ROYALBLUE
SetColor 65, 105, 225
Case Blue
SetColor 0, 0, 255
Case MEDIUMBLUE
SetColor 0, 0, 205
Case DARKBLUE
SetColor 0, 0, 139
Case NAVY
SetColor 0, 0, 128
Case MIDNIGHTBLUE
SetColor 25, 25, 112
'Brown colors
Case CORNSILK
SetColor 255, 248, 220
Case BLANCHEDALMOND
SetColor 255, 235, 205
Case BISQUE
SetColor 255, 228, 196
Case NAVAJOWHITE
SetColor 255, 222, 173
Case WHEAT
SetColor 245, 222, 179
Case BURLYWOOD
SetColor 222, 184, 135
Case _TAN
SetColor 210, 180, 140
Case ROSYBROWN
SetColor 188, 143, 143
Case SANDYBROWN
SetColor 244, 164, 96
Case GOLDENROD
SetColor 218, 165, 32
Case DARKGOLDENROD
SetColor 184, 134, 11
Case PERU
SetColor 205, 133, 63
Case CHOCOLATE
SetColor 210, 105, 30
Case SADDLEBROWN
SetColor 139, 69, 19
Case SIENNA
SetColor 160, 82, 45
Case BROWN
SetColor 165, 42, 42
Case MAROON
SetColor 128, 0, 0
'White colors
Case WHITE
SetColor 255, 255, 255
Case SNOW
SetColor 255, 250, 250
Case HONEYDEW
SetColor 240, 255, 240
Case MINTCREAM
SetColor 245, 255, 250
Case AZURE
SetColor 240, 255, 255
Case ALICEBLUE
SetColor 240, 248, 255
Case GHOSTWHITE
SetColor 248, 248, 255
Case WHITESMOKE
SetColor 245, 245, 245
Case SEASHELL
SetColor 255, 245, 238
Case BEIGE
SetColor 245, 245, 220
Case OLDLACE
SetColor 253, 245, 230
Case FLORALWHITE
SetColor 255, 250, 240
Case IVORY
SetColor 255, 255, 240
Case ANTIQUEWHITE
SetColor 250, 235, 215
Case LINEN
SetColor 250, 240, 230
Case LAVENDERBLUSH
SetColor 255, 240, 245
Case MISTYROSE
SetColor 255, 228, 225
'Grey colors
Case GAINSBORO
SetColor 220, 220, 220
Case LIGHTGREY
SetColor 211, 211, 211
Case SILVER
SetColor 192, 192, 192
Case DARKGRAY
SetColor 169, 169, 169
Case GRAY
SetColor 128, 128, 128
Case DIMGRAY
SetColor 105, 105, 105
Case LIGHTSLATEGRAY
SetColor 119, 136, 153
Case SLATEGRAY
SetColor 112, 128, 144
Case DARKSLATEGRAY
SetColor 47, 79, 79
Case BLACK
SetColor 0, 0, 0
End Select
End Function
End Type



Streaksy(Posted 1+ years ago)

 Bobysait: Yeah I could have done that but have you seen what happens when you left + right click on a colour? ;DJesse: Thats cool but I put all the colour codes in an array because I might want to call upon the colours in a way other than simply changing setting the current drawing colour.  But yeh it's handy isn't it ;D


Bobysait(Posted 1+ years ago)

 I had not tested the Right click :) very usefull ^^so let'go for a 2-frame image  ^^
Code: [Select]
If Colour_Demo Then
ofx=18
ofy=15
sp=10
w=133
h=20
Graphics 1024,768,0,2
SetBuffer BackBuffer()
SetFont LoadFont("tahoma",18) ; lucida console 21

; draw colours to an image
Local ColoursImg = CreateImage(1024,768,2)
CLSColour "black"
For frame = 0 To 1
SetBuffer ImageBuffer(ColoursImg,frame)
x=ofx
y=ofy
For c=1 To Colours
Colour c
If frame=0 Then Rect x,y,w,h,1:Colour c,150:Text x+(w/2)-1,y+1+(h/2),ColourName(c),1,1:Colour c,160
Rect x,y,w,h,0
Rect x+1,y+1,w-2,h-2,0
If frame=0 Then Colour c,390
Text x+(w/2),y+(h/2)-1,ColourName(c),1,1
y=y+h+sp:If y+h>GraphicsHeight() Then y=ofy:x=x+w+sp
Next
Next
SetBuffer BackBuffer()

frame=0
CLSColour "khaki"
Repeat
Cls
mmsx=MouseX()
mmsy=MouseY()
mmd2=MouseDown(2)
x=ofx
y=ofy
DrawImage ColoursImg,0,0,mmd2
For c=1 To Colours
If RectsOverlap(x,y,w,h,mmsx,mmsy,1,1)
Colour c,390:Rect x,y,w,h,0 : If MouseDown(1) Then CLSColour ColourName(c)
Exit ; exit if mouseover
EndIf
y=y+h+sp:If y+h>GraphicsHeight() Then y=ofy:x=x+w+sp
Next
Flip
Until KeyHit(1)
FreeImage ColoursImg
End
EndIf
@Jesse : Maybe a [ codebox ] [ /codebox ] is more discret ...


Jesse(Posted 1+ years ago)

 Treaksy, I wasn't trying to show it of as being a better example but that maybe it would help with color declarations for others and maybe even combine both to make it more complete. yours do have several advantages.@bobysait, I know what you mean. I was just trying to, irresponsibly, show it off.fixed now


Streaksy(Posted 1+ years ago)

 Not showing off either :P  Just explain why it is how it is


Bobysait(Posted 1+ years ago)

 just a small joke for Streaksy :on your keyboard,  you'll fine a smart key with 2 arrows ( one going left, one going right )you could use it to indent a bit your code :P


Streaksy(Posted 1+ years ago)

 funny thing is i actually have my own style of indentation.  when i see indented code it seems all spread out to me.. i like sections of code all clustered together.  just suits the way i think of it.  when i see something good in the code archives and use it i actually, in most cases, remove all the indentation.  just a foible :P


Subirenihil(Posted 1+ years ago)

 @MaliceUsing hexidecimal notation for your color constants would be much easier to read and edit (as long as you understand hex).
Code: [Select]
;For example, when dealing with colors:
Const COL_ICE = $00FFFF80
;is easier to interpret than
Const COL_ICE = 16777088
;Just remember that it goes Alpha (when used for textures), Blue, Green, Red.  2 Hex digits per component.


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal