File: import.py

package info (click to toggle)
golly 2.3-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 10,080 kB
  • sloc: cpp: 41,951; python: 6,339; sh: 3,912; perl: 1,172; java: 49; makefile: 47
file content (16 lines) | stat: -rw-r--r-- 497 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Change the selected area from N states to emulated-Margolus states:
# s -> 1+2s (if in the top-left of the partition)
# s -> 2+2s (if not)

from glife import rect
import golly as g

r = rect( g.getselrect() )
if r.empty: g.exit("There is no selection.")

for row in xrange(r.top, r.top + r.height):
   for col in xrange(r.left, r.left + r.width):
      if (col%2) and (row%2):
         g.setcell(col, row, 1+g.getcell(col,row)*2)
      else:
         g.setcell(col, row, 2+g.getcell(col,row)*2)