Shading dark

I generated a 7-depth Penrose tiling last night. It took most of the night.

Axiom:
  [N]++[N]++[N]++[N]++[N]
Rules:
  M=OA++pA—-NA[-OA----MA]++;
  N=+OA–PA[---MA--NA]+;
  O=-MA++NA[+++OA++PA]-;
  P=–OA++++MA[+PA++++NA]–NA;
  A=
Angle:36

The tiled SVG’s generated by the L-System are prone to very high rates of duplicate elements. They’re also extremely slow and system intensive to process under Inkscape as the entire graph is rendered as a single bazillion-point object. Handling the performance problem is simple enough: Inkscape/Edit/Select_All and then break up the object with Inkscape/Path/Break_Apart. Ahh, much better.

Handling the duplicates is tougher. There are simple duplicate elements, PATH elements with identical attributes and vertices and there are path elements which are identical except that they list the vertices in a different order. The former are easy to remove. Just fold the raw XML document so that all PATH entries occupy but a single line, sort the PATH elements and then remove all duplicates. In my case I just extracted the PATH elements to an external text file, wrote a quick XEmacs macro to make each PATH element single-line and then did:

$ sort outfile.xml | uniq 

Voila! All identical PATH elements removed. This simplistic dupe-removal reduced the file size by approximately 30%.

I looked at removing the duplicate-vertex elements but found it too hard for a quick hack fix. In short I’d have to extract all the path elements and then the vertices for each element, sort them and then do duplicate removal. That was more than I was willing to be bothered with. However while wandering the data I noticed that there were many 7 vertex elements whose vertices precisely overlaid the vertexes of other elements (exception: a small few elements at the edge of the graph). With the exception of the ones at the edge of the graph, they were all redundant. Remove them:

$ grep -v "path.*M.*L.*L.*L.*L.*L.*L"  outfile.svg

While a plain white mesh is pleasantly clear, I had the idea of colouring the tiles to give a bit of a stereoscopic effect.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#! /usr/bin/env python
import sys

in_f = open (sys.argv[1], "r")
out_f = open (sys.argv[2], "w")
ndx = 0
for line in in_f:
  if ndx % 3 == 1:
    line = line.replace ('fill:none', 'fill:#999999')
  if ndx % 3 == 2:
    line = line.replace ('fill:none', 'fill:#cccccc')
  out_f.write (line)
  ndx += 1
in_f.close ()
out_f.close ()

The effect of which is to assign a fill colour to two thirds of the elements, a different colour for each third

Inkscape-LSystem-PenroseRender-Big-Coloured

I like it.