Page 1 of 1

Drawing a polygon

Posted: Thu May 24, 2018 7:52 pm
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

Re: Drawing a polygon

Posted: Thu May 24, 2018 8:23 pm
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

Re: Drawing a polygon

Posted: Fri May 25, 2018 4:28 am
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 :)

Re: Drawing a polygon

Posted: Fri May 25, 2018 4:46 pm
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

Re: Drawing a polygon

Posted: Fri May 25, 2018 7:37 pm
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

Re: Drawing a polygon

Posted: Fri May 25, 2018 10:14 pm
by bluebird
Kevin

The error I get is

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

Thanks for your reply

Re: Drawing a polygon

Posted: Sat May 26, 2018 2:36 am
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 2028 times

Re: Drawing a polygon

Posted: Mon May 28, 2018 12:51 am
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.