Page 1 sur 1

Generateur de ZEBRA

Publié : jeu. 14/mai/2020 23:07
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

Re: Generateur de ZEBRA

Publié : ven. 15/mai/2020 0:38
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.

Re: Generateur de ZEBRA

Publié : ven. 15/mai/2020 0:58
par Ekim
Merci @Ar-S

Je suis également un couche tard :lol:

Oui j'aurais dû y pense à cette méthode, bravo :wink:

Re: Generateur de ZEBRA

Publié : ven. 15/mai/2020 7:53
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.

Re: Generateur de ZEBRA

Publié : dim. 17/mai/2020 14:56
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