GLBasic forum

Codesnippets => 2D-snippets => Topic started by: momosxp on 2009-Aug-18

Title: DrawRect with Border
Post by: momosxp on 2009-Aug-18
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) Select
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




Example
Code (glbasic) Select
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


[attachment deleted by admin]
Title: Re: DrawRect with Border
Post by: momosxp on 2009-Aug-24
ohh i would have to look into that.. Don't know polyvector yes. Will give it a try