Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #135646
| From | Hans Bezemer <the.beez.speaks@gmail.com> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | General routine for a polyline or a polygon |
| Date | 2026-09-10 12:46 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <117u1p9$1toc3$1@dont-email.me> (permalink) |
Can be used with any LINE command, as long as it draws a line between
two absolute coordinates. ( x1 y1 x2 y2 --):
: line cr rot >r -rot r> rot 0 .r ." ," . 0 .r ." ," . ; \ dummy line word
variable 'lineto \ stores
address of (lineto)
[: drop drop drop drop ;] constant (cancel) ( x1 y1 x2 y2 --)
[: 2dup 2>r line 2r> 'lineto @ ;] constant (lineto) ( x1 y1 x2 y2
-- x2 y2 xt)
[: 2dup (lineto) ;] constant (moveto) ( x y -- x y
x y xt)
: polygon[ ['] line (moveto) ; ( -- xt1 xt2)
: polyline[ (cancel) (moveto) ; ( -- xt1 xt2)
: +point rot execute ; ( x1 y1 xt x2
y2 -- x2 y2 xt)
: ]poly drop 2>r rot 2r> +point ; ( xt1 x1 y1
x2 y2 xt2 --)
(lineto) 'lineto !
This is a sample application:
polygon[ \ start a polygon
75 300 +point \ now issue all the points
161 329 +point
161 419 +point
215 347 +point
301 373 +point
250 300 +point
301 227 +point
215 253 +point
161 181 +point
161 271 +point
]poly \ close the polygon
All the points should be listed now (filtered output):
75,300 161,329 ok 6
161,329 161,419 ok 6
161,419 215,347 ok 6
215,347 301,373 ok 6
301,373 250,300 ok 6
250,300 301,227 ok 6
301,227 215,253 ok 6
215,253 161,181 ok 6
161,181 161,271 ok 6
75,300 161,271 ok
Hans Bezemer
Back to comp.lang.forth | Previous | Next — Next in thread | Find similar | Unroll thread
General routine for a polyline or a polygon Hans Bezemer <the.beez.speaks@gmail.com> - 2026-09-10 12:46 +0200
Re: General routine for a polyline or a polygon dxf <dxforth@gmail.com> - 2026-09-10 23:33 +1000
Re: General routine for a polyline or a polygon Hans Bezemer <the.beez.speaks@gmail.com> - 2026-09-10 19:22 +0200
Re: General routine for a polyline or a polygon Hans Bezemer <the.beez.speaks@gmail.com> - 2026-09-11 13:30 +0200
Re: General routine for a polyline or a polygon dxf <dxforth@gmail.com> - 2026-09-12 01:04 +1000
Re: General routine for a polyline or a polygon dxf <dxforth@gmail.com> - 2026-09-12 02:34 +1000
Re: General routine for a polyline or a polygon Hans Bezemer <the.beez.speaks@gmail.com> - 2026-09-11 19:22 +0200
csiph-web