
; About TNG Requester scholly 08 Version 1.0
; by scholly
; (intern arng_ugs_08.pb)
; WindowsXP(SP2), PB 4.10
;
; Textgadgets + Screen mit Zylinder-Scroller und Scroll-Bouncer
Code: Alles auswählen
; About TNG Requester scholly 08 Version 1.0
; by scholly
; (intern arng_ugs_08.pb)
; WindowsXP(SP2), PB 4.10
;
; Textgadgets + Screen mit Zylinder-Scroller und Scroll-Bouncer
Procedure DrawArcSprite(SpriteID.l, x.l, y.l, Radius.l, RollAngle.d, yHeight.l, ZoomX.d, CountX.l)
; NicTheQuick auf http://www.purebasic.fr/german/viewtopic.php?t=15752&start=20
EnableExplicit
Protected Width.l, Height.l, Measure.d, rWidth.l, Px.l, cos.d, sin.d, a.d, Px3.l
Width = SpriteWidth(SpriteID) ;Breite des Sprites
Height = SpriteHeight(SpriteID) ;Höhe des Sprites
rWidth = Radius * 2 ;Sichtbare Breite
Measure = Radius * 2 * #PI ;Umfang des Zylinders
If CountX > 0
ZoomX = 2 * rWidth / (Width * CountX)
Else
ZoomX = ZoomX * Width / Measure
EndIf
For Px = 0 To rWidth
cos = 2.0 * Px / rWidth - 1.0
sin = Sqr(1 - cos * cos)
a = ATan(sin / cos)
If a <= 0.0 : a + #PI : EndIf
a = #PI - a + RollAngle
Px3 = Int(a * rWidth / (#PI * ZoomX))
If Px3 < 0
Px3 = Width - ((-Px3) % Width) - 1
Else
Px3 = Px3 % Width
EndIf
ClipSprite(SpriteID, Px3, 0, 1, Height)
DisplaySprite(SpriteID, x + Px, y + sin * yHeight)
Next
ClipSprite(SpriteID, #PB_Default, #PB_Default, #PB_Default, #PB_Default)
DisableExplicit
EndProcedure
Procedure MIRRORSPRITE(SPRITEID.l, Direction.l)
; chaoskid auf http://www.purebasic.fr/german/archive/viewtopic.php?t=2636
EnableExplicit
Protected hdc.l, height.l, width.l
hdc = StartDrawing(SpriteOutput(SPRITEID))
Height = SpriteHeight(SPRITEID)
Width = SpriteWidth(SPRITEID)
If Direction
StretchBlt_(hdc, 0, Height, Width, -Height, hdc, 0, 0, Width, Height, #SRCCOPY)
Else
StretchBlt_(hdc, Width, 0, -Width, Height, hdc, 0, 0, Width, Height, #SRCCOPY)
EndIf
StopDrawing()
DisableExplicit
EndProcedure
Procedure ar8()
EnableExplicit
Protected ar8_quit = #False
If InitSprite()=0
MessageRequester("ERROR","ar8: Can't InitSprite() !",#MB_ICONERROR)
End
EndIf
Protected win_Width = 400
Protected win_Height = 440
Protected ar8_win_titel.s = "About-Requester - TNG "
Protected ar8_win_nr = OpenWindow(#PB_Any, 0, 0, win_Width, win_Height, ar8_win_titel ,#PB_Window_ScreenCentered | #PB_Window_SystemMenu)
If ar8_win_nr=0
MessageRequester("ERROR","ar8: Can't open window !",#MB_ICONERROR)
End
EndIf
If CreateGadgetList(WindowID(ar8_win_nr)) = 0
MessageRequester("ERROR","ar8: Can't create Gadgetlist !",#MB_ICONERROR)
CloseWindow(ar8_win_nr)
End
EndIf
Protected tg1 = TextGadget(#PB_Any,0, 5,win_width,20,"PureBoard Requester Suite",#PB_Text_Center)
Protected tg2 = TextGadget(#PB_Any,0,30,win_width,20,"schollys Requester 8 Version 42",#PB_Text_Center)
Protected tg3 = TextGadget(#PB_Any,0,55,win_width,20,"Copyleft März 2008",#PB_Text_Center)
Protected ar8_scr_nr = OpenWindowedScreen(WindowID(ar8_win_nr), 10, 100, win_Width-20, win_Height-110, 0, 0, 0)
If ar8_scr_nr=0
MessageRequester("ERROR","ar8: Can't open ar8-screen !",#MB_ICONERROR)
CloseWindow(ar8_win_nr)
End
EndIf
;Zylinder-Scroller-Daten - Anfang
Protected File.s = #PB_Compiler_Home+"examples\sources\Data\PureBasicLogo.bmp"
Protected sprite_unten = LoadSprite(#PB_Any, File)
If sprite_unten=0
MessageRequester("ERROR","ar8: Can't load sprite_unten !",#MB_ICONERROR)
CloseScreen()
CloseWindow(ar8_win_nr)
End
EndIf
Protected sprite_oben = LoadSprite(#PB_Any, File)
If sprite_oben=0
MessageRequester("ERROR","ar8: Can't load sprite_oben !",#MB_ICONERROR)
FreeSprite(sprite_unten)
CloseScreen()
CloseWindow(ar8_win_nr)
End
EndIf
MIRRORSPRITE(sprite_oben, 0)
Protected Radius = 180 ; Durchmesser verändern
Protected ZoomX.d = 1 ; Breite des Logos
Protected CountX = 4 ; Anzahl der Logos hintereinander
Protected y_Height_unten = Radius / 1.5 ; Ausbuchtungshöhe nach unten, Negativ nach oben, Radius+1 = grade
Protected y_Height_oben = Radius /-1.5 ; Ausbuchtungshöhe nach unten, Negativ nach oben, Radius+1 = grade
Protected y_offset = 130
Protected x_offset = 10
Protected Rolloben.d = 0.0
Protected Rollunten.d = 0.0
;Zylinder-Scroller-Daten - Ende
;Bouncer -Anfang
Protected bnctxt.s = " all coded with "
Protected bncfont_id = LoadFont(#PB_Any,"Arial", 16,#PB_Font_Bold)
;nun brauchen wir die Pixellänge des einfachen scrolltextes
StartDrawing(WindowOutput(ar8_win_nr))
DrawingFont(FontID(bncfont_id))
Protected bncstr_len = TextWidth(bnctxt)
StopDrawing()
;ist der Scrolltext länger als das Fenster breit, meckern
If bncstr_len > win_width / 3 * 2
MessageRequester("Obacht !!", "ar8: Scrolltext zu lang zum Bouncen")
End
EndIf
Protected bnc_drawoffset_x = win_width - bncstr_len - 40
Protected bnc_drawoffset_y = y_offset+22 ; hier den vertikalen Offset im WindowScreen anpassen
Protected bnc_scrollrichtung.s = "links"
;Bouncer-Daten - Ende
Repeat
ClearScreen(0)
;bouncer
If bnc_scrollrichtung = "links"
bnc_drawoffset_x - 1 ; Scrollgeschwindigkeit nach links einstellen....
If bnc_drawoffset_x < 15
bnc_scrollrichtung = "rechts"
EndIf
ElseIf bnc_scrollrichtung = "rechts"
bnc_drawoffset_x + 1 ; Scrollgeschwindigkeit nach rechts einstellen....
If bnc_drawoffset_x > win_width - 20 - bncstr_len - 15
bnc_scrollrichtung = "links"
EndIf
EndIf
StartDrawing(ScreenOutput())
DrawingFont(FontID(bncfont_id))
DrawText(bnc_drawoffset_x,bnc_drawoffset_y,bnctxt,#White,#Black)
StopDrawing()
;obere Hälfte der Cylinderscrollers
Rolloben - #PI / 180.0 ;scrollt vorwärts (+) oder rückwärts (-) je >Divisor, desto langsam
If Rolloben > 2.0 * #PI : Rolloben - 2.0 * #PI : EndIf
If Rolloben = 0.0 : Rolloben + 2.0 * #PI : EndIf
If Rolloben < 0.0 : Rolloben + 2.0 * #PI : EndIf
DrawArcSprite(sprite_oben, x_offset, y_offset, Radius, Rolloben, y_Height_oben ,ZoomX, CountX)
;untere Hälfte der Cylinderscrollers
Rollunten + #PI / 180.0 ;scrollt vorwärts (+) oder rückwärts (-) je >Divisor, desto langsam
If Rollunten > 2.0 * #PI : Rollunten - 2.0 * #PI : EndIf
If Rollunten = 0.0 : Rollunten + 2.0 * #PI : EndIf
If Rollunten < 0.0 : Rollunten + 2.0 * #PI : EndIf
DrawArcSprite(sprite_unten, x_offset, y_offset, Radius, Rollunten, y_Height_unten ,ZoomX, CountX)
FlipBuffers()
Protected ar8_EventID = WaitWindowEvent(1)
If EventWindow() = ar8_win_nr
If ar8_EventID = #PB_Event_CloseWindow
ar8_quit = #True
FreeSprite(sprite_oben)
FreeSprite(sprite_unten)
CloseScreen()
CloseWindow(ar8_win_nr)
EndIf
EndIf
Until ar8_quit = #True
DisableExplicit
EndProcedure
ar8()
End