Code: Select all
#dobro=1
#Police=1
#Sprite=1
Declare polygone(x,y,taille,angle,rotation.f,color,r.b,coul_remp)
Declare remplis(*hdc,x,y,couleur_remplissage)
; ***********************************
Resultat = InitSprite()
FontID = LoadFont(#Police, "arial", 18, #PB_Font_Bold )
EcranX = GetSystemMetrics_(#SM_CXSCREEN):;=largeur de l'ecran
EcranY = GetSystemMetrics_(#SM_CYSCREEN):;=hauteur de l'ecran
WindowID = OpenWindow(1, 0, 0, EcranX, EcranY, "hello", #PB_Window_SystemMenu|#PB_Window_BorderLess |#PB_Window_ScreenCentered )
WindowID = WindowID(1)
ecran= OpenWindowedScreen(WindowID,0,0,800, 600, 1, 0,0)
Resultat = InitMouse()
Repeat
ExamineMouse()
Event=WindowEvent()
If MouseButton(2)
End
EndIf
x=400 ;location x
y=300 ; location y
taille=300
angle=4 ; pour un triangle 4 pour un carre , 8 pour un octogone ect ...
rotation.f=180
For tp=0 To 360
; Delay (200)
r=0 ; remplis ou pas !!
rotation.f=tp
color=RGB($FF,$FF,$FF) ; couleur du tour$
coul_remp=RGB($F9,$FE,$8B) ; couleur du remplissage !
c=c+1
polygone(x,y,taille,angle,rotation.f,color,r,coul_remp)
If c=50
angle=Random(8)+3
c=0
EndIf
FlipBuffers():; affiche l'ecran
ClearScreen(RGB(0,0,0))
ExamineMouse()
Event=WindowEvent()
If MouseButton(2)
End
EndIf
Next tp
Until Event=#PB_Event_CloseWindow
Procedure polygone(x,y,taille,angle,rotation.f,color,r.b,coul_remp)
rotation.f= rotation.f*0.01745329
alpha.f=2*(#PI/angle)
For t=1 To angle
d1.f=(t-1)*alpha+rotation.f
d3.f=t*alpha+rotation.f
*dc=StartDrawing(ScreenOutput() )
DrawingMode(4)
LineXY(x+taille*Sin(d1),y+taille*Cos(d1),x+taille*Sin(d3),y+taille*Cos(d3),color); polygone vide
StopDrawing()
Next t
If r=1
*dc=StartDrawing(ScreenOutput() )
DrawingMode(4)
remplis(*dc,x,y,coul_remp )
StopDrawing()
EndIf
EndProcedure
Procedure remplis(*hdc,x,y,couleur_remplissage)
pinceau=CreateSolidBrush_(couleur_remplissage)
SelectObject_(*hdc,pinceau)
ExtFloodFill_(*hdc,x,y,GetPixel_(*hdc,x,y),#FLOODFILLSURFACE)
DeleteObject_(pinceau)
ReleaseDC_(WindowID(1),*hdc)
EndProcedure