Drawing a polygon

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
bluebird
Posts: 172
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF

Drawing a polygon

Post by bluebird »

Friends

When I try to copile this code I get OK with the rectangles but not so with the polygons
The problem is probably understanding about "Points" .
I am assuming that each of 4 point sets {Row,Col} are required and any clockwise or couner clockwise is OK


Has anyone used this Draw feature without using Bos Taurus?

Thanks

***********************************************
Procedure Wallcolors ()
* Paint a wall to illustrate color combinations
***********************************************
Local aSelectedColors:={MEDVIOLETRED,{205,90,162},{90,162,205},{170,95,142},{93,50,165}}

if !iswindowdefined(Win_Wall)

DEFINE WINDOW Win_Wall;
AT 50,50 ;
WIDTH 550 ;
HEIGHT 450 ;
TITLE "Paint a wall" ;
BACKCOLOR IVORY
END WINDOW
Win_Wall.Activate


Else
Win_Wall.show

EndIf


DRAW RECTANGLE IN WINDOW Win_Wall AT 10,200 TO 330,400 FILLCOLOR aSelectedColors[1] // right wall

DRAW RECTANGLE IN WINDOW Win_Wall AT 10,200 TO 40,400 FILLCOLOR aSelectedColors[2] //top stripe

DRAW RECTANGLE IN WINDOW Win_Wall AT 10,200 TO 40,400 FILLCOLOR aSelectedColors[3] // upper stripe

DRAW RECTANGLE IN WINDOW Win_Wall AT 340,200 TO 300,400 FILLCOLOR aSelectedColors[2] // base stripe



DRAW POLYGON IN WINDOW Win_Wall POINTS {{50,50},{10,200},{300,200},{390,10}} FILLCOLOR aSelectedColors[1] //left wall

DRAW POLYGON IN WINDOW Win_Wall POINTS {{50,50},{80,50},{40,200},{10,200}} FILLCOLOR aSelectedColors[2]

DRAW POLYGON IN WINDOW Win_Wall POINTS {{80,50},{110,50},{70,200},{40,200}} FILLCOLOR aSelectedColors[3]

DRAW POLYGON IN WINDOW Win_Wall POINTS {{360,50},{390,50},{2300,200},{330,200}} FILLCOLOR aSelectedColors[2]


DRAW POLYGON IN WINDOW Win_Wall POINTS {{390,50},{330,200},{330,400},{375,50}} FILLCOLOR aSelectedColors[5] //floor

Return NIL
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Drawing a polygon

Post by andyglezl »

Así a simple vista no veo que el poligono se cierre para "llenarlo" de un color,
creo que te falta una última coordenada.
-----------------------------------------------------------------------------------------------

So at first glance I do not see that the polygon closes to "fill" it with a color,
I think you're missing a last coordinate.

DRAW POLYGON IN WINDOW Win_Wall POINTS {{50,50},{10,200},{300,200},{390,10}, {50,50}} FILLCOLOR aSelectedColors[1] //left wall
Andrés González López
Desde Guadalajara, Jalisco. México.
bluebird
Posts: 172
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF

Re: Drawing a polygon

Post by bluebird »

Thanks for the excellent observation

I tought that I only had to give the polygon 4 points just like the rectangle.
Should have thought of what "poly" means.

Gracious, and good luck Mexico with NAFTA :)
bluebird
Posts: 172
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF

Re: Drawing a polygon

Post by bluebird »

Thanks Andy. but I still get syntax error if I include the line below:

I have not been successful in finding an example of drawing a polygon with HMG
In the code below it does not make a difference if I write it out on one line, or use the semi colons.

What am I doing wrong ???? :(

Private aSelectedColors:={{199,21,133},{205,90,162},{90,162,205},{170,95,142},{93,50,165}} //defined ahead of call to do rectangles and polygons


DRAW POLYGON IN WINDOW Win_Wall;
POINTS {{50,50},{10,200},{300,200},{390,50},{50,50}} ;
PENCOLOR {61,82,200} ;
PENWIDTH 4 ;
FILLCOLOR aSelectedColors[1] //left wall
User avatar
kcarmody
Posts: 152
Joined: Tue Oct 07, 2014 11:13 am
Contact:

Re: Drawing a polygon

Post by kcarmody »

bluebird wrote: Fri May 25, 2018 4:46 pm Thanks Andy. but I still get syntax error if I include the line below:

I have not been successful in finding an example of drawing a polygon with HMG
In the code below it does not make a difference if I write it out on one line, or use the semi colons.

What am I doing wrong ???? :(

Private aSelectedColors:={{199,21,133},{205,90,162},{90,162,205},{170,95,142},{93,50,165}} //defined ahead of call to do rectangles and polygons


DRAW POLYGON IN WINDOW Win_Wall;
POINTS {{50,50},{10,200},{300,200},{390,50},{50,50}} ;
PENCOLOR {61,82,200} ;
PENWIDTH 4 ;
FILLCOLOR aSelectedColors[1] //left wall
What error exactly are you getting?

Check out \SAMPLES\Controls\Graph\GRAPH_01\demo.prg . It compiles and runs fine for me. It draws several shapes, including a polygon. The polygon it draws has 7 sides, and there are 7 coordinate pairs in POINTS. You must look closely to see the 7 sides, as two of them are nearly in the same line.

Kevin
bluebird
Posts: 172
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF

Re: Drawing a polygon

Post by bluebird »

Kevin

The error I get is

Error E0030 Syntax error "syntax error at 'POLYGON'"

Thanks for your reply
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Drawing a polygon

Post by andyglezl »

Probaste el ejemplo que te menciono Kevin ???
---------------------------------------------------------
Did you try the example that Kevin mentioned to you ???

Polygon.png
Polygon.png (10.21 KiB) Viewed 1795 times
Andrés González López
Desde Guadalajara, Jalisco. México.
bluebird
Posts: 172
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF

Re: Drawing a polygon

Post by bluebird »

Sorry for the late reply

Yes, I found it. My program does what I want it to do . Still do not know why it did not work the first time.

Theory: there may have been unseen characters within my original text.

Sincere thanks to all who helped me.
Post Reply