juste un peu d'aide pour mon code svp merci

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
bernard13
Messages : 1221
Inscription : mer. 05/janv./2005 21:30

juste un peu d'aide pour mon code svp merci

Message par bernard13 »

Bonjour à tous
je me suis amuser à coder un peu truc
on rentre trois parametres et un cercle se dessine
mon probleme c'est que ça marche pas quand je rentre les 3 parametre aucun cercle n'apparait qui peux me dire pourquoi svp merci

Code : Tout sélectionner

Enumeration 
   #image 
   #x
   #String_x
   #y 
   #String_y
   #rayon 
   #String_r
   #Bouton_dessin
 
 EndEnumeration

Procedure dessine_cercle()
x=Val(GetGadgetText(#String_y))
y=Val(GetGadgetText(#String_y))
r=Val(GetGadgetText(#String_r))
If StartDrawing(ImageOutput(#image)) 
    Circle(x,y,r,RGB(0,0,255))
  
StopDrawing()
  
  EndIf 


EndProcedure 





If OpenWindow(0,0,0,400,350,"Dessine un cercle",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
  If CreateImage(0,400,280)
  
  EndIf 
CreateGadgetList(WindowID(0))
   ImageGadget(#image,0,0,0,0,ImageID(0))
   TextGadget(#x,5,300,50,20,"X :", #PB_Text_Center)
   StringGadget(#String_x,40,300,30,20,"",#PB_String_Numeric)
   TextGadget(#y,90,300,50,20,"Y :",#PB_Text_Center)  
   StringGadget(#String_y,125,300,30,20,"",#PB_String_Numeric)
   TextGadget(#rayon,175,300,50,20,"R :",#PB_Text_Center)
   StringGadget(#String_r,210,300,30,20,"",#PB_String_Numeric)
   ButtonGadget(#bouton_dessin,270,300,80,20,"Dessine")

Repeat 
Select WaitWindowEvent () 
 
  Case #PB_Event_Gadget 
   
    Select EventGadget () 
    Case #Bouton_dessin:dessine_cercle()
    ;fermer=1
    EndSelect 
         Case #PB_Event_CloseWindow 
            fermer=1 
    EndSelect 
Until fermer=1 
EndIf
End 
Dr. Dri
Messages : 2527
Inscription : ven. 23/janv./2004 18:10

Message par Dr. Dri »

premierement tu ne donnes pas le bon numéro d'image (imageoutput)
deuxiemement tu ne rafraichis pas ton gadget

Code : Tout sélectionner

Procedure dessine_cercle()
x=Val(GetGadgetText(#String_y))
y=Val(GetGadgetText(#String_y))
r=Val(GetGadgetText(#String_r))
If StartDrawing(ImageOutput(0))
    Circle(x,y,r,RGB(0,0,255))
 
StopDrawing()
 
  EndIf

SetGadgetState(#image, ImageID(0))

EndProcedure
Dri
bernard13
Messages : 1221
Inscription : mer. 05/janv./2005 21:30

Message par bernard13 »

merci pour tes conseils
bernard13
Messages : 1221
Inscription : mer. 05/janv./2005 21:30

Message par bernard13 »

et pour effacer l'ecran
faut 'il mettre clearscreen?
Gillou
Messages : 373
Inscription : sam. 28/août/2004 17:35
Localisation : Bretagne, 22
Contact :

Message par Gillou »

Clearscreen sert uniquement dans le cas d'écran (screen), ici tu utilises une fenêtre (window), si tu veux effacer ton image tu peux faire ça par exemple :
Procedure efface_image(Image, CouleurFond=0)
     If IsImage (Image)
         StartDrawing ( ImageOutput (Image))
             DrawingMode ( #PB_2DDrawing_Default )
             Box (0, 0, ImageWidth (Image), ImageHeight (Image), CouleurFond)
         StopDrawing ()
     EndIf
EndProcedure
brossden
Messages : 822
Inscription : lun. 26/janv./2004 14:37

Message par brossden »

En résumé si tu essayes le code suivant tu devrais obtenir ce que tu veux

Code : Tout sélectionner


Enumeration
  #image
  #x
  #String_x
  #y
  #String_y
  #c
  #String_c
  #rayon
  #String_r
  #Bouton_dessin
  #Bouton_Efface
  
EndEnumeration

Procedure dessine_cercle()
  x=Val(GetGadgetText(#String_x))
  y=Val(GetGadgetText(#String_y))
  r=Val(GetGadgetText(#String_r))
  C=Val(GetGadgetText(#String_c))
  If StartDrawing(ImageOutput(0))
    Circle(x,y,r,C) 
    StopDrawing()
  EndIf
  SetGadgetState(#image, ImageID(0))
EndProcedure

Procedure   efface_image(Image, CouleurFond)
  If IsImage (Image)
    StartDrawing ( ImageOutput (Image))
    DrawingMode ( #PB_2DDrawing_Default )
    Box (0, 0, ImageWidth (Image), ImageHeight (Image), CouleurFond)
    StopDrawing ()
    SetGadgetState(#image, ImageID(0))
  EndIf
EndProcedure


If OpenWindow(0,0,0,400,350,"Dessine un cercle",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
  If CreateImage(0,400,280)
  EndIf
  CreateGadgetList(WindowID(0))
  ImageGadget(#image,0,0,0,0,ImageID(0))
  TextGadget(#x,5,300,50,20,"X :", #PB_Text_Center)
  StringGadget(#String_x,40,300,30,20,"120",#PB_String_Numeric)
  TextGadget(#y,90,300,50,20,"Y :",#PB_Text_Center) 
  StringGadget(#String_y,125,300,30,20,"100",#PB_String_Numeric)
  TextGadget(#rayon,175,300,50,20,"R :",#PB_Text_Center)
  StringGadget(#String_r,210,300,30,20,"40",#PB_String_Numeric)
  TextGadget(#c,5,325,80,20,"Couleur :", #PB_Text_Center)
  StringGadget(#String_c,80,323,80,20,"255",#PB_String_Numeric)
  ButtonGadget(#Bouton_dessin,270,300,60,20,"Dessine")
  ButtonGadget(#Bouton_Efface,330,300,60,20,"Efface")
  Repeat
    Select WaitWindowEvent ()
      Case #PB_Event_Gadget
        Select EventGadget ()
          Case #Bouton_dessin
            dessine_cercle()
          Case #Bouton_Efface
            efface_image(#image, 0)
          Case #String_c
            SetGadgetText(#String_c,Str(ColorRequester(Val(GetGadgetText(#String_c)))))
            Debug "ok"
        EndSelect
      Case #PB_Event_CloseWindow
        fermer=1
    EndSelect
  Until fermer
EndIf
End 
bernard13
Messages : 1221
Inscription : mer. 05/janv./2005 21:30

Message par bernard13 »

Merci Brossden
Répondre