Quadsymm Python Script
Posted: September 3rd, 2009, 2:55 am
A very basic quad rotational symmetry generator. Select an area with live cells and run the script file. Should work for any life rules and any number of states. Requires Golly 2.0 and at least Python 2.4 although it might work with earlier versions also.
Edit:
Slight mod to make bilateral symmetry:
Code: Select all
# Quadsymm
# by knightlife -- Sept 2009
# Create quad symmetry using the current selection.
# Current selection becomes the top left quadrant of resulting pattern.
# based on invert.py script from golly 2.0
from glife import rect
from time import time
import golly as g
r = rect( g.getselrect() )
if r.empty: g.exit("There is no selection.")
oldsecs = time()
maxstate = g.numstates() - 1
for row in xrange(r.top, r.top + r.height):
# if large selection then give some indication of progress
newsecs = time()
if newsecs - oldsecs >= 1.0:
oldsecs = newsecs
g.update()
# also allow keyboard interaction
g.dokey( g.getkey() )
for col in xrange(r.left, r.left + r.width):
g.setcell(r.left + r.width + r.height - 1 - (row - r.top), r.top - r.width + r.height + (col - r.left), g.getcell(col, row))
g.setcell(r.left + 2*r.width - 1 - (col - r.left), r.top + 2*r.height - 1 - (row - r.top), g.getcell(col, row))
g.setcell(r.left + r.width - r.height + (row - r.top), r.top + r.width + r.height - 1 - (col - r.left), g.getcell(col, row))
if not r.visible(): g.fitsel()
Slight mod to make bilateral symmetry:
Code: Select all
# Bilatsymm
# by knightlife -- Sept 2009
# Create bilateral symmetry using the current selection.
# Current selection becomes the left half of resulting pattern.
# based on invert.py script from golly 2.0
from glife import rect
from time import time
import golly as g
r = rect( g.getselrect() )
if r.empty: g.exit("There is no selection.")
oldsecs = time()
maxstate = g.numstates() - 1
for row in xrange(r.top, r.top + r.height):
# if large selection then give some indication of progress
newsecs = time()
if newsecs - oldsecs >= 1.0:
oldsecs = newsecs
g.update()
# also allow keyboard interaction
g.dokey( g.getkey() )
for col in xrange(r.left, r.left + r.width):
g.setcell(r.left + 2*r.width - 1 - (col - r.left), r.top + (row - r.top), g.getcell(col, row))
if not r.visible(): g.fitsel()