Codesnippets > 2D-snippets

DrawRect with Border

(1/1)

momosxp:
Here a simple function to draw a rectangle with border. I wrote it for the Menus of a RPG..
Maybe something which could be implemented in GLBasic?


--- Code: (glbasic) ---FUNCTION DrawWindow: WindowX,WindowY,WindoWidth,WindowHeight,WindowRGB,BorderRGB,Border
DRAWRECT WindowX,WindowY,WindoWidth+2*Border,Border,BorderRGB
DRAWRECT WindowX,WindowY+WindowHeight+Border,WindoWidth+2*Border,Border,BorderRGB
DRAWRECT WindowX,WindowY+Border,Border,WindowHeight+Border,BorderRGB
DRAWRECT WindowX+WindoWidth+Border,WindowY+Border,Border,WindowHeight+Border,BorderRGB
// ALPHAMODE 1
DRAWRECT WindowX+Border,WindowY+Border,WindoWidth,WindowHeight,WindowRGB
// ALPHAMODE 0
ENDFUNCTION
--- End code ---



Example

--- Code: (glbasic) ---SETSCREEN 320,240,0
SYSTEMPOINTER TRUE
// SETCURRENTDIR("Media") // seperate media and binaries?
WHILE TRUE
MOUSESTATE mx,my,b1,b2
DrawWindow (20,2,50,100,RGB(255,255,255),RGB(0,0,255),5)
DrawWindow (120,70,100,100,RGB(0,0,255),RGB(255,0,0),mx)
SHOWSCREEN
WEND
FUNCTION DrawWindow: WindowX,WindowY,WindoWidth,WindowHeight,WindowRGB,BorderRGB,Border
DRAWRECT WindowX,WindowY,WindoWidth+2*Border,Border,BorderRGB
DRAWRECT WindowX,WindowY+WindowHeight+Border,WindoWidth+2*Border,Border,BorderRGB
DRAWRECT WindowX,WindowY+Border,Border,WindowHeight+Border,BorderRGB
DRAWRECT WindowX+WindoWidth+Border,WindowY+Border,Border,WindowHeight+Border,BorderRGB
// ALPHAMODE 1
DRAWRECT WindowX+Border,WindowY+Border,WindoWidth,WindowHeight,WindowRGB
// ALPHAMODE 0
ENDFUNCTION
--- End code ---

[attachment deleted by admin]

momosxp:
ohh i would have to look into that.. Don't know polyvector yes. Will give it a try

Navigation

[0] Message Index

Go to full version