Page 1 of 1

Golly question

Posted: October 12th, 2014, 9:03 am
by HartmutHolzwart
How do I save a pattern in #P fromat instead of .rle or .mc?

Re: Golly question

Posted: October 12th, 2014, 11:10 am
by dvgrn
HartmutHolzwart wrote:How do I save a pattern in #P fromat instead of .rle or .mc?
It's not one of Golly's native output formats, so you'll have to write a script to do it.

It could be a fairly short script, depending on what you want. I can write an inefficient version in a few minutes:

copy-in-#P-format.py:

Code: Select all

import golly as g

r=g.getselrect()
if r==[]: g.exit("No pattern selected.")
if len(g.getcells(r))%2: g.note("States above 1 will be reduced to 1.")
out="#P "+str(r[0])+","+str(r[1])+"\n"
for y in range(r[1],r[1]+r[3]):
  for x in range(r[0],r[0]+r[2]):
    out += "." if g.getcell(x,y)==0 else "*"
  out+="\n"
g.setclipstr(out)
This is designed to copy a pattern to the clipboard rather than saving it, but it's easy to adjust that. It will produce a big rectangle with an unnecessary number of trailing periods, but that's also easy to fix.

Maybe the right way to do it would be to break up the pattern into non-overlapping small rectangles, and save each one separately, to keep the pattern size reasonable for large objects. Would that be useful to you, or no?

Re: Golly question

Posted: October 12th, 2014, 11:23 am
by HartmutHolzwart
It's meant to produce input files for gencols only. So just small files...