Page 1 sur 1

je cherche à faire clignoter un texte ,

Publié : sam. 17/oct./2015 6:30
par Micheao
BOnjour
je cherche à faire clignoter un texte , j'ai passer beaucoup d'heures à chercher comment faire et aussi sur le forum et j'ai pas trouver

Code : Tout sélectionner

EnableExplicit
InitSprite()
InitMouse()
InitKeyboard()
Enumeration
  #Main_Form
  #Spr_texte
EndEnumeration
Global Event_Window,Font
Font = LoadFont(0, "Balloonist Sf", 50, #PB_Font_Bold ) 
OpenWindow(#Main_Form,0,0,800,600,"Teste de textest",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(#Main_Form),0,0,800,600)
CreateSprite(#Spr_texte,1090,80,#PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(#Spr_texte))
DrawingMode(#PB_2DDrawing_AlphaChannel)
Box(0,0,1090,80,RGBA(0,0,0,0))
DrawingMode(#PB_2DDrawing_AlphaBlend)
DrawingFont(Font)
DrawText(20,10,"Texte qui clignote ",RGBA(255,255,255,255),RGBA(0,0,0,0));
StopDrawing()

Repeat 
Repeat
  Event_Window=WindowEvent()
  Select Event_Window
    Case #PB_Event_CloseWindow
      End
  EndSelect
    Until Event_Window=0
  DisplayTransparentSprite(#Spr_texte,80,250)

 
    FlipBuffers()
      ClearScreen(RGB(0, 0, 0))
  ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)

Re: je cherche à faire clignoter un texte ,

Publié : sam. 17/oct./2015 6:38
par SPH
Le mieux pour toi, pour faire clignoter un texte, c'est d'eteindre et de rallumer continuellement ton moniteur :lol:

Re: je cherche à faire clignoter un texte ,

Publié : sam. 17/oct./2015 6:59
par Demivec

Code : Tout sélectionner

EnableExplicit
InitSprite()
InitMouse()
InitKeyboard()
Enumeration
  #Main_Form
  #Spr_texte
EndEnumeration
Global Event_Window,Font
Font = LoadFont(0, "Balloonist Sf", 50, #PB_Font_Bold ) 
OpenWindow(#Main_Form,0,0,800,600,"Teste de textest",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(#Main_Form),0,0,800,600)

CreateSprite(#Spr_texte,1090,80,#PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(#Spr_texte))
  DrawingMode(#PB_2DDrawing_AlphaChannel)
  Box(0,0,1090,80,RGBA(0,0,0,0))
  DrawingMode(#PB_2DDrawing_AlphaBlend)
  DrawingFont(Font)
  DrawText(20,10,"Texte qui clignote ",RGBA(255,255,255,255),RGBA(0,0,0,0));
StopDrawing()

Define clignoteTexte
AddWindowTimer(#Main_Form, 0, 200)

Repeat 
  Repeat
    Event_Window=WindowEvent()
    Select Event_Window
      Case #PB_Event_Timer
        clignoteTexte ! 1 
      Case #PB_Event_CloseWindow
        End
    EndSelect
  Until Event_Window=0
  
  If clignoteTexte
    DisplayTransparentSprite(#Spr_texte,80,250)
  EndIf
  
  
  
  FlipBuffers()
  ClearScreen(RGB(0, 0, 0))
  ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)

Re: je cherche à faire clignoter un texte ,

Publié : sam. 17/oct./2015 7:07
par microdevweb
Sph la vengeance est un plat qui ce mange froid, mais c'est un forum d'entraide donc voici la solution.

Code : Tout sélectionner

EnableExplicit
InitSprite()
InitMouse()
InitKeyboard()
Enumeration
      #Main_Form
      #Spr_texte
EndEnumeration
Global Event_Window,Font,gTimeElapsed=ElapsedMilliseconds(),TextOn.b=#False
Font = LoadFont(0, "Balloonist Sf", 50, #PB_Font_Bold )
OpenWindow(#Main_Form,0,0,800,600,"Teste de textest",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(#Main_Form),0,0,800,600)
CreateSprite(#Spr_texte,1090,80,#PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(#Spr_texte))
DrawingMode(#PB_2DDrawing_AlphaChannel)
Box(0,0,1090,80,RGBA(0,0,0,0))
DrawingMode(#PB_2DDrawing_AlphaBlend)
DrawingFont(Font)
DrawText(20,10,"Texte qui clignote ",RGBA(255,255,255,255),RGBA(0,0,0,0));
StopDrawing()

Repeat
      Repeat
            Event_Window=WindowEvent()
            Select Event_Window
                  Case #PB_Event_CloseWindow
                        End
            EndSelect
      Until Event_Window=0
      If TextOn
            DisplayTransparentSprite(#Spr_texte,80,250)
      EndIf
      If (ElapsedMilliseconds()-gTimeElapsed)>800
            If TextOn
                  TextOn=#False
            Else
                  TextOn=#True
            EndIf
             gTimeElapsed=ElapsedMilliseconds()
      EndIf
      FlipBuffers()
      ClearScreen(RGB(0, 0, 0))
      ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
Oups javais pas vu que Demivec avait répondu, c'est aussi une solution si du moins tu n'est pas en plein écran

Re: je cherche à faire clignoter un texte ,

Publié : sam. 17/oct./2015 7:52
par Anonyme2
SPH a écrit :Le mieux pour toi, pour faire clignoter un texte, c'est d'eteindre et de rallumer continuellement ton moniteur :lol:

:mrgreen:

Re: je cherche à faire clignoter un texte ,

Publié : sam. 17/oct./2015 8:59
par Micheao
merci Demivec et microdevweb pour votre explication

Sph et denis --> je vous ignore

Re: je cherche à faire clignoter un texte ,

Publié : sam. 17/oct./2015 10:26
par GallyHC
Bonjour,

Perso je pref faire "TextOn = (TextOn + 1) % 2" que de faire un "if" ;p. Question de gout perso.

Code : Tout sélectionner

EnableExplicit
InitSprite()
InitMouse()
InitKeyboard()
Enumeration
      #Main_Form
      #Spr_texte
EndEnumeration
Global Event_Window,Font,gTimeElapsed=ElapsedMilliseconds(),TextOn.b=#False
Font = LoadFont(0, "Balloonist Sf", 50, #PB_Font_Bold )
OpenWindow(#Main_Form,0,0,800,600,"Teste de textest",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(#Main_Form),0,0,800,600)
CreateSprite(#Spr_texte,1090,80,#PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(#Spr_texte))
DrawingMode(#PB_2DDrawing_AlphaChannel)
Box(0,0,1090,80,RGBA(0,0,0,0))
DrawingMode(#PB_2DDrawing_AlphaBlend)
DrawingFont(Font)
DrawText(20,10,"Texte qui clignote ",RGBA(255,255,255,255),RGBA(0,0,0,0));
StopDrawing()

Repeat
      Repeat
            Event_Window=WindowEvent()
            Select Event_Window
                  Case #PB_Event_CloseWindow
                        End
            EndSelect
      Until Event_Window=0
      If TextOn
            DisplayTransparentSprite(#Spr_texte,80,250)
      EndIf
      If (ElapsedMilliseconds() - gTimeElapsed) > 800
        TextOn        = (TextOn + 1) % 2
        gTimeElapsed  = ElapsedMilliseconds()
      EndIf
      FlipBuffers()
      ClearScreen(RGB(0, 0, 0))
      ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
Cordialement,
GallyHC

Re: je cherche à faire clignoter un texte ,

Publié : sam. 17/oct./2015 10:43
par Micheao
Merci GallyHCpour ton conseil

Re: je cherche à faire clignoter un texte ,

Publié : mar. 27/oct./2015 18:17
par Anonyme2
GallyHC a écrit :Bonjour,
Perso je pref faire "TextOn = (TextOn + 1) % 2" que de faire un "if" ;p. Question de gout perso.
Cordialement,
GallyHC
Bonjour GallyHC,

je te propose 2 autres méthodes pour inverser et je te donne le code assembleur qui correspond aux 3 méthodes (32 bits).
Il y en a peut être d'autres.
La 1ere est de loin la plus courte et la plus rapide.
Tu peux l'écrire aussi TextOn ! 1 au lieu de TextOn = TextOn!1

Code : Tout sélectionner

TextOn.l = 0
For i = 1 To 50
   TextOn = TextOn!1
   Debug TextOn   
Next
Debug ""

TextOn.l = 0
For i = 1 To 50
   TextOn = Bool(Not(TextOn))
   Debug TextOn   
Next

Debug ""

TextOn.l = 0
For i = 1 To 50
      TextOn = (TextOn + 1) % 2
   Debug TextOn   
Next
Assembleur

Code : Tout sélectionner

; TextOn = TextOn!1
  MOV    ebx,dword [v_TextOn]
  XOR    ebx,1
  MOV    dword [v_TextOn],ebx
  
  
  
  ; TextOn = Bool(Not(TextOn))
  CMP    dword [v_TextOn],0
  JE     No0
  XOR    eax,eax
  JMP    Ok0
No0:
  MOV    eax,1
Ok0:
_Bool0:
  AND    eax,eax
  JE    .False
  MOV    eax,1
  JMP   .True
.False:
  XOR    eax,eax
.True:
  MOV    dword [v_TextOn],eax
  
  
  ; TextOn = (TextOn + 1) % 2
  MOV    ebx,dword [v_TextOn]
  INC    ebx
  MOV    eax,ebx
  MOV    ecx,2
  CDQ
  IDIV   ecx
  MOV    ebx,edx
  MOV    dword [v_TextOn],ebx

Re: je cherche à faire clignoter un texte ,

Publié : mer. 28/oct./2015 7:36
par Micheao
Merci Denis pour tes Explications

Re: je cherche à faire clignoter un texte ,

Publié : jeu. 29/oct./2015 12:30
par GallyHC
Bonjour,

Merci "Denis" pour ces précisions. Si j'utilise plus "

Code : Tout sélectionner

i = (i + 1) % 2
", car cela me permet par moment (comme pour une compteur de BPM faire avec x valeur(s)). si j'ai 4 valeurs a faire j'ai le code "

Code : Tout sélectionner

i = (i + 1) % 4
", ce qui n'est pas possible avec les deux autres codes.

Mais pour un simple clignotement j'utiliserais la première version a partir de maintenant.

Cordialement,
GallyHC