通过后记中的递归更改线条颜色
change line color by recursion in postscript
我想让我的图案有多种颜色。我的意思是我希望我的 DoLine
使每条时间线都具有相似但不同的颜色。所以我做了
/red 0.41 def
/green 0.1 def
/blue 0.21 def
/incRed {/red red 0.01 add} def
/incGreen {/green green 0.03 add} def
/incBlue {/blue blue 0.05 add} def
和我的DoLine
/DoLine
{
incRed
incGreen
incBlue
red green blue setrgbcolor
rotation rotate
0 linelen rlineto
currentpoint stroke
translate 0 0 moveto
} def
但它只输出一种颜色的模式,设置为
/red 0.41 def
/green 0.1 def
/blue 0.21 def
我错过了什么吗?如果你需要的话,这是我的所有代码
%!
/Helvetica findfont 8 scalefont setfont
/ang1 -141 def
/ang2 {-2 ang1 mul} def
/linelen 36 def
/depth 0 def
/down {/depth depth 1 add def} def
/up {/depth depth 1 sub def} def
/red 0.41 def
/green 0.1 def
/blue 0.21 def
/incRed {/red red 0.01 add} def
/incGreen {/green green 0.03 add} def
/incBlue {/blue blue 0.05 add} def
/CrownPos
{
/x 300 def
/y 300 def
x y moveto
} def
/DoLine
{
incRed
incGreen
incBlue
red green blue setrgbcolor
rotation rotate
0 linelen rlineto
currentpoint stroke
translate 0 0 moveto
} def
/Print
{
gsave
.62 .62 scale
2 setlinewidth
down DoLine
depth 8 le
{
ang1 rotate Print
ang2 rotate Print
} if
up
grestore
} def
/Crown
{
/rotation 0 def
CrownPos Print
stroke
/rotation 270 def
CrownPos Print
stroke
/rotation 90 def
CrownPos Print
stroke
} def
Crown
600 600 translate
180 rotate Crown
showpage
这些颜色递增例程有两个问题:1) 它们没有将新值重新设置到变量中(即缺少 def
)和 2) 它们递增得太快,太快达到白色.试试这些改版后的版本:
/incRed { /red red 0.0001 add def } def
/incGreen { /green green 0.0003 add def } def
/incBlue { /blue blue 0.0005 add def } def
我想让我的图案有多种颜色。我的意思是我希望我的 DoLine
使每条时间线都具有相似但不同的颜色。所以我做了
/red 0.41 def
/green 0.1 def
/blue 0.21 def
/incRed {/red red 0.01 add} def
/incGreen {/green green 0.03 add} def
/incBlue {/blue blue 0.05 add} def
和我的DoLine
/DoLine
{
incRed
incGreen
incBlue
red green blue setrgbcolor
rotation rotate
0 linelen rlineto
currentpoint stroke
translate 0 0 moveto
} def
但它只输出一种颜色的模式,设置为
/red 0.41 def
/green 0.1 def
/blue 0.21 def
我错过了什么吗?如果你需要的话,这是我的所有代码
%!
/Helvetica findfont 8 scalefont setfont
/ang1 -141 def
/ang2 {-2 ang1 mul} def
/linelen 36 def
/depth 0 def
/down {/depth depth 1 add def} def
/up {/depth depth 1 sub def} def
/red 0.41 def
/green 0.1 def
/blue 0.21 def
/incRed {/red red 0.01 add} def
/incGreen {/green green 0.03 add} def
/incBlue {/blue blue 0.05 add} def
/CrownPos
{
/x 300 def
/y 300 def
x y moveto
} def
/DoLine
{
incRed
incGreen
incBlue
red green blue setrgbcolor
rotation rotate
0 linelen rlineto
currentpoint stroke
translate 0 0 moveto
} def
/Print
{
gsave
.62 .62 scale
2 setlinewidth
down DoLine
depth 8 le
{
ang1 rotate Print
ang2 rotate Print
} if
up
grestore
} def
/Crown
{
/rotation 0 def
CrownPos Print
stroke
/rotation 270 def
CrownPos Print
stroke
/rotation 90 def
CrownPos Print
stroke
} def
Crown
600 600 translate
180 rotate Crown
showpage
这些颜色递增例程有两个问题:1) 它们没有将新值重新设置到变量中(即缺少 def
)和 2) 它们递增得太快,太快达到白色.试试这些改版后的版本:
/incRed { /red red 0.0001 add def } def
/incGreen { /green green 0.0003 add def } def
/incBlue { /blue blue 0.0005 add def } def