$_='my($w,$h,$x,$y,$z,$b,$v,$q,@s,@u,@a,@d)=(200,350,1,0,1,32000,chr(3
+9),65521,"
2582500861661521092082371081121531251811863301540361932582502020800771
+0624914813
6182133125230167124168161144241159090126154180197177188164129112226165
+1041421741
5419817714816414713424715507812817116320815809016217615419418718021414
+7111233224
172120142189","1734941700001632042184103200220081061764941740001632042
+2541031202
2011103213411176080051105147303310216047160213390060134162067278329162
+1141621443
1429918612011712529031715009015116230328116813214712729031729412603409
+7");map{@d
=map$_-144,/.{3}/g;while(my($a,$b,$c,$d,$e,$f)=splice@d,0,6){for(my$t=
+0;$t<=1;$t
+=.005){$u[$b+$t*($f*$t+$d)][$a+$t*($e*$t+$c)]=$z}}$z++}@s;sub{while(m
+y$n=pop){$
u[$n/$w][$n%$w]&&next;$u[$n/$w][$n%$w]=$z;push@_,$n+1,$n-1,$n-$w,$n<$w
+*$h?$n+$w:
$n}$z<5&&$z++}->(10*$_)for(1228,550,4005,2816,6943);$h+=10;for(1..$h){
+@d=(1,@{$u
[$_]||[]});push@a,map{$y=($y+($x=($x+($z=($d[$_]||1)-1))%$q))%$q;$z}0.
+.$w}@u=@a;
$h=pack"N2C5",$w,$h,8,3;$w="x\1";while($z=@d=splice@u,0,$b){$w.=pack"C
+SSC*",!!($
b-$z),$z,~$z,@d};$w.=pack"N",$x+($y<<16);for$b(0..255){$b=(($b&1)*0xED
+B88320)^($
b>>1)for 0..7;push@u,$b}open(F,">rose.png");binmode F;print F pack("H*
+","89504e4
70d0a1a0a");print F pack("N",-4+length).$_.pack"N",sub{$w=$h=0xFFFFFFF
+F;$w=$u[($
w^$_)&0xff]^($w>>8)for unpack"C*",$_;$w^$h}->()for"IHDR$h",pack("H38",
+"504c54450
00000003000b200006f0000004"),"tEXtComment\0".join($/,unpack("(a80)*","
+\$_=$v$_$v
;s#\$/##g;eval")),"IDAT$w","IEND"';s#$/##g;eval
(generates rose.png)
Updated to work in 5.8 & golfed some
It's pure perl, string/warnings compliant, and has been tested on 5.8.8 and 5.12.4 and on windows, ubuntu & centos, so i'm fairly confident it works everywhere - let me know if it doesn't
References
- Drawing: I can't draw, so I copied
this
(I may post the Tk spline based tracing program I wrote later :) )
- Splines:
- Flood fill
- PNG:
What's missing?
- thorns
-
I might try and include BooK's encoder to actually produce compressed png's (without too much trouble)
-
I'd like to add some sort of anti-aliasing or more likely hq3x
- It would be interesting to complete the png generation by adding filtering