Figures d'attente (2)

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
Avatar de l’utilisateur
MLD
Messages : 1103
Inscription : jeu. 05/févr./2009 17:58
Localisation : Bretagne

Figures d'attente (2)

Message par MLD »

Bonjour a tous
Pour ceux que sa intéresse, j'ai refait quelques figures d'attente (simple)

Code : Tout sélectionner

;appli MLD Figures d'attente
;Niveau de difficulté : *
;19/03/2017
Enumeration Window
  #mainForm
EndEnumeration

Enumeration Gadget
  #Canvas = 1 
  #canvas2 = 2
  #canvas3 = 3
  #canvas4 = 4
  #canvas5 = 5
  #canvas6 = 6
EndEnumeration

;Centre X et Y d'un cercle
Global CX = 30
Global CY = 30
;Rayon du cercle
Global cercleR = 26
Global Radius.i = 25
Global Maxangle 
Global Maxangle2
Global Maxangle3

Global Police = LoadFont(20, "Tahoma", 60)

Declare Start()
Declare Draw()
Declare Draw2()
Declare Draw3()
Declare Draw4()
Declare Draw5()
Declare Draw6()
Declare fondcanvas(canvasnum)
Declare Exit()

Start()

Procedure Start()
  OpenWindow(#mainForm, 0, 0, 300, 240, "figures d'attente", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  SetWindowColor(0,$96BACD) 
  CanvasGadget(1, 10, 10, 60, 60)
  fondcanvas(1)
  CanvasGadget(#Canvas2, 10, 80, 60, 60)
  fondcanvas(2)
  CanvasGadget(#Canvas3, 10, 150, 60, 60)
  fondcanvas(3) 
  CanvasGadget(#Canvas4, 160,10,60,60)
  CanvasGadget(#Canvas5, 160,70,120,60)
  CanvasGadget(#Canvas6, 160,140,120,60)
  AddWindowTimer(0, 1, 40)
  BindEvent(#PB_Event_Timer,@Draw())
  BindEvent(#PB_Event_Timer,@Draw2())
  BindEvent(#PB_Event_Timer,@Draw3())
  BindEvent(#PB_Event_Timer,@Draw4())
  BindEvent(#PB_Event_Timer,@Draw5())
  BindEvent(#PB_Event_Timer,@Draw6())
  BindEvent(#PB_Event_CloseWindow, @Exit())
  Repeat : WaitWindowEvent() : ForEver
EndProcedure

Procedure fondcanvas(canvasnum)
  Select canvasnum
      Case 1,2,3,4
        StartDrawing(CanvasOutput(canvasnum))
         Box(0,0,60,60,GetWindowColor(0))
        StopDrawing()
      Case 5,6
        StartDrawing(CanvasOutput(canvasnum))
         Box(0,0,120,600,GetWindowColor(0))
        StopDrawing()
  EndSelect       
EndProcedure  

Procedure Draw()
  Static Angle    ;Angle variant de 0 à 360 Degrés
  Protected X, Y  ;Coordonnées X, Y du point circulant sur le cercle
  maxangle = maxangle + 20
  If maxangle >360 :maxangle = 0:EndIf
  StartDrawing(CanvasOutput(#Canvas))
  ;L'angle varie de 0 à 360 Degrés incrémenté 
   For Angle = 0 To maxangle Step 30
   ;Dessin du cercle
    DrawingMode(#PB_2DDrawing_Default)
   ;Nouvelles coordonnées X & Y du point
    X = CX + Radius * Cos(Angle * #PI / 180)
    X2 = CX + Radius * Cos((Angle-30) * #PI / 180)
    X3 = CX + Radius * Cos((Angle-180) * #PI / 180)
    X4 = CX + Radius * Cos((Angle-210) * #PI / 180)
    Y = CY + Radius * Sin(Angle * #PI / 180)
    Y2 = CY + Radius * Sin((Angle-30) * #PI / 180)
    Y3 = CY + Radius * Sin((Angle-180) * #PI / 180)
    Y4 = CY + Radius * Sin((Angle-210) * #PI / 180)
    ;Dessin du point
    Circle(X, Y, 3,$FF0000)
    Circle(X2, Y2, 3,GetWindowColor(0))
    Circle(X3, Y3, 3,$0000FF)
    Circle(X4, Y4, 3,GetWindowColor(0))
  Next
  StopDrawing()  
EndProcedure

 Procedure Draw2()
   If cercleR > 0
     cercleR = cercleR -1
   Else
     cercleR = 25
   EndIf  
   StartDrawing(CanvasOutput(#Canvas2))
   ;Dessin du cercle
     DrawingMode(#PB_2DDrawing_Default)
     Circle(30, 30,cercleR,$4040FF)
     Circle(30, 30,cercleR-1,GetWindowColor(0))
   StopDrawing()
 EndProcedure
; 
 Procedure Draw3()
 Static Angle    ;Angle variant de 0 à 360 Degrés
  Protected X, Y  ;Coordonnées X, Y du point circulant sur le cercle
  maxangle2 = maxangle2 - 25
  If maxangle2 < 0 :maxangle2 = 360:EndIf
  StartDrawing(CanvasOutput(#Canvas3))
  ;L'angle varie de 0 à 360 Degrés 
   For Angle = 0 To maxangle2 Step 30
   ;Dessin du cercle
    DrawingMode(#PB_2DDrawing_Default)
   ;Nouvelles coordonnées X & Y du point
    X = CX + Radius * Cos(Angle * #PI / 180)
    X2 = CX + Radius * Cos((Angle+30) * #PI / 180)
    X3 = CX + Radius * Cos((Angle+240) * #PI / 180)
    Y = CY + Radius * Sin(Angle * #PI / 180)
    Y2 = CY + Radius * Sin((Angle+30) * #PI / 180)
    Y3 = CY + Radius * Sin((Angle+240) * #PI / 180)
    ;Dessin du point
    Circle(X, Y, 3,$FF0000)
    Circle(X2, Y2, 3,GetWindowColor(0))
    Circle(X3, Y3, 3,$0000FF)
  Next
  StopDrawing()  
 EndProcedure
; 
 Procedure Draw4()
   Static z
   z = z +1
   If z > 10:z= 0:EndIf 
   fondcanvas(4)
   Txt.s = Chr(8703)
   StartDrawing(CanvasOutput(#Canvas4))
   If z = 10
     DP = TextWidth(Txt.s) +12
   Else
     DP = 0
   EndIf
   DrawingMode(#PB_2DDrawing_AlphaBlend|#PB_2DDrawing_Transparent)
   DrawingFont(Police)
   DrawText(DP,((60 - TextHeight(Txt.s))/2),Txt.s,RGBA(34,139,34, 255))
   StopDrawing()
 EndProcedure
; 
 Procedure Draw5()
   Static DP
   Static x
   fondcanvas(5)
   StartDrawing(CanvasOutput(#Canvas5))
   Txt.s = "●" 
   If DP = (85 - TextWidth(Txt.s)) 
     X= 1
   EndIf  
   If DP = 0
     X= 0
   EndIf
   If X =1
     DP = DP -1
   Else
     DP = DP +1
   EndIf   
   DrawingMode(#PB_2DDrawing_AlphaBlend|#PB_2DDrawing_Transparent)
   DrawingFont(Police)
   DrawText(DP,((60 - TextHeight(Txt.s))/2),Txt.s,RGBA(0,178,238, 255))
   StopDrawing()
 EndProcedure
 
 Procedure Draw6()
   Static DP
   Static x
   fondcanvas(6)
   StartDrawing(CanvasOutput(#Canvas6))
   Txt.s = "●" 
   If DP => (85 - TextWidth(Txt.s)) 
     X= 1
   EndIf  
   If DP = 0
     X= 0
   EndIf
   If X =1
     DP = DP -5
   Else
     DP = DP +5
   EndIf   
   DrawingMode(#PB_2DDrawing_AlphaBlend|#PB_2DDrawing_Transparent)
   DrawingFont(Police)
   DrawText(DP,((60 - TextHeight(Txt.s))/2),Txt.s,RGBA(255,99,71, 255))
   StopDrawing()
 EndProcedure

Procedure Exit() 
  End
EndProcedure
Dernière modification par MLD le dim. 01/avr./2018 17:48, modifié 1 fois.
Avatar de l’utilisateur
Kwai chang caine
Messages : 6962
Inscription : sam. 23/sept./2006 18:32
Localisation : Isere

Re: Figures d'attente (2)

Message par Kwai chang caine »

Marche nickel
Merci du partage 8)
ImageLe bonheur est une route...
Pas une destination

PureBasic Forum Officiel - Site PureBasic
Avatar de l’utilisateur
falsam
Messages : 7244
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: Figures d'attente (2)

Message par falsam »

Tel quel ce code n'a rien de figures d'attente. Si un processus de chargement ou de calcul lourd est en cours, la figure d'attente sera figée.
Configuration : Windows 11 Famille 64-bit - PB 6.03 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
Avatar de l’utilisateur
MLD
Messages : 1103
Inscription : jeu. 05/févr./2009 17:58
Localisation : Bretagne

Re: Figures d'attente (2)

Message par MLD »

@KCC
Merci
@ Falsam
Sans blague
Répondre