Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
b+ Beginners Corner
#61
BTW the above code is in preparation for building a Smarter Snake I intend on challenging you guys (any gals left?) later on like at last forum. Remember Ashish? he was only one to take on the challenge back then and look where he is now!

Where IS he NOW BTW? :-))
b = b + ...
Reply
#62
yeee where is @mnr At
Reply
#63
How about BestOfQBasic? Smile
b = b + ...
Reply
#64
When Pete dug up this code for Boxing Accident
https://qb64phoenix.com/forum/showthread.php?tid=409
to tell his clever joke, I was looking over code and thought immediately of this button coloring mod.

Color Transition Button

draws fake 3d button that colors from one hue around outside to another hue at middle

Code: (Select All)
_Title "Color transition button test" 'b+ 2024-07-03
Screen _NewImage(800, 600, 32)
_PrintMode _KeepBackground
btn 10, 10, 210, 60, &HFF002200, &HFF8888FF, "Testing 1,2,3..."
btn 210, 100, 410, 150, &HFF330000, &HFFFFFF00, "Testing 1,2,3..."
' button assumed wider than tall
Sub btn (x1, y1, x2, y2, c1 As _Unsigned Long, c2 As _Unsigned Long, text$)
    cAnalysis c1, r1, g1, b1, a
    cAnalysis c2, r2, g2, b2, a
    h2 = (y2 - y1) / 2
    For i = 0 To h2
        Line (x1 + i, y1 + i)-(x2 - i, y2 - i), midInk~&(r1, g1, b1, r2, g2, b2, i / h2), B
    Next
    fc~& = _DefaultColor: bc~& = _BackgroundColor ' save color before we chnge
    Color _RGB32(0, 0, 0)
    _PrintString (x1 + (x2 - x1 - 8 * Len(text$)) / 2 + 2, y1 + (y2 - y1 - 16) / 2 + 2), text$
    Color _RGB32(255, 255, 255)
    _PrintString (x1 + (x2 - x1 - 8 * Len(text$)) / 2, y1 + (y2 - y1 - 16) / 2), text$

    Color fc~&, bc~& ' restore color
End Sub

Function midInk~& (r1%, g1%, b1%, r2%, g2%, b2%, fr##)
    midInk~& = _RGB32(r1% + (r2% - r1%) * fr##, g1% + (g2% - g1%) * fr##, b1% + (b2% - b1%) * fr##)
End Function

Sub cAnalysis (c As _Unsigned Long, outRed, outGrn, outBlu, outAlp)
    outRed = _Red32(c): outGrn = _Green32(c): outBlu = _Blue32(c): outAlp = _Alpha32(c)
End Sub

   

This has a couple of useful routines: midInk~& function to transition from one color to another and
cAnalysis sub to take a color and get the red, green, blue, alpha components out of the color.
b = b + ...
Reply




Users browsing this thread: 1 Guest(s)