CreateGreadientBrush
really a gread...y brush? is it a typo - same in your script? are you sure it is called? Are you using Call_IfExists? or call by function?GetPtr?
I would spell it Gradient. thats the first a saw. the other thing i see, it is doing the gradient somehow but not as intended because you use the wrong type to store colors and positions,
colors as rgb in range of bytes only. the desktops is multiple times that big in pixels
. you need fractures of bytes to display it. trying to store 255 / 1000 in a long integer is like using a grenade to peel off a banana.
try to use NO INTEGERS, exchange LONG and replace it with NUMBER
there is that rect,
width is right - left and
heigth is bottom - top since bottom is the bigger number and we want to have an absolute / positive number not negative.
lets assume an average screen 16:9 or 16:10 or just 4:3 width perhaps 1200 more ore less, height 750 , somewhere a taskbar...its not for being exact but to check in what ranges the numbers are.
loopEnd were 768 maybe. and we can to make it look good go from very bright to very dark in 768 steps
and also you go from orange to blue/ thats 9nce across the spectrum as these are opposing colors, orange i full red, half green, zero blue
start with RGB 255,127,0 and go to purple blue 63, 0, 255
the red will chANGE 192 IN Height STEPS from 255 to 63 that were to subtract 192/Height every iteration, an integer to use here will not word precise enough - thinBasic offers high precision numbers - completely free, you might use these., don't be shy. Really, at no extra cost you get as many Numbers as you need. As you want... grab a few, its always good to have some numbers in storage.
mentioning it:
also the storages must be a numbers where you keep colors ore the amount that schall change with every iteration
so i suggest you look i did not completely fix everything up for yoou to use but i messed it up and captured and abused your
VARIABLES, I GAVE THEM OTHER NAMES and forced them to do something completely different or even commented some of them...
I did not use the provided fat brush nor the bucket to poor the color onto a thin line that has no space to deal with such amounts of paint
' the big brush and a bucket are not tools for me to draw a fine line
' i use like
if that will do?Declare Function FineLine Lib "gdi32.dll" Alias "Rectangle"( byval hDc As Dword, Byval L as Long, ByVal Y as Long, ByVal R as Long Byval H As Long Function tWindow.Gradient() Dim tc1 As tRgb(me.mGradiClrOne) '// tRgb is my UDT. I will show the elements. ' these 2 udts contain colors to start and end? Dim tc2 As tRgb(me.mGradiClrTwo) 'tc1 what is now and tc2 what shall be final? ' clean out a bit here... Dim rct As RECT Win_getclientrect(me.mHandle, rct) ':::::::Dim gBrush As Dword = 0 Dim Me_Hdc As Dword = Win_CreateCompatibleDC(hDc) ' i will draw onto the windows surface... dim lHeight as Long at varptr(rct.nBottom) ' i capture this Dim lRight as Long at Varptr(rct.nRight) ' also my hostage now dim lLeft As Long at Varptr(rct.nLeft) ' got all i need froom this... ' avoid missing pixels at left or right lLeft -= 1 lRight +=2 ' instead of creating additional variables i create shortcuts to the already existing ' Dim hBmp As Dword = Win_CreateCompatibleBitmap(hDc, rct.nRight, rct.nBottom) ' Dim loopEnd As Long = rct.nBottom ' Win_SelectObject(memHdc, hBmp) ' ' For i as Long = 0 to loopEnd - 1 ' Dim tRct As Rect ' Long can not be. The screen might be 750 pixels high. colors are only bytes from 0 to 255 ' but integer can not show nor memorize the result of 255 / 750 ' for a gradient it should be smooth so we must use fractures of bytes. ' Numbers are great and very precise ' haha, i captured them, now they are mine: Dim red as Long = 1 Dim green As Long = 2 Dim blue As Long = 3 number current(3) current()= array assign tc1.red, tc1.green, tc1.blue number change(3) ' what we want minus what we already have is to achieve in the count of lHeight steps change(red) = (tc2.red - current(red) )/ lHeight change(green) = (tc2.green - current(green) /lHeight change(blue) = tc2.blue - current(blue) / lHeight while lHeight ' no need to count for to next if we have the count already in lHeight '//// gBrush = CreateSolidBrush(Rgb(red, green, blue)) //// ' i use a thinpencil instead of Bob Ross' 2-inch-wide-brush :) sendmessage me.handle, %META_SETTEXTCOLOR | %DS_SETFOREGROUND, 0, RGB( current(red), current(green), current(blue) ) ' this to change the current foreground color on a dialog. ' somehow thinBsic did not grab one when the foreground-colors ' were available for anyone and for free. now dialogs in thinbasic wait for the next ' outlet of paint to receive their forecolor adjustment.. ' does not know %Meta_SetTextColor? = 0x0200 ' | %DS_SetForeGround? = 0x0209 ' ----------------------------------- ' ... use this as message: 0x0409 ' ======== if FineLine( Me_hDC, lLeft, lHeight, lRight, lHeight ) then nop ' now add what is needed per step to reach the destination Color current(red) += change(red) current(green) += change(green) current(blue) += change(blue) decr lHeight ' 1 step less to go wend end function
Bookmarks