nanogui: How to draw a rounded rectangle using nano-X API?
Subject:
Re: [nanogui] How to draw a rounded rectangle using nano-X API?
From:
"Greg Haerr" ####@####.####
Date:
8 Feb 2011 04:13:31 -0000
Message-Id: <01b201cbc746$8bc59110$6964a8c0@winXP>
: It should be easy to convert CreateRoundRectRgn to
: a GrRoundRect function, but I'm not familiar with
: Win32 API, and it seems that RECT in CreateRoundRectRgn
: is not the same with GR_RECT. Could someone tell me
: which structures and functions should be replaced?
This code may be a bit tricky, ultimately you will be
rewriting it completely to use GrLine and GrDrawPoint
calls to draw a rounded rectangle. The example you
have uses region-unions, and none of that will work
for drawing your rounded rectangle.
To draw a rounded rectangle, each corner is drawn as
one quarter of a circle, connected to the top, bottom
and side lines. Perhaps you should just use the GrArc
and GrLine routines after drawing a rounded rectangle
on graph paper. For the arc radius, you can use the
code in CreateRoundRectRgn that sets the left
and right rectangle values.
As another thought, I think FLTK supports rounded
rectangles, you might look at that code and convert
it to nano-X API.
Regards,
Greg