StretchText-Function
Übersicht

![]() |
SpionAtomBetreff: StretchText-Function |
![]() Antworten mit Zitat ![]() |
---|---|---|
Hier mal eine Funktion, um Texte mit einem netten Effekt einzublenden
EDIT: Damit das Proggi startet, einmal die Maustaste drücken Code: [AUSKLAPPEN] Const xr=800, yr=600 Graphics xr, yr,16,2 HidePointer Global fontButton = LoadFont("Thorndale",30,1) Global mx, my SetBuffer BackBuffer() WaitMouse() ;Menü einblenden For d = 0 To 25 Viewport 0,0,xr,yr Cls ; drawButton("Hauptmenü",20,20) Viewport 0,yr/2-d,xr,d+d+1 drawButton("P",100,yr/2-15-3) drawButton("L",200,yr/2-15-3) drawButton("Q",300,yr/2-15-3) Rect 0,yr/2-d,xr,1,1 Rect 0,yr/2+d,xr,1,1 Flip() Delay 1 Next Viewport 0,0,xr,yr ;Eingaberoutine loopTimer = CreateTimer(60) endLoop = False Repeat mx = MouseX() my = MouseY() Cls Rect 0,yr/2-25,xr,1,1 Rect 0,yr/2+25,xr,1,1 ; drawButton("Hauptmenü",20,20, False) If drawButton("P",100,yr/2-15-3) Then Color 255,255,255 b1 = stretchText("lay", 100, yr/2+22, b1, 7, 2) Else b1 = 0 End If If drawButton("L",200,yr/2-15-3) Then Color 255,255,255 b2 = stretchText("oad", 200, yr/2+22, b2, 7, 2) Else b2 = 0 End If If drawButton("Q",300,yr/2-15-3) Then Color 255,255,255 b3 = stretchText("uit", 300, yr/2+22, b3, 7, 2) If MouseDown(1) Then endLoop = True Else b3 = 0 End If Color 255, 255, 255 Line mx - 3, my, mx + 3, my Line mx, my - 3, mx, my + 3 Flip(0) WaitTimer(loopTimer) Until KeyDown(1) Or endLoop End() Function drawButton(t$="Buttontext erwartet", xpos=1, ypos=1, clickable = True) SetFont fontButton bxsize = StringWidth(t$)+5 bysize = StringHeight(t$)+5 If Len(t$) = 1 Then If bxsize < bysize Then bxsize = bysize Else bysize = bxsize End If miR = mouseInRect(xpos, ypos, xpos + bxsize, ypos + bysize) Color 150,150,150 Rect xpos+1, ypos, bxsize, 1,1 Rect xpos+1, ypos+bysize+1, bxsize, 1,1 Rect xpos, ypos+1, 1, bysize,1 Rect xpos+bxsize+1, ypos+1, 1, bysize,1 Color 50,50,50 Rect xpos+1,ypos+1,bxsize,bysize,1 If miR And clickable Then Color 255, 255, 0 Else Color 255,255,255 Text xpos+(bxsize-StringWidth(t$))/2+1, ypos+(bysize-StringHeight(t$))/2+1, t$ Return miR End Function Function mouseInRect(x1, y1, x2, y2) If mx < x1 Or mx > x2 Then Return False If my < y1 Or my > y2 Then Return False Return True End Function Function stretchText(t$, x, y, p, s = 1, d = 1) If d = 1 Then one_char_size# = StringWidth("#") / 100.0 tl = Len(t$) For i = 1 To tl Text x + (i-1)*one_char_size# * p, y, Mid$(t$,i,1) Next Else If d = 2 Then one_char_size# = StringHeight(Left$(t$,1)) / 100.0 one_char_size_w# = StringWidth("#") tl = Len(t$) For i = 1 To tl Text x+one_char_size_w#+(one_char_size#-StringWidth(Mid$(t$,i,1)))/2, y + (i-1)*one_char_size# * p, Mid$(t$,i,1) Next End If p = p + s If p > 100 Then p = 100 Return p End Function ![]() |
||
- Zuletzt bearbeitet von SpionAtom am Mo, Sep 19, 2005 11:38, insgesamt einmal bearbeitet
![]() |
Hagbard |
![]() Antworten mit Zitat ![]() |
---|---|---|
Bei mir passiert leider nichts... | ||
Apocalyptic |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Blacky hat Folgendes geschrieben: Bei mir passiert leider nichts...
Code ansehen könnte helfen ![]() BlitzBasic: [AUSKLAPPEN] WaitMouse |
||
Suum cuique
[ www.ffs-net.de.vu ] [ Raycaster ] |
![]() |
Hagbard |
![]() Antworten mit Zitat ![]() |
---|---|---|
Danke,
hab eher an Waitkey gedacht, is aber jetzt auch egal. Ich finde es sieht cool aus. Vielleicht gucke ich mir den Code nochmal genauer an. mfg |
||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group