tAdded background color control - polygen - generative drawing of polygonal patterns
 (HTM) git clone git://src.adamsgaard.dk/polygen
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
 (DIR) commit f51f9c0287d3176bb8fa818db4035b3ddf41413c
 (DIR) parent ba5bec68d87be35cff72f57af2ea41062f9760ef
 (HTM) Author: Anders Damsgaard <anders.damsgaard@geo.au.dk>
       Date:   Thu, 13 Mar 2014 21:39:26 +0100
       
       Added background color control
       
       Diffstat:
         M octahedron.py                       |       4 +---
         M polygen.py                          |      20 ++++++++++++++------
       
       2 files changed, 15 insertions(+), 9 deletions(-)
       ---
 (DIR) diff --git a/octahedron.py b/octahedron.py
       t@@ -1,10 +1,8 @@
        #!/usr/bin/env python
       -
       -import numpy
        import polygen
        
        octahedron = polygen.regular_star_polygon(8)
       -#octahedron = polygen.regular_star_polygon(3)
        p = polygen.polyplot()
        p.set_points(octahedron.points)
        p.plot_all_to_all(line_width=4, exceptions=[[0,4], [1,5], [2,6], [3,7]])
       +p.save_plot(background_color='#666666', transparent_background=False)
 (DIR) diff --git a/polygen.py b/polygen.py
       t@@ -13,12 +13,11 @@ class polyplot:
                self.points = points
        
            def plot_all_to_all(self, line_color='k', line_width=2,
       -            image_name='all_to_all', image_format='png',
       -            figure_size=(8,8), transparent_background=True,
       +            figure_size=(8,8),
                    plot_points=False, points_style='wo',
                    show_axes=False, exceptions=[]):
                self.points = numpy.asarray(self.points)
       -        fig = plt.figure(figsize=figure_size)
       +        self.fig = plt.figure(figsize=figure_size)
                for i in range(self.points.shape[0]):
                    for j in range(self.points.shape[0]):
                        if (i != j and
       t@@ -32,9 +31,18 @@ class polyplot:
                plt.axis('equal')
                if (show_axes == False):
                    plt.axis('off')
       -        fig.savefig(image_name + '.' + image_format,
       -                transparent=transparent_background)
       -        fig.clf()
       +
       +    def save_plot(self, image_name='all_to_all', image_format='png',
       +            background_color='white',
       +            transparent_background=False):
       +        if (transparent_background == True):
       +            self.fig.savefig(image_name + '.' + image_format,
       +                    transparent=True)
       +        else:
       +            self.fig.savefig(image_name + '.' + image_format,
       +                    facecolor=background_color, transparent=False)
       +        self.fig.clf()
       +
        
        class regular_star_polygon:
            def __init__(self, n=5):