Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Polygon Creation -- Request for Algorithm Suggestions

by eyepopslikeamosquito (Bishop)
on Nov 27, 2017 at 03:14 UTC ( #1204307=note: print w/replies, xml ) Need Help??


in reply to Polygon Creation -- Request for Algorithm Suggestions

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1204307]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2020-10-26 14:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (251 votes). Check out past polls.

    Notices?