File: import.py

package info (click to toggle)
golly 2.1-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 9,560 kB
  • ctags: 5,064
  • sloc: cpp: 38,119; python: 3,203; perl: 1,121; makefile: 58; java: 49; sh: 22
file content (18 lines) | stat: -rw-r--r-- 500 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Change the selected area from N states to simulated-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)