11-25-2022, 11:31 AM
Now one thing that I think we're all happy about (or at least I'm happy about it), was the addition of all the color names to QB64. Personally, I find it quite nice to be able to do things like Color Red, Blue and such. My one personal gripe, however, is that it's impossible to remember all the color names and what they actually look like. Do I want Wheat, or Peach, or GoldenRod? Is it LightGray, or LightGrey? Uggh! If I just had a handy little tool to help me quickly find and make use of these colors!!
And, lo and behold, now I do!
Compile and run. Use arrow keys to change colors one color at a time, or A - Z keys to jump to that corresponding point in the color name index. Hit ENTER to select several colors that you like, and ESC to exit the program.
The program saves your selected color names and values to the clipboard, and you can simply post them into your program wherever you desire afterwards. (CTRL-V is shortcut key to post into the IDE.)
Makes for a quick little tool to help you remember what the names are, how to actually spell them, and maybe add a little bit more of the rainbow into your programs.
Example colors quickly copied:
And, lo and behold, now I do!
Code: (Select All)
Screen _NewImage(800, 600, 32)
$Color:32
Do
GetColor cn$, cv&&
Color cv&&
Print cn$, cv&&, _Red32(cv&&), _Green32(cv&&), _Blue32(cv&&)
Loop
Sub GetColor (KolorName$, KolorValue&&)
Static clip$
file$ = ".\internal\support\color\color32.bi"
If _FileExists(file$) = 0 Then Exit Sub 'bad path, bad file... some glitch... we can't work
Open file$ For Binary As #1
ReDim Kolor(1000) As String
ReDim Value(1000) As _Integer64
Dim Alphabet(25) As Integer
Do Until EOF(1)
Line Input #1, text$
If UCase$(Left$(text$, 5)) = "CONST" Then
count = count + 1
text$ = Mid$(text$, 7) 'strip off the CONST and space
l = InStr(text$, "=")
Kolor(count) = Left$(text$, l - 4)
Value(count) = Val(Mid$(text$, l + 2))
If Alphabet(Asc(Kolor(count), 1) - 65) = 0 Then Alphabet(Asc(Kolor(count), 1) - 65) = count
End If
Loop
Close
ReDim _Preserve Kolor(count) As String
ReDim _Preserve Value(count) As _Integer64
w = _Width: h = _Height
xPos = (w - 320) \ 2: yPos = (h - 240) \ 2
PCopy 0, 1
selected = 1
Do
Line (xPos, yPos)-Step(320, 240), LightGray, BF
fPosx = (w - _PrintWidth(Kolor(selected))) \ 2
_PrintString (fPosx, yPos + 5), Kolor(selected)
Line (xPos + 30, yPos + 30)-Step(260, 180), Value(selected), BF
Line (xPos + 30, yPos + 30)-Step(260, 180), Black, B
k = _KeyHit
z = k And Not 32
Select Case z
Case 18432: selected = selected - 1: If selected < 1 Then selected = count
Case 20480: selected = selected + 1: If selected > count Then selected = 1
Case 13: KolorName$ = Kolor(selected): KolorValue&& = Value(selected)
Case 65 To 90:
If Alphabet(z - 65) Then selected = Alphabet(z - 65)
If z = 81 Then selected = Alphabet(82 - 65) 'there is no Q colors, so show R
If z = 90 Then selected = count 'there is no Z colors, so last one
End Select
_Display
Loop Until k = 13 Or k = 27
_AutoDisplay
PCopy 1, 0
If k = 27 Then _Clipboard$ = clip$: System
clip$ = clip$ + KolorName$ + "~& =" + Str$(KolorValue&&) + Chr$(13)
End Sub
Compile and run. Use arrow keys to change colors one color at a time, or A - Z keys to jump to that corresponding point in the color name index. Hit ENTER to select several colors that you like, and ESC to exit the program.
The program saves your selected color names and values to the clipboard, and you can simply post them into your program wherever you desire afterwards. (CTRL-V is shortcut key to post into the IDE.)
Makes for a quick little tool to help you remember what the names are, how to actually spell them, and maybe add a little bit more of the rainbow into your programs.
Example colors quickly copied:
Code: (Select All)
AntiqueBrass~& = 4291663221
CrayolaGold~& = 4293379735
Gold~& = 4294956800