#  Copyright (c) 1997-2006
#  Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Berlin, Germany)
#  http://www.math.tu-berlin.de/polymake,  mailto:polymake@math.tu-berlin.de
#
#  This program is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by the
#  Free Software Foundation; either version 2, or (at your option) any
#  later version: http://www.gnu.org/licenses/gpl.txt.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#-----------------------------------------------------------------------------
#  $Project: polymake $$Id: overlaid_drawing,v 1.8 2006/03/02 11:25:23 gawrilow Exp $

#  Visualize several tropical polygons jointly in one postscript image.

#  This script illustrates the following concepts:
#
#  - passing arguments via @ARGV:
#    > polymake --script overlaid_drawing 1.trop 2.trop ...
#  - composing a picture of several objects
#  - passing decorations to VISUAL
#  - calling preference labels as user functions

application 'tropical';

# different colors for different objects; may be extended arbitrarily
my @colors=($Visual::Color::facets, "255 128 128", "128 255 128", "128 128 255");
#           default                 first          second         third

sub draw {
  my @list;
  my $i=1;
  foreach (@_) {
    my $this_color= $i > $#colors? $colors[0] : $colors[$i];
    @list=(@list, $_->VISUAL(FacetColor=>$this_color));
    ++$i;
  }
  compose(@list);
}

sub multiload {
  map { load($_) } @_ # here only tropical polygons make sense
}

prefer_now "postscript";
draw(multiload(@ARGV));


# Local Variables:
# mode: perl
# c-basic-offset:3
# End:
