ali_t89
asked on
How do I create and draw a BowTie polygon on Delphi
so far I did this much. I can compile it but when I run it, I don't see anything
procedure DrawBowTie( const xPaper: TImage ; // to draw upon
const xColor: TColor ) ; // the pen color
// Procedure to draw a BowTie on an Image.
// The BowTie occupies from 1/4 to 3/4 of the Width of the Image,
// and from 1/4 to 3/4 of the Height, with the pinch in the middle
// of the Image.
// Coordinates of the vertexes are calculated from the 1/4 values,
// plus value, Mid, for the pinch area.
var W1Q, H1Q, Mid: integer ;
begin
W1Q := xPaper.Width div 4 ; // 1/4 of the Width
// 2 * W1Q is 2/4 (or 1/2) of the Width
// 3 * W1Q is 3/4 of the Width
H1Q := xPaper.Height div 4 ; // 1/4 of the Height
// 2 * H1Q is 2/4 (or 1/2) of the Height
// 3 * H1Q is 3/4 of the Height
Mid := xPaper.Height div 20; // 1/20 of the Height (for Bow "Pinch")
xPaper.Canvas.Pen.Color := xColor ; // set drawing color
xPaper.Canvas.Polygon( [point( W1Q, H1Q), //upper left
point(2*W1Q,2*H1Q-Mid), //upper middle pinch
point(3*W1Q, H1Q), //upper right
point(3*W1Q,3*H1Q), //lower right
point(2*W1Q,2*H1Q+Mid), //lower middle pinch
point( W1Q,3*H1Q)] ) //lower left
end ;
procedure DrawBowTie( const xPaper: TImage ; // to draw upon
const xColor: TColor ) ; // the pen color
// Procedure to draw a BowTie on an Image.
// The BowTie occupies from 1/4 to 3/4 of the Width of the Image,
// and from 1/4 to 3/4 of the Height, with the pinch in the middle
// of the Image.
// Coordinates of the vertexes are calculated from the 1/4 values,
// plus value, Mid, for the pinch area.
var W1Q, H1Q, Mid: integer ;
begin
W1Q := xPaper.Width div 4 ; // 1/4 of the Width
// 2 * W1Q is 2/4 (or 1/2) of the Width
// 3 * W1Q is 3/4 of the Width
H1Q := xPaper.Height div 4 ; // 1/4 of the Height
// 2 * H1Q is 2/4 (or 1/2) of the Height
// 3 * H1Q is 3/4 of the Height
Mid := xPaper.Height div 20; // 1/20 of the Height (for Bow "Pinch")
xPaper.Canvas.Pen.Color := xColor ; // set drawing color
xPaper.Canvas.Polygon( [point( W1Q, H1Q), //upper left
point(2*W1Q,2*H1Q-Mid), //upper middle pinch
point(3*W1Q, H1Q), //upper right
point(3*W1Q,3*H1Q), //lower right
point(2*W1Q,2*H1Q+Mid), //lower middle pinch
point( W1Q,3*H1Q)] ) //lower left
end ;
FYI, I ran your code on Delphi 7, all was fine.
ASKER
I don't have Delphi 7..but thanks anyways. I don't understand why a Bowtie Polygon doesn't show when I do it!
What's version of your Delphi?
Have you tried to draw on an empty TImage instance?
Have you tried to draw on an empty TImage instance?
ASKER
im using the delphi application on borland development studio 2006 it doesn't clarify the version of delphi but it says borland version 10.0
ASKER
no I havent tried to draw anything because when I run it. It doesn't have anything to draw on. TImage doesn't show up
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks man now I have the image