Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #1035 > unrolled thread

Looping over all defined colours

Started byCecil Westerhof <Cecil@decebal.nl>
First post2012-11-11 11:34 +0100
Last post2012-11-17 14:50 +0100
Articles 3 — 2 participants

Back to article view | Back to comp.lang.postscript


Contents

  Looping over all defined colours Cecil Westerhof <Cecil@decebal.nl> - 2012-11-11 11:34 +0100
    Re: Looping over all defined colours Don Lancaster <don@tinaja.com> - 2012-11-11 09:52 -0800
    Re: Looping over all defined colours Cecil Westerhof <Cecil@decebal.nl> - 2012-11-17 14:50 +0100

#1035 — Looping over all defined colours

FromCecil Westerhof <Cecil@decebal.nl>
Date2012-11-11 11:34 +0100
SubjectLooping over all defined colours
Message-ID<87pq3kl977.fsf@Compaq.site.inet>
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

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

[toc] | [next] | [standalone]


#1037

FromDon Lancaster <don@tinaja.com>
Date2012-11-11 09:52 -0800
Message-ID<aga3evF1806U1@mid.individual.net>
In reply to#1035
On 11/11/2012 2:34 AM, Cecil Westerhof wrote:
> 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
>


See the many examples on our website.

works for url's; modify for colors...

<< /name1 {data1} name2 {data2}... >>
{mark exch /eurl cvx ] cvx def} forall





-- 
Many thanks,

Don Lancaster                          voice phone: (928)428-4073
Synergetics   3860 West First Street   Box 809 Thatcher, AZ 85552
rss: http://www.tinaja.com/whtnu.xml   email: don@tinaja.com

Please visit my GURU's LAIR web site at http://www.tinaja.com

[toc] | [prev] | [next] | [standalone]


#1055

FromCecil Westerhof <Cecil@decebal.nl>
Date2012-11-17 14:50 +0100
Message-ID<873908e3tn.fsf@Compaq.site.inet>
In reply to#1035
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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.postscript


csiph-web