.. .. .. ..   ..
BlitzBasic > Codearchiv > GrafikAktuallisiert 30.05.2009

..  Windowsmauszeiger+Schatten - von Codemaster 
Dieser Code kann die Windowsmauszeiger (Hand, Sanduhr, Pfeil) inklusive Schatten darstellen, benötigt dazu aber keine externen Bilder. Sicher nützlich für GUIs.

;** Windowsmauszeiger (sogar mit Schatten), ohne externe Bilder
;** 08.04.2004 by Codemaster

Graphics 800,600,0,1 
SetBuffer BackBuffer() 
HidePointer() 
ClsColor 255,0,255 

Const Cursor_Default = 1 
Const Cursor_Hand = 2 
Const Cursor_Wait = 3 

Global Anim 

Dim UDFColor(2) 
UDFColor(1) = $000000 
UDFColor(2) = $FFFFFF 

While Not KeyDown(1) 
Cls 
DrawBoxes 
AnimateCursor 
If MouseX() < 800 Then Cursor = Cursor_Wait 
If MouseX() < 540 Then Cursor = Cursor_Hand 
If MouseX() < 270 Then Cursor = Cursor_Default 
DrawPointer(MouseX(),MouseY(),Cursor) 
Flip 
Wend 
End 

Function AnimateCursor(r1=255,g1=255,b1=255,r2=0,g2=0,b2=0) 
Anim = (Anim + 2) Mod 360 
Anim2# = (Sin(Anim) + 1) / 2 
r = r1 * Anim2 + r2 * (1 - Anim2) 
g = g1 * Anim2 + g2 * (1 - Anim2) 
b = b1 * Anim2 + b2 * (1 - Anim2) 
UDFColor(1) = (255-r) * $10000 + (255-g) * $100 + (255-b) ;<- kann auskommentiert werden! 
UDFColor(2) = r * $10000 + g * $100 + b 
End Function 

Function DrawBoxes() 
Color 255,255,255 
Line 270,0,270,600 
Line 540,0,540,600 
Color 255,0,0 Rect 50,50,50,100 
Color 0,255,0 Rect 100,50,50,100 
Color 0,0,255 Rect 150,50,50,100 
Color 255,255,0 Rect 200,50,50,100 
Color 0,255,255 Rect 250,50,50,100 
Color 0,0,0 Rect 300,50,50,100 
Color 255,255,255 Rect 350,50,50,100 
End Function 

Function DrawPointer(x,y,Cursor=Cursor_Default) 
LockBuffer() 
Select Cursor 
Case Cursor_Hand 
Restore Cursor_Hand 
Case Cursor_Wait 
Restore Cursor_Wait 
Default 
Restore Cursor_Default 
End Select 
Read Width,Height 
Read HotSpotX, HotSpotY 
For y1 = -HotSpotY To -HotSpotY + Height-1 
LCol = 0 
For x1 = -HotSpotX To -HotSpotX + Width-1 
Read Col1 
If (x+x1)>=0 And (y+y1)>=0 And (x+x1) 0 Then LCol = LCol - 1 
EndIf 
If (LCol > 0) And (Col1 = 0) Then 
LCol2 = ReadPixelFast(x+x1,y+y1) 
R = (LCol2 And $FF0000) / $10000 * ((6-LCol) * 8 + 52) / 100 + 10 
G = (LCol2 And $FF00) / $100 * ((6-LCol) * 8 + 52) / 100 + 10 
B = (LCol2 And $FF) * ((6-LCol) * 8 + 52) / 100 + 10 
WritePixelFast x+x1,y+y1,R * $10000 + G * $100 + B 
EndIf 
EndIf 
Next 
Next 
UnlockBuffer() 
End Function 

End 

.Cursor_Default 
Data 15,21,1,1 
Data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0 
Data 1,1,0,0,0,0,0,0,0,0,0,0,0,0,0 
Data 1,2,1,0,0,0,0,0,0,0,0,0,0,0,0 
Data 1,2,2,1,0,0,0,0,0,0,0,0,0,0,0 
Data 1,2,2,2,1,0,0,0,0,0,0,0,0,0,0 
Data 1,2,2,2,2,1,0,0,0,0,0,0,0,0,0 
Data 1,2,2,2,2,2,1,0,0,0,0,0,0,0,0 
Data 1,2,2,2,2,2,2,1,0,0,0,0,0,0,0 
Data 1,2,2,2,2,2,2,2,1,0,0,0,0,0,0 
Data 1,2,2,2,2,2,2,2,2,1,0,0,0,0,0 
Data 1,2,2,2,2,2,2,2,2,2,1,0,0,0,0 
Data 1,2,2,2,2,2,2,1,1,1,1,1,0,0,0 
Data 1,2,2,2,1,2,2,1,0,0,0,0,0,0,0 
Data 1,2,2,1,1,2,2,1,0,0,0,0,0,0,0 
Data 1,2,1,0,0,1,2,2,1,0,0,0,0,0,0 
Data 1,1,0,0,0,1,2,2,1,0,0,0,0,0,0 
Data 1,0,0,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