Bard Judith has asked for the wisdom of the Perl Monks concerning the following question:

Searching for a program I could run to combine certain words in a particular sequence, I stumbled across this page of yours:

http://www.perlmonks.org/?node_id=554374

Exactly what I'm looking for, with a particularly cross-media application :) Let me clarify; I'm an artist working on initial designs for an art diary. Since that involves over three hundred pages, I'd like to run all the possible (yup, logical left brain stuff here! I'm a rather geeky artist...) combinations of my chosen palette - background colour, accent colour, and focal point colour. I know nothing about Perl or any scripting language besides the most basic Basic, so if anyone finds this a fun project and wouldn't mind inputting twenty-one words, running the program and emailing/posting the results, I'd be most appreciative. In fact, I'd mail you a copy of the diary after publication!

Background: parchment, gold, tan, butter, ivory, cream, mushroom, grey, lavender, aqua, skyblue, mint, sage, pink, barnred

Accent: parchment, gold, tan, butter, ivory, cream, mushroom, grey, lavender, aqua, skyblue, mint, sage, pink, barnred, black, chocolate, burgundy, terracotta, turquoise, violet

Focal: black, chocolate, burgundy, terracotta, turquoise, violet

I don't know if there is a way to avoid duplicates (since the accents can be any combination) such as 'cream, violet, violet', but it's not vital. Ideally I'd get a printout in alphabetical order by Background first, then Accent, and finally the Focal variations. Yeah, I know there are a lot of possibilities - (21 x 20 x 19? Is that right?)

Anyone up for the challenge? Contact me on Facebook as Bard Judith, or email me at masterbard (at) poetic (dot) com. Thanks heaps!

Edit: g0n - formatting tags

Replies are listed 'Best First'.
Re: Colour Combinations - Interested?
by moklevat (Priest) on Dec 05, 2007 at 03:33 UTC
    Although I support the notion that you have to give code to get code, I've always wanted to be a patron of the arts.

    #!/usr/bin/perl use strict; use warnings; my @backgrounds = qw/aqua barnred butter cream gold grey ivory lavend +er mint mushroom parchment pink sage skyblue tan/; my @accents = qw/aqua barnred black burgundy butter chocolate cre +am gold grey ivory lavender mint mushroom parchment pink sage skyblue + tan terracotta turqouise violet/; my @focuses = qw/black burgundy chocolate terracotta turquoise vi +olet/; for my $background (@backgrounds) { for my $accent (@accents) { for my $focus (@focuses) { print "$background $accent $focus\n" unless $accent eq $focus; } } }
    I'll spare my fellow monks the 41k of output, but Bard Judith could have gotten it from my Scratch Pad for a limited time.
Re: Colour Combinations - Interested?
by Your Mother (Archbishop) on Dec 05, 2007 at 02:04 UTC

    Part of the problem with the problem is that *many* of the combinations will be stomach churning or illegible. Here is something you can test fly in the meanwhile.

Re: Colour Combinations - Interested?
by zentara (Cardinal) on Dec 05, 2007 at 15:39 UTC
    Update: slightly improved example

    This isn't the place for job offers, it's to get you to learn. Here is a Tk code snippet that gives you a quick start. One big problem, is that on X11, color names are defined in your rgb.txt file, which is usually in /usr/X11/lib/rgb.txt. My script below removed/changed your colors to accomodate the rgb.txt list. Now you can specify colors exactly like #ae55d916d916 , so you can use the Tk color selector widget, to get the exact rgb names for your colors like terracotta, etc.

    #!/usr/bin/perl use Tk; use strict; my $x=0; my $y=0; my @backgrounds = qw/lightsteelblue red grey20 gold grey ivory lavend +er green grey25 brown pink skyblue tan/; my @accents = qw/lightsteelblue red black darkred yellow chocolat +e grey25 gold grey ivory lavender green grey60 white pink brown skybl +ue tan violet/; my @focuses = qw/black darkred chocolate violet/; my %nums; my $count = 0; for my $background (@backgrounds) { for my $accent (@accents) { for my $focus (@focuses) { #print "$background $accent $focus\n" unless $accent eq $focus; $nums{$count} = [ $background, $accent, $focus] unless $accent e +q $focus; $count++; } } } #print keys %nums; my $mw=tkinit; $mw->minsize(qw(500 500)); $mw->fontCreate('big', -family=>'arial', -weight=>'bold', -size=>int(-18*18/14)); my $c = $mw->Scrolled('Canvas')->pack(-expand=>1,-fill=>'both'); $count = 0; for (0..scalar keys %nums) { my $item=$c->createRectangle($x-200,$y,$x+200,$y+25, -fill=> ${$nums{$_}}[0], -outline => ${$nums{$_}}[2], -width=> 5, ); my $text = $c->createText($x+10,$y+10, -anchor=>'center', -fill => ${$nums{$_}}[1], -text => ${$nums{$_}}[0].'-'.${$nums{$_}}[1].'-'.${$nums{$_}}[2 +], -font => 'big', ); $y+=40; } $c->configure(-scrollregion => [$c->bbox('all')] ); $mw->Button( -text => "Save", -command => [sub { $c->update; my @capture=(); my ($x0,$y0,$x1,$y1)=$c->bbox('all'); @capture=('-x'=>$x0,'-y'=>$y0,-height=>$y1-$y0,-width=>$x1-$x +0); $c -> postscript(-colormode=>'color', -file=>$0.'.ps', -rotate=>90, -width=>800, -height=>500, @capture); } ] )->pack; MainLoop;

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum