2017-01-23 20 views
2

我开发了一个功能,使在后记一个简单的复选框,但仍似乎无法工作。 有产生矩形没有问题,但似乎线路(使复选框的经典X)的写作过程中抛出一个异常。nocurrentpoint例外的PostScript

/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 

有人可以解释如何正确地做到这一点吗? 在此先感谢。

+0

这是一个过程定义,你在哪里调用过程?当前点(或任何其他设置当前点的命令)执行'moveto'时,'currentpoint'仅有效。在你自己设置一个之前没有现在的问题。 (翻译或其他转换不会设置当前点) –

回答

3

这正是问题 - 后rectstroke叫你关闭路径,并留下没有起点。

您可以再次移动到那里,将值放在堆栈上并发出moveto - 在生成检查的其他部分的代码中似乎至少有一个错误 - 并且,由于您具有四舍五入在DimChars已经,可能更容易在这些问题用rlineto

总而言之,如果按这个顺序更换rectstroke后您的指示,你应该是不错的:

... 
    xInitChk YInitChk moveto 
    DimChars DimChars rlineto 
    stroke 
    XInitChk YInitChk DimChars add moveto 
    DimChars DimChars neg rlineto 
    stroke 
} bind def