Generateur de ZEBRA

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
Ekim
Messages : 215
Inscription : dim. 24/juin/2018 1:20

Generateur de ZEBRA

Message par Ekim »

Bonsoir à tous,

j'éssais de créer un générateur de Zebra mais cela ne fonctionne pas :cry:

Code : Tout sélectionner

If OpenWindow(0, 0, 0, 400, 200, "Line", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
	If CreateImage(0, 400, 200) And StartDrawing(ImageOutput(0))
		;Box(0, 0, 400, 200, #Black)
		
		clr2=#Yellow
		clr1=#Red ;#Black
		
		For ln=1 To 360; Step 20
			
			
			For x = 1 To 20
				Swap clr1, clr2
				LineXY(x+ln,1,x+ln+40,200,clr1)
			Next x
		Next ln
		
		StopDrawing() 
		
		ImageGadget(0, 0, 0, 400, 200, ImageID(0))
	EndIf
	
	Repeat
		Event = WaitWindowEvent()
	Until Event = #PB_Event_CloseWindow
EndIf
donc si quelqu'un peu m'aider, sa serait vachement chouette :P
Avatar de l’utilisateur
Ar-S
Messages : 9540
Inscription : dim. 09/oct./2005 16:51
Contact :

Re: Generateur de ZEBRA

Message par Ar-S »

Une petite bidouille à 1h30 du matin..
Pas de math, juste de la ruse.

Code : Tout sélectionner


      clr2=#Yellow
      clr1=#Red ;#Black


      If OpenWindow(0, 0, 0, 400, 200, "Line", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
        If CreateImage(0, 400, 200) And StartDrawing(ImageOutput(0))
          Box(0, 0, 400, 200, clr2)
          
          For x = 0 To 399 Step 20

            While jump < 20
              LineXY(x,0,x+20,200,clr1)
              jump+1
              x+1
            Wend     
            jump = 0
          Next x
  
      StopDrawing()
      
      ImageGadget(0, 0, 0, 400, 200, ImageID(0))
   EndIf
   
   Repeat
      Event = WaitWindowEvent()
   Until Event = #PB_Event_CloseWindow
EndIf
Tu devrais cependant regarder la lib Vector pour faire du propre.
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Ekim
Messages : 215
Inscription : dim. 24/juin/2018 1:20

Re: Generateur de ZEBRA

Message par Ekim »

Merci @Ar-S

Je suis également un couche tard :lol:

Oui j'aurais dû y pense à cette méthode, bravo :wink:
Mesa
Messages : 1126
Inscription : mer. 14/sept./2011 16:59

Re: Generateur de ZEBRA

Message par Mesa »

Vector:

Code : Tout sélectionner

w=400
h=400
dw=50
rot=-20

If OpenWindow(0, 0, 0, w, h, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CanvasGadget(0, 0, 0, w, h)    
  
  If StartVectorDrawing(CanvasVectorOutput(0))
    VectorFont(LoadFont(0, "Times New Roman", 60, #PB_Font_Bold))
    
    VectorSourceColor(RGBA(255, 0, 0, 255))
    MovePathCursor(0, 0)
    AddPathBox(0, 0, w, h)
    FillPath()
    
    VectorSourceColor(RGBA(255, 255, 0, 255))
    MovePathCursor(-w, 0)
    RotateCoordinates(0, 0, rot)
    
    For i=0 To w/dw
      AddPathBox(-w, 0, dw, h+3*dw)
      
      TranslateCoordinates(2*dw, 0) 
      FillPath()
    Next i 
    
    StopVectorDrawing()
  EndIf
  
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf
bug fix
M.
Ekim
Messages : 215
Inscription : dim. 24/juin/2018 1:20

Re: Generateur de ZEBRA

Message par Ekim »

@Mesa, sympa cette méthode :wink:

@Ar-S, pourquoi suivant ces paramètres, les rainures sont altérées?

Code : Tout sélectionner

clr2=#Yellow
clr1=#Black

	If CreateImage(0, 790, 510) And StartDrawing(ImageOutput(0))
		Box(0, 0, 790, 510, clr2)
		
		For x = 0 To 700 Step 10
			
			While jump < 10
				LineXY(x+140,0,x-140,510,clr1)
				jump+1
				x+1
			Wend 
    
			jump = 0
		Next x
		
		StopDrawing()
		
	EndIf


If OpenWindow(0, 0, 0, 790, 510, "Line", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

	ImageGadget(0, 0, 0, 790, 510, ImageID(0))
	
	Repeat
		Event = WaitWindowEvent()
	Until Event = #PB_Event_CloseWindow
EndIf
Répondre