Problems? Is your data what you think it is? | |
PerlMonks |
Hilbert + Dragon = Obfuby benizi (Hermit) |
on Dec 19, 2007 at 09:38 UTC ( [id://657837]=obfuscated: print w/replies, xml ) | Need Help?? |
The Hilbert DragonBy default, this adds PerlTk graphics to Hilbert Curve. But, as penance for irritating the math gods (Math >> XKCD, even in my book), this one allows you to input any L-system you want. Update: Forgot to explain that the obfu's pattern is in the (negative) shape of the Penrose dragon, but it makes the Hilbert curve by default. (hence "the Hilbert Dragon").
(See the readmore for TONS more.) UsageThere are parameters galore. Parameters are split on '=' signs. So, 'a=90' is the same as 'a 90'. L-system options: a DEG = angle increment in degrees default 90 m RAD = initial angle offset in radians default 0 i N = number of iterations default 5 Output options: t NNN = total pixels (= width = height) default if Tk: 511 default if terminal: 33 w N = width in pixels default = t h N = height in pixels default = t n 1 = no Tk (default is to use Tk if it's present) b 1 = bit output (only applicable if no Tk) bit output can be fed into ImageMagick L-system operators: S STR = start string (called 'axiom' in Fractint) + = rotate by 'a' degrees - = rotate by 'a' degrees in the opposite direction [ = push (save position and angle) ] = pop (restore position and angle) F = draw one unit forward M = move one unit forward (without drawing) any other characters = no drawing/movement operation, but used for substitution Default L-system: S L L +RF-LFL-FR+ R -LF+RFR+FL- See below for examples. FractintIf you've ever used Fractint, or want to try some Fractint L-systems that you find, there are some differences in format. My code doesn't do: empty substitutions Due to the way parameters are parsed, you should use something like: F N (where N is unused elsewhere) instead of: F= ('F' goes to '' empty) No D and G Use F and M instead. @ operator This is the biggest difference. It seems like it can't usually be avoided. So some Fractint systems are just off-limits to my program [currently...]. angles are specified differently Fractint angle 10 means 360/10 degrees = in mine: a=36 Fractint angle 6 means 360/6 degrees = in mine: a=60 | operator (just do it manually, by inserting multiple +'s or -'s) \NN, /NN (can sometimes work around by using a=small, and changing all other angles) anything with color (sorry, all smooth hue gradients here) Examples'bush'. Looks like a bush. perl this.pl S ++++F F FF-[-F+F+F]+[+F-F-F] a 22.5 i 4For a PNG of the same (requires ImageMagick's convert): perl this.pl S ++++F F FF-[-F+F+F]+[+F-F-F] a 22.5 i 4 t 515 n 1 b 1 | convert -depth 8 -size 515x515 rgb:- bush.png'cross' perl this.pl S FX X FX+FX+FXFY-FY- Y +FX+FXFY-FY-FY F NDekking church. (Only looks good with odd-numbered iterations) perl this.pl S WZYX F N W FW+F-XFW-F+Z X ++F--Y-F+Z++F--Y-F+Z Y ++F--Y+F-X Z FW+F-X i 5Hilbert II perl this.pl S X X=XFYFX+F+YFXFY-F-XFYFX Y=YFXFY-F-XFYFX+F+YFXFY i 3'hiway' (Penrose Dragon) perl this.pl S FX X FX+FY Y FX-FY F N i 9Penrose tiles perl this.pl S [7]++[7]++[7]++[7]++[7] 6 8F++9F----7F[-8F----6F]++ 7 +8F--9F[---6F--7F]+ 8 -6F++7F[+++8F++9F]- 9 --8F++++6F[+9F++++7F]--7F F N a=36'lace' perl this.pl a 30 S W W +++X--F--ZFX+ X ---W++F++YFW- Y +ZFX--F--Z+++ Z -YFW++F++Y--- i 6PNG/GIF/JPEG/whatever outputUsing ImageMagick, it's pretty easy to get files of any of these. Add to the end of the command: n 1 b 1 | convert -depth 8 -size ${t}x${t} rgb:- filename.typewhere the ${t}'s are whatever you specified for t=NNN (or 511, by default) SourcesThis wouldn't have been possible without several incredible sources:
Shameless plugI made a gallery of fractals that this program (plus ImageMagick) created. (Page also has some of the same background that this node has -- and I haven't yet given proper credit to the L-systems' "inventors"/"transcribers".)
Back to
Obfuscated Code
|
|