[Resolu] Probleme sur un code de dégrader

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
Avatar de l’utilisateur
GallyHC
Messages : 1708
Inscription : lun. 17/déc./2007 12:44

[Resolu] Probleme sur un code de dégrader

Message par GallyHC »

Bonjour tous,

La j'en perd mon latin et je ne comprend pas d'ou vient l'erreur dans mon code. En gros mon code dessine un degrader tout les x et ce dans la taille maxi d'un gadget image. Et tout les x il fait des saut dans le dégrader, alors voila le code mais la je vois pas le pourquoi de l'erreur.

Code : Tout sélectionner

EnableExplicit

; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************

; +--------------------------------------------------------------------------+
; |                                                                          |
; +--------------------------------------------------------------------------+

Procedure setDrawDMXChannel(limagegadget.l, w.l, h.l)
;
  Protected i.l
  Protected j.l
  Protected posx.f
  Protected posy.f
  Protected tmpa.f
  Protected tmpb.f
  Protected pasa.f
  Protected pasb.f
  Protected pasc.f
  Protected mula.f
  Protected mulb.f
  Protected mulc.f
  Protected numx.l = 32
  Protected numy.l = 16 
  Protected Dim Couleur(2)

  Couleur(0) = $8E6235
  Couleur(1) = $E9D6C2
  Couleur(2) = $D5B08C

  If CreateImage(limagegadget, w, h)
    If StartDrawing(ImageOutput(limagegadget))
      tmpa = w/numx
      tmpb = h/numy
      Box(0, 0, w, h, $0000FF)
      pasa = (Red(Couleur(2))   - Red(Couleur(1)))   / tmpa 
      pasb = (Green(Couleur(2)) - Green(Couleur(1))) / tmpa
      pasc = (Blue(Couleur(2))  - Blue(Couleur(1)))  / tmpa
      For j = 1 To numx
        mula = Red(Couleur(1))
        mulb = Green(Couleur(1))
        mulc = Blue(Couleur(1))
        For i = 1 To tmpa+1
          mula = mula + pasa
          mulb = mulb + pasb
          mulc = mulc + pasc
          LineXY(posx+i, 1, posx+i, h-2, RGB(mula,mulb,mulc))
        Next i
        posx + tmpa
      Next j
      StopDrawing()
    EndIf
    SetGadgetState(limagegadget, ImageID(limagegadget))
  EndIf

EndProcedure

; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************

; +--------------------------------------------------------------------------+
; |                                                                          |
; +--------------------------------------------------------------------------+

Define event.l
Define hWnd.l = OpenWindow(0, 0, 0, 800, 500, "test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If hWnd <> 0
  ImageGadget(26, 5, 5, 778, 400, 0)
  setDrawDMXChannel(26, 778, 400)
  
  Repeat
    event   = WaitWindowEvent(10)
  Until event =#PB_Event_CloseWindow
EndIf
Merci d'avance,
GallyHC
Dernière modification par GallyHC le mar. 07/févr./2012 11:27, modifié 1 fois.
Configuration : Tower: Windows 10 (Processeur: i7 "x64") (Mémoire: 16Go) (GeForce GTX 760 - 2Go) - PureBasic 5.72 (x86 et x64)
G-Rom
Messages : 3641
Inscription : dim. 10/janv./2010 5:29

Re: Probleme sur un code de dégrader

Message par G-Rom »

travail avec des integer ;)
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Re: Probleme sur un code de dégrader

Message par Backup »

Normal, tu divise 778/32 ça tombe pas juste !! (tmpa = w/numx)

si tu met 640 c'est bon :

Code : Tout sélectionner

EnableExplicit

; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************

; +--------------------------------------------------------------------------+
; |                                                                          |
; +--------------------------------------------------------------------------+

Procedure setDrawDMXChannel(limagegadget.l, w.l, h.l)
	;
	Protected i.l
	Protected j.l
	Protected posx.f
	Protected posy.f
	Protected tmpa.f
	Protected tmpb.f
	Protected pasa.f
	Protected pasb.f
	Protected pasc.f
	Protected mula.f
	Protected mulb.f
	Protected mulc.f
	Protected numx.l = 32
	Protected numy.l = 16
	Protected Dim Couleur(2)
	
	Couleur(0) = $8E6235
	Couleur(1) = $E9D6C2
	Couleur(2) = $D5B08C
	
	If CreateImage(limagegadget, w, h)
		If StartDrawing(ImageOutput(limagegadget))
			tmpa = w/numx
			tmpb = h/numy
			Box(0, 0, w, h, $0000FF)
			pasa = (Red(Couleur(2))   - Red(Couleur(1)))   / tmpa
			pasb = (Green(Couleur(2)) - Green(Couleur(1))) / tmpa
			pasc = (Blue(Couleur(2))  - Blue(Couleur(1)))  /tmpa
			For j = 1 To numx
				 mula = Red(Couleur(1))
				 mulb = Green(Couleur(1))
				 mulc = Blue(Couleur(1))
				
				For i = 1 To tmpa+1
					mula = mula + pasa
					mulb = mulb + pasb
					mulc = mulc + pasc
					
					
					LineXY(posx+i, 1, posx+i, h-2, RGB(mula,mulb,mulc))
				Next i
				posx + tmpa
			Next j
		StopDrawing()
	EndIf
	SetGadgetState(limagegadget, ImageID(limagegadget))
EndIf

EndProcedure

; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************

; +--------------------------------------------------------------------------+
; |                                                                          |
; +--------------------------------------------------------------------------+

Define event.l
Define hWnd.l = OpenWindow(0, 0, 0, 800, 500, "test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If hWnd <> 0
ImageGadget(26, 5, 5, 640, 400, 0)
setDrawDMXChannel(26, 640, 400)

Repeat
	event   = WaitWindowEvent(10)
Until event =#PB_Event_CloseWindow
EndIf
Avatar de l’utilisateur
GallyHC
Messages : 1708
Inscription : lun. 17/déc./2007 12:44

Re: Probleme sur un code de dégrader

Message par GallyHC »

merci pour vos reponses j'ai corrige mon code :)
Configuration : Tower: Windows 10 (Processeur: i7 "x64") (Mémoire: 16Go) (GeForce GTX 760 - 2Go) - PureBasic 5.72 (x86 et x64)
Avatar de l’utilisateur
kernadec
Messages : 1606
Inscription : ven. 25/avr./2008 11:14

Re: Probleme sur un code de dégrader

Message par kernadec »

bonjour
peut être comme ça, pour conserver le cadre rouge

cordialement

Code : Tout sélectionner

EnableExplicit

; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************

; +--------------------------------------------------------------------------+
; |                                                                          |
; +--------------------------------------------------------------------------+

Procedure setDrawDMXChannel(limagegadget.l, w.l, h.l)
  ;
  Protected i.l
  Protected j.l
  Protected posx.f
  Protected posy.f
  Protected tmpa.f
  Protected tmpb.f
  Protected pasa.f
  Protected pasb.f
  Protected pasc.f
  Protected mula.f
  Protected mulb.f
  Protected mulc.f
  Protected numx.l = 30
  Protected numy.l = 16
  Protected Dim Couleur(2)
  
  Couleur(0) = $8E6235
  Couleur(1) = $E9D6C2
  Couleur(2) = $D5B08C
  
  If CreateImage(limagegadget, w, h)
    If StartDrawing(ImageOutput(limagegadget))
      tmpa = w/numx
      tmpb = h/numy
      pasa = (Red(Couleur(2))   - Red(Couleur(1)))   / tmpa
      pasb = (Green(Couleur(2)) - Green(Couleur(1))) / tmpa
      pasc = (Blue(Couleur(2))  - Blue(Couleur(1)))  /tmpa
      For j = 1 To numx
        mula = Red(Couleur(1))
        mulb = Green(Couleur(1))
        mulc = Blue(Couleur(1))
        For i = 1 To numx+tmpa
          mula = mula + pasa
          mulb = mulb + pasb
          mulc = mulc + pasc
          LineXY(posx+i, 1, posx+i, h-2, RGB(mula,mulb,mulc))
        Next i
        posx + tmpa
      Next j
      DrawingMode(4)
      Box(0, 0, w, h, $0000FF)
      StopDrawing()
    EndIf
    SetGadgetState(limagegadget, ImageID(limagegadget))
  EndIf
  
EndProcedure

; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************

; +--------------------------------------------------------------------------+
; |                                                                          |
; +--------------------------------------------------------------------------+

Define event.l
Define hWnd.l = OpenWindow(0, 0, 0, 800, 500, "test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If hWnd <> 0
  ImageGadget(26, 5, 5, 200, 400, 0)
  setDrawDMXChannel(26, 200, 400)
  
  Repeat
    event   = WaitWindowEvent(10)
  Until event =#PB_Event_CloseWindow
EndIf
G-Rom
Messages : 3641
Inscription : dim. 10/janv./2010 5:29

Re: Probleme sur un code de dégrader

Message par G-Rom »

y a juste ca à corrigé :
Protected tmpa.f
Protected tmpb.f
en
Protected tmpa.i
Protected tmpb.i
Avatar de l’utilisateur
GallyHC
Messages : 1708
Inscription : lun. 17/déc./2007 12:44

Re: Probleme sur un code de dégrader

Message par GallyHC »

Bonjour tous,

J'avais deja corriger tout cela G-Rom et je te remercie :) Voir la 2eme capture http://purebasic.fr/french/viewtopic.php?f=3&t=12560

Cordialement,
GallyHC
Configuration : Tower: Windows 10 (Processeur: i7 "x64") (Mémoire: 16Go) (GeForce GTX 760 - 2Go) - PureBasic 5.72 (x86 et x64)
Répondre