forme géométrique : deltoîde

Programmation d'applications complexes
manababel
Messages : 135
Inscription : jeu. 14/mai/2020 7:40

forme géométrique : deltoîde

Message par manababel »

formes similaire d'astroîde

Code : Tout sélectionner

Procedure filter_deltoide(cx,cy,rayon,ang.f=90,b=2,a=2,col=$ffffff)
  
  If b<1:b=1:EndIf
  If b>9:b=9:EndIf
  If a<2:a=2:EndIf
  If a>128:a=128:EndIf
  
  r=(rayon)/((b+1)*2) 

	 x1=(b+Cos(Radian(ang)))*r+cx
	 y1=(-Sin(Radian(ang)))*r+cy

	 compt.f=(360/(rayon*4))
	 If compt<0.5:compt=0.5:EndIf
	 
	 i.f=0
	 While i.f<=360
	  x2.f=Cos(Radian(i*a+ang))
	  y2.f=Sin(Radian(i*a+ang))
	  x=(b*(Cos(Radian(i)))+x2)*r+cx
	  y=(b*(Sin(Radian(i)))-y2)*r+cy
    LineXY(x,y,x1,y1,col)
    x1=x
    y1=y
    i=i+compt
   Wend

EndProcedure


Global lg = 800
Global ht = 600

If OpenWindow(0, 0, 0, lg, ht, "deltoide", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
  
  Image = CreateImage(#PB_Any, lg, ht)

  ii=0
  Repeat
    
   Event = WindowEvent()   
   
   StartDrawing(ImageOutput(Image))
   Box(0,0,lg,ht,0)
   
   a.f=ii/1
   opt1=1
   opt2=1
   For y=25 To 775 Step 50
     For x=25 To 975 Step 50
       filter_deltoide(x,y,50,a,opt1,opt2)
       opt1=Mod(opt1+1,8)
     Next
     opt2=Mod(opt2+1,9)
   Next

   StopDrawing()

   StartDrawing(WindowOutput(0))
   DrawImage(ImageID(Image), 0, 0)
   StopDrawing()
   
   ii=ii+1 
   ii=Mod(ii,3600)
   
 Until Event = #PB_Event_CloseWindow Or quit=1
 FreeImage(#PB_All)
 CloseWindow(0)

EndIf