#!/bin/sh
. ./Common

###############################################################################

tst "make an open polygon" <<EOF
struct p2d *p = p2d_new();

p2d_append(p, v2d_new(0, 0));
p2d_append(p, v2d_new(1, 2));
p2d_write_gnuplot(stdout, p);
EOF

expect <<EOF
0 0
1 2

EOF

#------------------------------------------------------------------------------

tst "make a closed polygon" <<EOF
struct p2d *p = p2d_new();

p2d_append(p, v2d_new(-1, 1));
p2d_append(p, v2d_new(3, 7));
p2d_close(p);
p2d_write_gnuplot(stdout, p);
EOF

expect <<EOF
-1 1
3 7
-1 1

EOF

#------------------------------------------------------------------------------

tst "make two open polygons" <<EOF
struct p2d *p = p2d_new();
struct p2d *q = p2d_new();

p2d_append(p, v2d_new(1, 4));
p2d_append(p, v2d_new(2, 8));
p->next = q;
p2d_append(q, v2d_new(3, 15));
p2d_append(q, v2d_new(4, 16));
p2d_write_gnuplot_all(stdout, p);
EOF

expect <<EOF
1 4
2 8

3 15
4 16

EOF

###############################################################################