Post by tenochtitlanuk on Dec 29, 2020 17:17:34 GMT -5
Anatoly and I have been showing JB-ers how to rotate text +-90 degrees by BMP manipulation.
I like to post something graphic and cheerful at this time of year, so here is a demo of how easy it is to rotate by any angle in LB... we all need cheering in this time of COVID.
Take out the delay for a nice visual rush...
nomainwin
global angle
WindowWidth =800
WindowHeight =800
open "test" for graphics_nsb as #mg
#mg "trapclose [quit]"
hw = hwnd( #mg)
calldll #user32, "GetDC", hw as ulong, hdc as ulong
calldll #gdi32, "SetBkMode", hdc as long, 1 As long, result As long
#mg "home ; fill darkblue ; color cyan ; backcolor darkblue"
#mg "fill darkblue ; color cyan ; backcolor darkblue"
weight = 0 ' how much to emphasize /widen the strokes
height = 20 ' how big to make font ?in pixels?
t =500
for angle =0 to 3 *3600 +100 step 100' rotates in degrees/10 about bottom left-hand of character bounding box
height =height *1.01 ' progressively reduce font size
H =int( height)
calldll #gdi32, "CreateFontA",_
H as long, 0 as long,_
angle as long, angle as long,_
weight as long,_
0 as long, 0 as long, 0 as long, 0 as long, 0 as long, 0 as long, 0 as long, 0 as long,_
"Arial" as ptr,_
hfont as ulong
calldll #gdi32, "SelectObject", hdc as ulong, hfont as ulong, oldhfont as ulong
#mg "color "; col$()
#mg "place "; 300 +230 *sinR( t +deg); " "; 500 +230 *cosR( t +deg)
#mg "\. New Year!"
timer 100, [p]
wait
[p]
timer 0
next angle
#mg "getbmp scr 0 0 800 800"
bmpsave "scr", "greetings.bmp"
wait
function col$() ' graduated colour cycling
red =int( 128 +127 *sin( angle /607))
grn =int( 128 +127 *cos( angle /845))
blu =int( 128 +127 *cos( angle /423))
col$ =str$( red) +" " +str$( grn) +" " +str$( blu)
end function
function cosR( t): cosR =cos( t *3.14159265 /180): end function
function sinR( t): sinR =sin( t *3.14159265 /180): end function
[quit]
calldll #user32, "ReleaseDC", hWnd as long, hdc as long, result as long
close #mg
end
PS This version is one of several and is a serendipitous result of a misunderstanding of the call/release! But Hey Ho- result looks good.