Page 1 of 1

Poly2D Library

Posted: Fri Apr 09, 2004 1:57 pm
by Christian
Hi!

Some time ago I wrote some procedures for easy drawing polygons in Purebasic. Now I improved them and made a library out of it. (Thanks El_Choni for your Talbite - it's greate! :) ) So you can download it under the following link. Read the "Readme.txt" for explanation of the 20 functions. It would be nice, if you would give some feedback to me, in case you test the lib. Feel also free to ask, if you have any questions concerning the library.

The included functions are:

Code: Select all

P2D_InitPolygonDrawing()
P2D_SetPolygonPoint()
P2D_DeletePolygonPoint()
P2D_MovePolygonPoint()
P2D_CreatePolygon()
P2D_UpdatePolygon()
P2D_FreePolygon()
P2D_SetPolygonBackgroundColor()
P2D_DisplayPolygon()
P2D_TransparentPolygonColor()
P2D_DisplayTransparentPolygon()
P2D_GetPolygonPointX()
P2D_GetPolygonPointY()
P2D_GetPolygonX()
P2D_GetPolygonY()
P2D_GetPolygonWidth()
P2D_GetPolygonHeight()
P2D_GetPolygonBackgroundColor()
P2D_GetPolygonBorderColor()
P2D_GetPolygonTransparentColor()
Poly2D Library

regards,
Christian

Posted: Fri Apr 09, 2004 7:58 pm
by dontmailme
Do you have any examples ?

Does it work on 3.89 beta 2 ?

Also, you may want to make a chm file for it and enable the f1 key to get context help :)

Posted: Fri Apr 09, 2004 8:57 pm
by Christian
Hi dontmailme!

Here is an example for the lib. It shows the usage of some functions. But I hope it helps ... :)

Code: Select all

#SCREEN_Width = 500 
#SCREEN_Height = 500 

If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0 
MessageRequester("ERROR","Cant init DirectX",0) 
End 
EndIf 

MainWnd.l = OpenWindow(0, 0, 0, #SCREEN_Width, #SCREEN_Height, #PB_Window_ScreenCentered, "Polygon Beispiel") 
If OpenWindowedScreen(MainWnd.l, 0, 0, #SCREEN_Width, #SCREEN_Height, 1, 0, 0) 

If P2D_InitPolygonDrawing() 
; -- Cursor 
P2D_SetPolygonPoint(0, 0, 5, 5) 
P2D_SetPolygonPoint(0, 1, 30, 20) 
P2D_SetPolygonPoint(0, 2, 17, 17) 
P2D_SetPolygonPoint(0, 3, 20, 30) 

P2D_CreatePolygon(0, RGB(0,0,255), RGB(0,0,255)) 

; -- Shape with 5 points
P2D_SetPolygonPoint(1, 0, 0, 0) 
P2D_SetPolygonPoint(1, 1, 150, 0) 
P2D_SetPolygonPoint(1, 2, 175, 75) 
P2D_SetPolygonPoint(1, 3, 150, 200) 
P2D_SetPolygonPoint(1, 4, 50, 125) 

P2D_CreatePolygon(1, RGB(255,255,255), RGB(255,255,255)) 

; -- Triangle
P2D_SetPolygonPoint(2, 0, 0, 25) 
P2D_SetPolygonPoint(2, 1, 150, 0) 
P2D_SetPolygonPoint(2, 2, 175, 75) 

P2D_CreatePolygon(2, RGB(255,0,255), RGB(255,0,0)) 

; -- Shape with 8 points
P2D_SetPolygonPoint(3, 0, 50, 50) 
P2D_SetPolygonPoint(3, 1, 100, 25) 
P2D_SetPolygonPoint(3, 2, 150, 50) 
P2D_SetPolygonPoint(3, 3, 175, 100) 
P2D_SetPolygonPoint(3, 4, 150, 150) 
P2D_SetPolygonPoint(3, 5, 100, 175) 
P2D_SetPolygonPoint(3, 6, 50, 150) 
P2D_SetPolygonPoint(3, 7, 25, 100) 

P2D_CreatePolygon(3, RGB(255,255,0), RGB(0,0,255)) 

; -- Achteck 
P2D_SetPolygonPoint(4, 0, 50, 50) 
P2D_SetPolygonPoint(4, 1, 100, 25) 
P2D_SetPolygonPoint(4, 2, 150, 50) 
P2D_SetPolygonPoint(4, 3, 175, 100) 
P2D_SetPolygonPoint(4, 4, 150, 150) 
P2D_SetPolygonPoint(4, 5, 100, 175) 
P2D_SetPolygonPoint(4, 6, 50, 150) 
P2D_SetPolygonPoint(4, 7, 25, 100) 

P2D_CreatePolygon(4, RGB(255,255,0), RGB(0,0,255))

EndIf 

EndIf

Repeat 
While WindowEvent() : Wend 
ExamineKeyboard() 
ExamineMouse() 

P2D_DisplayPolygon(1, 200, 20)
P2D_DisplayTransparentPolygon(2, 20, 140)
P2D_DisplayTransparentPolygon(3, 20, 250)
P2D_DisplayTransparentPolygon(0, MouseX(), MouseY())


FlipBuffers() 
ClearScreen(0, 4, 0) 
Until KeyboardPushed(#PB_KEY_ESCAPE)
I can't say Whether it works in 3.89 BETA 2 or not, because I am not working with this version. I am still using 3.81.

Unfortunately I don't have a program for making .chm files. But look into the Readme.txt -> Should help!

regards,
Christian

Re: Poly2D Library

Posted: Fri Apr 09, 2004 9:45 pm
by NoahPhense
Christian wrote:(Thanks El_Choni for your Talbite - it's greate! :) )
Yeah, can't wait until it works with Beta 2, it works with Beta 1, but not Beta 2..

I'm sure it only needs a small adjustment. Even thought I have the source
I really haven't looked at it.. damn I'm spoiled.. lol

- np