无当前点异常 PostScript
nocurrentpoint exception PostScript
我开发了一个函数来在 postscript 中制作一个简单的复选框,但它似乎仍然不起作用。
生成矩形没有问题,但是在写行的时候好像会抛出异常(使checkbox的经典X)。
/nocurrentpoint in --nocurrentpoint--
这是我的代码。
/doMarkedCheckBox {
0.1 setlinewidth
currentpoint
/yIniChk exch def
/xIniChk exch def
xIniChk
yIniChk
DimChars
DimChars
rectstroke
xIniChk DimChars add yIniChk DimChars add lineto
0 DimChars 0 sub moveto
yIniChk DimChars add xIniChk lineto
stroke
} bind def
有人可以解释一下如何正确地做到这一点吗?
提前致谢。
这正是问题所在 - 在 rectstroke
调用之后您关闭了路径并且没有起点。
您可以再次移动到那里,将值放在堆栈上并发出 moveto
- 代码似乎至少有一个错误来生成检查的另一部分 - 并且,由于您已经在 DimChars
中设置了 squaresize,因此在这些问题中使用 rlineto
可能更容易。
总而言之,如果您按以下顺序替换 rectstroke
之后的说明,您应该会很好:
...
xInitChk YInitChk moveto
DimChars DimChars rlineto
stroke
XInitChk YInitChk DimChars add moveto
DimChars DimChars neg rlineto
stroke
} bind def
我开发了一个函数来在 postscript 中制作一个简单的复选框,但它似乎仍然不起作用。 生成矩形没有问题,但是在写行的时候好像会抛出异常(使checkbox的经典X)。
/nocurrentpoint in --nocurrentpoint--
这是我的代码。
/doMarkedCheckBox {
0.1 setlinewidth
currentpoint
/yIniChk exch def
/xIniChk exch def
xIniChk
yIniChk
DimChars
DimChars
rectstroke
xIniChk DimChars add yIniChk DimChars add lineto
0 DimChars 0 sub moveto
yIniChk DimChars add xIniChk lineto
stroke
} bind def
有人可以解释一下如何正确地做到这一点吗? 提前致谢。
这正是问题所在 - 在 rectstroke
调用之后您关闭了路径并且没有起点。
您可以再次移动到那里,将值放在堆栈上并发出 moveto
- 代码似乎至少有一个错误来生成检查的另一部分 - 并且,由于您已经在 DimChars
中设置了 squaresize,因此在这些问题中使用 rlineto
可能更容易。
总而言之,如果您按以下顺序替换 rectstroke
之后的说明,您应该会很好:
...
xInitChk YInitChk moveto
DimChars DimChars rlineto
stroke
XInitChk YInitChk DimChars add moveto
DimChars DimChars neg rlineto
stroke
} bind def