How to “trap” my surface patches to prevent the background from bleeding through the cracks?

随声附和 提交于 2019-12-02 09:14:47

Alright, I've come up with something that sits a little easier in the gut.

6% fudging just feels to horrible to bear.

But Ken suggested that rounding could be involved. That means taking control of the rounding should gain one some measure of control over the problem. And it looks like it's true.

So I tried prepending all moveto and lineto calls with a call to prep:

/prep {
    transform
    %2 {
    %    exch
        %floor
        round
        %ceiling
        %2 mul cvi 2 div %round
    %} repeat
    itransform
} def

The comments show the various pieces I tried. Rounding on both device coordinates eliminated all horizontal bleed-lines and leaves very thin vertical bleeds. This seems to make sense assuming Ghostscript rasterizes by horizontal scanlines: it has an easier time with the horizontal ones with just a little help, but near-verticals are tougher.

But then I combined this with fudging. And I found that rounding just the device-y 'ordinate and fudging the patch dimensions by 2% eliminates all bleeds. It really lit up this batcave.

2% is an acceptable level of fudging, I think. (?)


Unfortunately, all the above requires tweaking when you adjust the value of N (the number of slices). The simplest fix to cover the whole surface is to stroke the edges in the same color as the fill. The only difficult point here is making sure the linewidth is appropriate for the scale. And the easy way to do that is to set them both together. For very high resolutions, this should probably be adjusted in some way to account for N.

1 70 dup dup scale div setlinewidth

Here's one of the images generated by the final program, a Steinmetz solid with coordinate axes and random colors, in a slightly skewed perspective (its right foot sticks out a little).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!