Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!rt.uk.eu.org!feed.xsnews.nl!border-2.ams.xsnews.nl!feeder.xennanews.com!feeder3!nf40.xennanews.com!not-for-mail From: Cecil Westerhof Newsgroups: comp.lang.postscript Subject: Re: Looping over all defined colours Organization: Decebal Computing References: <87pq3kl977.fsf@Compaq.site.inet> X-Homepage: http://www.decebal.nl/ Date: Sat, 17 Nov 2012 14:50:28 +0100 Message-ID: <873908e3tn.fsf@Compaq.site.inet> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:FrBnMsQh4Y+itPXTYYdDEdXDIRI= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@xennanews.com Lines: 300 NNTP-Posting-Host: 84.53.123.169 (84.53.123.169) NNTP-Posting-Date: Sat, 17 Nov 2012 14:59:12 +0100 Xref: csiph.com comp.lang.postscript:1055 Op zondag 11 nov 2012 11:34 CET schreef Cecil Westerhof: > Someone on this mailing-list showed met the simple way down to declare > a lot of colours at once. I wold like to do something with all those > colours. Is there a way to iterate the colours? > > /colors << > /colorBlack { 0 0 0 } > /colorBlue { 0 0 1 } > /colorCyan { 0 1 1 } % aqua > /colorFuchsia { 1 0 1 } > /colorGray { .5 .5 .5 } > /colorGreen { 0 .5 0 } > /colorIndigo { .31 0 .5 } > /colorLime { 0 1 0 } > /colorMaroon { .5 0 0 } > /colorNavy { 0 0 .5 } > /colorOlive { .5 .5 0 } > /colorOrange { 1 .56 0 } > /colorPurple { .5 0 .5 } > /colorRed { 1 0 0 } > /colorSilver { .75 .75 .75 } > /colorTeal { 0 .5 .5 } > /colorViolet { .94 .5 .94 } > /colorWhite { 1 1 1 } > /colorYellow { 1 1 0 } >>> def > colors begin I thought that it was perhaps a good idea to show my solution. It is not the best code (I am still learning to program in postscript) and I am using a library (but only for the creating of a font and centerString if I remember well). %!PS-Adobe-3.0 EPSF-3.0 %%BoundingBox: 0 0 595 842 /pageBottom 0 def /pageLeft 0 def /pageRight 595 def /pageTop 842 def #standard % Library init /authorFont 8 def /backgroundGray .9 def /usedFont /Bookman-ISOLatin1 findfont def % Program functions /displayColour { % r g b colour left bottom right top 5 dict begin /top exch def /right exch def /bottom exch def /left exch def /colour exch def colour right left sub 2 div left add top 10 add centerString left bottom right top rectangle gsave setrgbcolor fill grestore stroke end } def /displayRow { 10 bottom 85 top displayColour 110 bottom 185 top displayColour 210 bottom 285 top displayColour 310 bottom 385 top displayColour 410 bottom 485 top displayColour 510 bottom 585 top displayColour } def % Program init usedFont authorFont scalefont setfont colorWhite () colorWhite () colorWhite () colorWhite () colorWhite () colorYellowGreen (YellowGreen) colorYellow (Yellow) colorWhite (White) colorWheat (Wheat) colorVioletRed (VioletRed) colorViolet2 (Violet2) colorViolet (Violet) colorVeryLightGrey (VeryLightGrey) colorVeryDarkBrown (VeryDarkBrown) colorTurquoise (Turquoise) colorThistle (Thistle) colorTeal (Teal) colorTan (Tan) colorSummerSky (SummerSky) colorSteelBlue (SteelBlue) colorSpringGreen (SpringGreen) colorSpicyPink (SpicyPink) colorSlateBlue (SlateBlue) colorSkyBlue (SkyBlue) colorSilver (Silver) colorSienna (Sienna) colorSemiSweetChocolate (SemiSweetChocolate) colorSeaShell (SeaShell) colorSeaGreen (SeaGreen) colorScarlet (Scarlet) colorSalmon (Salmon) colorRichBlue (RichBlue) colorRed (Red) colorQuartz (Quartz) colorPurple (Purple) colorPlum (Plum) colorPink (Pink) colorPeachPuff (PeachPuff) colorPaleTurquoise (PaleTurquoise) colorPaleGreen (PaleGreen) colorOrchid (Orchid) colorOrangeRed (OrangeRed) colorOrange (Orange) colorOlive (Olive) colorOldGold (OldGold) colorNewTan (NewTan) colorNewMidnightBlue (NewMidnightBlue) colorNeonPink (NeonPink) colorNeonBlue (NeonBlue) colorNavyBlue (NavyBlue) colorNavy (Navy) colorMidnightBlue (MidnightBlue) colorMediumWood (MediumWood) colorMediumVioletRed (MediumVioletRed) colorMediumTurquoise (MediumTurquoise) colorMediumSpringGreen (MediumSpringGreen) colorMediumSlateBlue (MediumSlateBlue) colorMediumSeaGreen (MediumSeaGreen) colorMediumOrchid (MediumOrchid) colorMediumForestGreen (MediumForestGreen) colorMediumBlue (MediumBlue) colorMediumAquamarine (MediumAquamarine) colorMaroon2 (Maroon2) colorMaroon (Maroon) colorMandarianOrange (MandarianOrange) colorLimeGreen (LimeGreen) colorLime (Lime) colorLightSteelBlue (LightSteelBlue) colorLightGrey2 (LightGrey2) colorLightGrey (LightGrey) colorLightBlue (LightBlue) colorKhaki (Khaki) colorIndigo (Indigo) colorIndianRed (IndianRed) colorHunterGreen (HunterGreen) colorHoneydew (Honeydew) colorGreen (Green) colorGrey (Grey) colorGreenYellow (GreenYellow) colorGreenCopper (GreenCopper) colorGreen (Green) colorGoldenrod (Goldenrod) colorGold (Gold) colorFuchsia (Fuchsia) colorForestGreen (ForestGreen) colorFirebrick (Firebrick) colorFeldspar (Feldspar) colorFuchsia (Fuchsia) colorDustyRose (DustyRose) colorDimGrey (DimGrey) colorDarkWood (DarkWood) colorDarkTurquoise (DarkTurquoise) colorDarkTan (DarkTan) colorDarkSlateGrey (DarkSlateGrey) colorDarkSlateBlue (DarkSlateBlue) colorDarkPurple (DarkPurple) colorDarkOrchid (DarkOrchid) colorDarkOliveGreen (DarkOliveGreen) colorDarkGreenCopper (DarkGreenCopper) colorDarkGreen (DarkGreen) colorDarkBrown (DarkBrown) colorCyan (Cyan) colorCornFlowerBlue (CornFlowerBlue) colorCoral (Coral) colorCopper (Copper) colorCoolCopper (CoolCopper) colorCadetBlue (CadetBlue) colorBronzeII (BronzeII) colorBronze (Bronze) colorBrown (Brown) colorBrightGold (BrightGold) colorBrass (Brass) colorBlueViolet (BlueViolet) colorBlue (Blue) colorBlack (Black) colorBakersChocolate (BakersChocolate) colorBeige (Beige) colorAzure (Azure) colorAliceblue (Aliceblue) colorAquamarine (Aquamarine) % Program .9 grayBackground /bottom 800 def /top 825 def displayRow /bottom 750 def /top 775 def displayRow /bottom 700 def /top 725 def displayRow /bottom 650 def /top 675 def displayRow /bottom 600 def /top 625 def displayRow /bottom 550 def /top 575 def displayRow /bottom 500 def /top 525 def displayRow /bottom 450 def /top 475 def displayRow /bottom 400 def /top 425 def displayRow /bottom 350 def /top 375 def displayRow /bottom 300 def /top 325 def displayRow /bottom 250 def /top 275 def displayRow /bottom 200 def /top 225 def displayRow /bottom 150 def /top 175 def displayRow /bottom 100 def /top 125 def displayRow /bottom 50 def /top 75 def displayRow showpage .9 grayBackground /bottom 800 def /top 825 def displayRow /bottom 750 def /top 775 def displayRow /bottom 700 def /top 725 def displayRow /bottom 650 def /top 675 def displayRow showpage -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof