Publié : sam. 05/mars/2005 9:45
Merci pour vos reponces !
le plus dur maintenant vas etre de faire un code pas trop
"usine a gaz".
le plus dur maintenant vas etre de faire un code pas trop
"usine a gaz".
le problème c'est qu'avec des lignes aux coordonnées entières, ce n'est pas fiable...Frenchy Pilou a écrit :Quand on trace les segments, on compare les X
On garde le plus petit, Xmini
On place le FillArea à Xmini-1, Y quelconque
Ce qui fait que la couleur du Fill sera à l'extérieur
On teste le X, Y courant
S'il a la couleur du Fill c'est qu'il est à l'extérieur itou
Sinon c'est qu'il est dedans
Code : Tout sélectionner
HRGN CreatePolygonRgn(
CONST POINT *lppt, // address of array of points
int cPoints, // number of points in array
int fnPolyFillMode // polygon-filling mode
);
Code : Tout sélectionner
BOOL PtInRegion(
HRGN hrgn, // handle of region
int X, // x-coordinate of point
int Y // y-coordinate of point
);
http://www.codeguru.com/forum/archive/i ... 27124.htmlMy program, working perfectly in Win98 seemed to go awry in WinXP. I tracked that the problem was that CreatePolygonRgn() failed. CreateRectRgn() works, but CreatePolygonRgn() fails. Are there any known issues?
oui dr dri, cf doc ms :Dr. Dri a écrit :j'ai essayé l'api ptinregion... ca fonctionne nickel chez moi... ma region (hRgn) par contre, je la libère comment ? DeleteObject_() ??
Dri
The DeleteObject function deletes a logical pen, brush, font, bitmap, region, or palette, freeing all system resources associated with the object. After the object is deleted, the specified handle is no longer valid.
Code : Tout sélectionner
#dobro=1
#Police=1
#Sprite=1
#PI=3.1415926
Declare polygone(x.l,y.l,taille.l,angle.l,rotation.f,color.l,t)
; ***********************************
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, #PB_Window_SystemMenu|#PB_Window_BorderLess |#PB_Window_ScreenCentered , "hello")
WindowID = WindowID(1)
Result = OpenWindowedScreen(WindowID,0,0,800, 600, 1, 0,0)
Resultat = InitMouse()
Repeat
ExamineMouse()
Event=WindowEvent()
If MouseButton(2)
End
EndIf
;Star(x.l,y.l,intrad.l,n.l,phase.f,color.l)
x.l=400 ;location x
y.l=300 ; location y
taille.l=100
angle.l=4 ; pour un triangle 4 pour un carre , 8 pour un octogone ect ...
rotation.f=180
color.l=RGB($FF,$FF,$80)
For t=0 To 360
; Delay (200)
rotation.f=t
polygone(x.l,y.l,taille.l,angle.l,rotation.f,color.l,t)
FlipBuffers():; affiche l'ecran
ClearScreen(0,0,0)
ExamineMouse()
Event=WindowEvent()
If MouseButton(2)
End
EndIf
Next t
Until Event=#PB_Event_CloseWindow
Procedure polygone(x.l,y.l,taille.l,angle.l,rotation.f,color.l,t)
If angle.l=4
Else
EndIf
rotation.f= rotation.f*0.01745329
StartDrawing(ScreenOutput() )
DrawText(StrF( t))
alpha.f=2*(#PI/angle)
For t.l=1 To angle
d1.f=(t-1)*alpha+rotation.f
d3.f=t*alpha+rotation.f
LineXY(x+taille*Sin(d1),y+taille*Cos(d1),x+taille*Sin(d3),y+taille*Cos(d3),color)
Next
StopDrawing()
EndProcedure