nanogui: Thread: How to draw a rounded rectangle using nano-X API?


[<<] [<] Page 1 of 1 [>] [>>]
Subject: How to draw a rounded rectangle using nano-X API?
From: "Zhao Cheng" ####@####.####
Date: 4 Feb 2011 12:29:45 -0000
Message-Id: <op.vqdozcg2mmjpib@kitten>

I want to use nano-x API to draw a rounded rectangle, I
searched the source and found an implementation of
CreateRoundRectRgn, which is of Win32 API.

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?

-- 
Kind regards,
Zhao Cheng
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
[<<] [<] Page 1 of 1 [>] [>>]


Powered by ezmlm-browse 0.20.