Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.postscript > #1842 > unrolled thread
| Started by | Cecil Westerhof <Cecil@decebal.nl> |
|---|---|
| First post | 2014-03-31 13:24 +0200 |
| Last post | 2014-03-31 14:47 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.postscript
How to give colour as parameter to ghostscript Cecil Westerhof <Cecil@decebal.nl> - 2014-03-31 13:24 +0200
Re: How to give colour as parameter to ghostscript ken <ken@spamcop.net> - 2014-03-31 14:00 +0100
Re: How to give colour as parameter to ghostscript Cecil Westerhof <Cecil@decebal.nl> - 2014-03-31 14:47 +0200
| From | Cecil Westerhof <Cecil@decebal.nl> |
|---|---|
| Date | 2014-03-31 13:24 +0200 |
| Subject | How to give colour as parameter to ghostscript |
| Message-ID | <87y4zqsj9a.fsf@Equus.Decebal.nl> |
I have defined the following:
/colors <<
.
.
.
/colorNavy { 0 0 0.5 }
/colorNavyBlue { 0.14 0.14 0.56 }
/colorNeonBlue { 0.3 0.3 1 }
.
.
.
/colorOrange { 1 0.5 0 } % coral
/colorOrangeRed { 1 0.14 0 }
.
.
.
/colorRed { 1 0 0 }
.
.
.
/colorWhite { 1 1 1 }
/colorYellow { 1 1 0 }
/colorYellowGreen { 0.6 0.8 0.2 }
>> def
colors begin
Normally I do something like the following:
/backgroundColor {colorYellow} def
But I want to give the colour as a parameter to ghostscript:
-sbackgroundColor=colorNavy
What do I need to do in the postscript script to get the right value
in backgroundColor?
--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
[toc] | [next] | [standalone]
| From | ken <ken@spamcop.net> |
|---|---|
| Date | 2014-03-31 14:00 +0100 |
| Message-ID | <MPG.2da3775c413c12ec9898be@usenet.plus.net> |
| In reply to | #1842 |
In article <87y4zqsj9a.fsf@Equus.Decebal.nl>, Cecil@decebal.nl says...
> Normally I do something like the following:
> /backgroundColor {colorYellow} def
>
> But I want to give the colour as a parameter to ghostscript:
> -sbackgroundColor=colorNavy
>
> What do I need to do in the postscript script to get the right value
> in backgroundColor?
Setting a variable on the command line like that simply defines it in
systemdict with the given value.
So you can retrieve the value from systemdict :
systemdict /backgroundColor known {
systemdict /backgroundColor get
} if
checks for the existence of the key 'backgroundColor' in systemdict, and
if it finds it, retrieves it. Note that -s implies that the value is a
PostScript string, you might find it more convenient to use -d which
will allow you to associate the key with a name rather than a string.
Eg -dbackgroundColor=/colorNavy
Then you can use the name as a key to look up your color dictionary:
systemdict /backgroundColor known {
systemdict /backgroundColor get
colors exch get setcolor
} if
However, none of these seem to be quite what you are after. You seem to
want to associate the name 'backgroundColor' with a packed array which
has the executable bit set. Basically you can't do that from the command
line.
Instead use -c and -f to send a small section of PostScript on the
command line, or use one of the preceding examples but change the name
of the parameter.
For example lets call the parameter 'SetBackgroundColor', and we'll set
it with -d. Your command line then becomes:
gs .... -dSetBackgroundColor=/navyColor ......
And in your PostScript file:
/colors <<
.
.
.
/colorNavy { 0 0 0.5 }
/colorNavyBlue { 0.14 0.14 0.56 }
/colorNeonBlue { 0.3 0.3 1 }
.
.
.
/colorOrange { 1 0.5 0 } % coral
/colorOrangeRed { 1 0.14 0 }
.
.
.
/colorRed { 1 0 0 }
.
.
.
/colorWhite { 1 1 1 }
/colorYellow { 1 1 0 }
/colorYellowGreen { 0.6 0.8 0.2 }
>> def
systemdict /SetBackgroundColor known {%% Check if name known
systemdict /SetBackgroundColor get %% get the object associated
%% with the name
colors exch get %% get the array from the dict
/backgroundColor exch def %% associate backgroundColo
%% with that array.
} { %% not set, choose a default
/backgroundColor colors /colorOrange get def
} ifelse
Ken
[toc] | [prev] | [next] | [standalone]
| From | Cecil Westerhof <Cecil@decebal.nl> |
|---|---|
| Date | 2014-03-31 14:47 +0200 |
| Message-ID | <87txaesffb.fsf@Equus.Decebal.nl> |
| In reply to | #1842 |
Op Monday 31 Mar 2014 13:24 CEST schreef Cecil Westerhof:
> I have defined the following:
> /colors <<
> .
> .
> .
> /colorNavy { 0 0 0.5 }
> /colorNavyBlue { 0.14 0.14 0.56 }
> /colorNeonBlue { 0.3 0.3 1 }
> .
> .
> .
> /colorOrange { 1 0.5 0 } % coral
> /colorOrangeRed { 1 0.14 0 }
> .
> .
> .
> /colorRed { 1 0 0 }
> .
> .
> .
> /colorWhite { 1 1 1 }
> /colorYellow { 1 1 0 }
> /colorYellowGreen { 0.6 0.8 0.2 }
>>> def
> colors begin
>
> Normally I do something like the following:
> /backgroundColor {colorYellow} def
>
> But I want to give the colour as a parameter to ghostscript:
> -sbackgroundColor=colorNavy
>
> What do I need to do in the postscript script to get the right value
> in backgroundColor?
Found it. I call the script with:
-sbackground=color" background
And in the script I use:
/backgroundColor {background cvx exec} def
--
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