theptagon.py - polygen - generative drawing of polygonal patterns
(HTM) git clone git://src.adamsgaard.dk/polygen
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
theptagon.py (1892B)
---
1 #!/usr/bin/env python
2 import polygen
3 import matplotlib.pyplot as plt
4
5 # Colors from the 'solarized' color scheme
6
7 # Generate regular polygon with eight corners (heptagon)
8 heptagon = polygen.regular_star_polygon(7)
9
10 # Create the polygon plotting object
11 p = polygen.polyplot()
12
13 # Add a circle to be in the background
14 p.plot_circle(coord=[0,0], radius=1.0, color='#073642')
15
16 # Pass the heptagon points to the plot object
17 p.set_points(heptagon.points)
18
19 # Plot heptagon, do not draw lines to opposite points. Use custom colors.
20 p.plot_all_to_all(line_width=2, line_color='#b58900',
21 exceptions=[[0,1], [1,2], [2,3], [3,4], [4,5], [5,6], [6,0]])
22
23 # Add another smaller heptagon
24 heptagon_small = polygen.regular_star_polygon(7, 0.7)
25
26 # Pass the heptagon points to the plot object
27 p.set_points(heptagon_small.points)
28
29 # Plot heptagon, do not draw lines to opposite points. Use custom colors.
30 p.plot_all_to_all(line_width=2, line_color='#dc322f',
31 exceptions=[[0,1], [1,2], [2,3], [3,4], [4,5], [5,6], [6,0]])
32
33 # Add yet another even smaller heptagon
34 heptagon_smaller = polygen.regular_star_polygon(7, 0.5)
35
36 # Pass the heptagon points to the plot object
37 p.set_points(heptagon_smaller.points)
38
39 # Plot heptagon, do not draw lines to opposite points. Use custom colors.
40 p.plot_all_to_all(line_width=2, line_color='#859900',
41 exceptions=[[0,1], [1,2], [2,3], [3,4], [4,5], [5,6], [6,0]])
42
43 # Add yet another even smaller heptagon
44 heptagon_smallest = polygen.regular_star_polygon(7, 0.3)
45
46 # Pass the heptagon points to the plot object
47 p.set_points(heptagon_smallest.points)
48
49 # Plot heptagon, do not draw lines to opposite points. Use custom colors.
50 p.plot_all_to_all(line_width=2, line_color='#657b83',
51 exceptions=[[0,1], [1,2], [2,3], [3,4], [4,5], [5,6], [6,0]])
52
53 # Save figure as file
54 p.save_plot('heptagon', background_color='#002b36',
55 transparent_background=False)