Page 1 of 1
Rectangle
Posted: Wed Feb 26, 2025 8:29 am
by Natter
Hi,
I need to draw a rectangle on a window with an outline of a certain color and thickness. How to do it ?
Re: Rectangle
Posted: Wed Feb 26, 2025 10:16 am
by Silvio.Falconi
Natter wrote: Wed Feb 26, 2025 8:29 am
Hi,
I need to draw a rectangle on a window with an outline of a certain color and thickness. How to do it ?
Try this but I not test it
Code: Select all | Expand
#include "fivewin.ch"
function Main()
local oWnd
// Define the window
DEFINE WINDOW oWnd TITLE "Rectangle Example" SIZE 640, 480
// Set the pen color and thickness for the rectangle border
oWnd: SetPen( RGB(255, 0, 0), 3 ) // Red color, 3 pixels thickness
// Set the brush color for the rectangle fill (optional)
oWnd: SetBrush( RGB(0, 255, 0) ) // Green fill (you can also use a transparent fill)
// Draw the rectangle with specific coordinates
oWnd: DrawRect( 100, 100, 500, 300 ) // x1, y1, x2, y2
// Show and activate the window
ACTIVATE WINDOW oWnd
return
Re: Rectangle
Posted: Wed Feb 26, 2025 12:52 pm
by Natter
Thanks, I'll give it a try !
Re: Rectangle
Posted: Wed Feb 26, 2025 1:41 pm
by nageswaragunupudi
Code: Select all | Expand
function TestBox()
local oWnd
local aRect := { 60,100,300,400 }
local nBrdThick := 2
local nBrdColor := CLR_HRED
local nRectFill := CLR_YELLOW
DEFINE WINDOW oWnd SIZE 600, 500 PIXEL
oWnd:bPainted := { || FW_Box( oWnd, aRect, { nBrdColor, nBrdThick }, nRectFill ) }
ACTIVATE WINDOW oWnd CENTERED
return nil
Re: Rectangle
Posted: Wed Feb 26, 2025 6:23 pm
by Natter
Thanks Rao, good solution !