Ultimately this will be used in a web page (for shapes representing towns in different counties)
Interesting.
Many years ago, I developed Acme::EyeDrops -- which similarly had to solve the problem
of how to represent arbitrary shapes for use in ascii art.
If you look at Acme::EyeDrops Shape Reference,
you'll see it defines two kinds of shapes:
- Built-in shapes. An algorithm is used to generate these types of shapes, for example a Sierpinski triangle. (Note that A::E has precious few built-in shapes; ideas for new built-in shapes welcome).
- ".eye file" shapes. These shapes are defined by a (simply formatted) .eye file, for example, a map of italy.
Two simple examples to give you a feel for how this works.
Running this program:
use Acme::EyeDrops qw(sightly);
print sightly({ Text => 1,
TextFiller => '/\\',
Shape => 'siertri',
# For 'siertri' built-in shape, Width=>5 means:
# height is 2**5 lines
# width is 2 * 2**5 characters
Width => 5 });
displays:
/\
/\/\
/\ /\
/\/\/\/\
/\ /\
/\/\ /\/\
/\ /\ /\ /\
/\/\/\/\/\/\/\/\
/\ /\
/\/\ /\/\
/\ /\ /\ /\
/\/\/\/\ /\/\/\/\
/\ /\ /\ /\
/\/\ /\/\ /\/\ /\/\
/\ /\ /\ /\ /\ /\ /\ /\
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
/\ /\
/\/\ /\/\
/\ /\ /\ /\
/\/\/\/\ /\/\/\/\
/\ /\ /\ /\
/\/\ /\/\ /\/\ /\/\
/\ /\ /\ /\ /\ /\ /\ /\
/\/\/\/\/\/\/\/\ /\/\/\/\/\/\/\/\
/\ /\ /\ /\
/\/\ /\/\ /\/\ /\/\
/\ /\ /\ /\ /\ /\ /\ /\
/\/\/\/\ /\/\/\/\ /\/\/\/\ /\/\/\/\
/\ /\ /\ /\ /\ /\ /\ /\
/\/\ /\/\ /\/\ /\/\ /\/\ /\/\ /\/\ /\/\
/\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Running this program:
use Acme::EyeDrops qw(sightly);
print sightly({ Text => 1,
TextFiller => 'Azzurri',
Shape => 'map_italy' });
displays:
Azzurr
iAzzurriAzz
urriAzzurriAzzurr
iA zzurriAzzurriAzzurriAzz
urriAzzurriAzzurriAzzurriAzzur
riAzzurriAzzurriAzzurriAzzurriAzz
urriAzzurriAzzurriAzzurriAzzur
riAzzurriAzzurriAzzurriAzzurr
iAzzurriAzzurriAzzurriAzzurriA
zzurriAzzurriAzzurriAzzurriAzzu
rriAzzurriAzzurriAzzurriAzzurr
iAzzurr iAzzurriAzzurri
Azzu rriAzzurriAzzu
rr iAzzurriAzzurri
AzzurriAzzurriAzz
urriAzzurriAzzurr
iAzzurriAzzurriAzz
u rriAzzurriAzzurriA
zzur riAzzurriAzzurriA
zzurr iAzzurriAzzurriAz
zurri AzzurriAzzurriAzz
urriA zzurriAzzurriAzzurriA
zzu rriAzzurriAzzurriA
zzurriAzzurriAzzur
ri AzzurriAzzurriAzz
urriAzzu rriAzzurriAzzurriA
zzurriAz zurriAzzurriAzzurri
Azzurri AzzurriAzzu rriAz
zurriAz zurriAzz urr
iAzzurr iAzz ur
riAzzur riA
zzurriA zzurr
iAzz ur riAzz
ur riAzz
urri
Azzu
r ri Azzur
riAzzurriAzzurri Az
zurriAzzurriAzz
urriAzzurri
AzzurriA
zzurr
iAz
The primary purpose of Acme::EyeDrops is to auto-generate obfuscated,
working Perl code ... so its shape pouring capabilities are fairly primitive.
I'm just bringing it to your attention in case it gives you ideas for your current project,
or in case it generates ideas for enhancing the shape pouring capabilities
of Acme::EyeDrops.