我正在尝试编写自定义函数的PDF shading使用类型1(基于函数)着色与FunctionType 4 (Postscript计算器)。以下是我尝试的基础:
...
5 0 obj
<<
/Type /Page
/Parent 1 0 R
/MediaBox [0 0 500 400]
/Resources << /Shading << /Sh1 8 0 R >> >>
/Contents 6 0 R
>>
endobj
6 0 obj %Contents
<<
/Length 37
>>
stream
2 J
0 200 200 200 re
q
W n %clip to 200x200 rectangle
/Sh1 sh %fill with shading
Q
endstream
endobj
7 0 obj %The function itself
<<
/FunctionType 4
/Domain [0 1 0 1]
/Range [0 1 0 1 0 1]
/Length 24
>>
stream
{
pop %pop parameters - I guess these are x, y coordinates (?)
pop
0.5 %half red , green, blue = gray
0.5
0.5
}
endstream
endobj
8 0 obj %The shading
<<
/ShadingType 1
/ColorSpace /DeviceRGB
/Function 7 0 R
>>
endobj
...我认为这应该会使正方形变得灰色。但结果是什么都没有-画布保持为空(在Adobe PDF阅读器中尝试)。
谁能告诉我我做错了什么?
或者--有人能提供一个这样的PDF的例子吗--带有自定义着色功能?我需要一些开始的东西。(稍后我想使用该函数为我的SWF到PDF转换器实现具有重复模式的径向着色)
我在互联网上没有找到任何与Shading Type 1相关的PDF示例。
发布于 2021-03-20 06:11:12
我现在发现了问题所在。
/FunctionType 4
/Domain [0 1 0 1]我将函数的域设置为0- 1,这会将坐标裁剪到最大值1。由于某些原因,我认为传入的坐标是0-1。
修改
/FunctionType 4
/Domain [0 1000 0 1000]适合我,矩形是灰色的。
https://stackoverflow.com/questions/66715628
复制相似问题