绘制虚线边框

发布于 2024-08-04 00:20:13 字数 363 浏览 1 评论 0原文

想象一下您正在绘制一张县边界地图。给您一组多边形,每个边界一个多边形,然后您绘制每个多边形。

在两个县共享边界的地方,您最终只需绘制两次边界即可。在没有部分透明效果并且使用实心笔的情况下,这没有问题。

但是,在地图上,这种边界通常用点划线表示。在这种情况下,可能会发生如下所示的情况:

alt text

请注意破折号图案(通常为破折号)的方式:点点,在两个区域共享边界的地方搞砸了。在这种情况下,它碰巧变成了长划线点图案,但总的来说,它可以做任何事情,从巧合地看起来正常到创建实线。

地图渲染软件如何/应该如何防止此类伪影的发生?

Imagine you are drawing a map of county borders. You are given a set of polygons, one for each boundary, and you draw each polygon.

In places where two counties share a border you just end up drawing the border twice. In the absence of partial transparency effects, and with a solid pen, this is no problem.

But, on maps, borders of this kind are customarily shown by dash-dotted lines. In this case, situations like the one depicted below can happen:

alt text

Notice how the dash pattern, which normally is dash-dot-dot, gets screwed up where the two areas share a border. In this case, it happened to become a longdash-dot pattern, but in general it could do anything from coincidentally looking normal to creating a solid line.

How does/should map rendering software prevent artifacts of this kind from occuring?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

惟欲睡 2024-08-11 00:20:13

该伪像是由于该边界被绘制了两次而造成的。您可以尝试不绘制边界部分两次,而不是试图抑制此类伪影,方法是在内存中保留已绘制的段列表,并且如果遇到已经绘制的拉伸,则不会再次绘制它。

The artifact is due the fact that the piece of border is drawn twice. Instead of trying to supress such artifacts, you could try to not draw border sections twice, by keeping a list of segments already drawn in memory, and if you encounter a stretch that's already drawn, you don't draw it again.

天赋异禀 2024-08-11 00:20:13

您的画笔图案将某些像素着色为黑色,并保留某些像素。您可以设置画笔图案将这些像素涂成白色(或任何背景颜色),而不是单独留下像素吗?

另一种可能性是始终绘制两次县边界 - 一次使用纯白色图案,另一次使用您选择的画笔图案。

Your brush pattern colors some pixels black and leaves some pixels alone. Instead of leaving the pixel alone, can you set up your brush pattern to color those pixels white (or whatever your background color is)?

Another possibility is to always draw your county borders twice -- once with a solid white pattern, and again with the brush pattern of your choice.

好菇凉咱不稀罕他 2024-08-11 00:20:13

我想他们将边界线分成几段,然后删除重叠部分。

这主要是一个几何问题,而不是绘图问题。

I suppose they break their border lines into segments, then remove the overlaps.

This is mostly a geometric problem, not a drawing problem.

扬花落满肩 2024-08-11 00:20:13

您可以使用 Zip-a-tone 风格,而不是使用虚线,如下所示:

“alt

Zip-a-tone 是一种图形艺术的东西,基本上是一张粘性塑料片,上面有规则的(可打印的)点图案。要使用它,您可以将一大张它放在您的绘图上,然后将其切割在绘图上您想要拉链色调的区域周围,然后剥掉您不需要的部分。

对于这张图像,我只是使用了交替的棋盘图案,线条宽度为两个像素。因为所有线条都是从该棋盘图案的一个大(虚拟)块中绘制的,所以您永远不必担心接头处的奇怪伪影或任何重叠效果。

成角度的线有点棘手,但基本上你想象线的边缘有点穿过像素,因此你以适当的等级阴影而不是全黑绘制它们(在此处的 45 度线的情况下,像素使用 RGB(170, 170, 170) 绘制,但任何角度都可以使用适当的阴影进行渲染)。

我不确定 GDI+ 是否可以使用纹理画笔轻松完成此操作,但也许吧。否则你就必须对其进行自定义编码。与纯灰色实线相比,此方法的优点在于,这可以让一些背景显示出来。

Instead of going with a dashed line, you could do it Zip-a-tone style, like this:

alt text

Zip-a-tone was this graphic art stuff that was basically a sticky sheet of plastic with a regular (printable) pattern of dots on it. To use it, you would lay a big sheet of it over your drawing and cut it around the areas on your drawing that you wanted zip-a-toned, and then peel off the parts you didn't want.

For this image, I just went with an alternating checkerboard pattern, with the lines two pixels wide. Because all the lines are drawn from one big (virtual) block of this checkerboard pattern, you never have to worry about weird artifacts at the joints or any overlap effects.

Angled lines are a bit tricky, but basically you imagine the edges of the line sort of cutting through pixels, and thus you draw them at the appropriate shade of grade instead of full black (in the case of the 45 degree line here, the pixels are drawn with RGB(170, 170, 170), but any angle could be rendered with appropriate shades).

I'm not sure if GDI+ could do this easily using the textured brushes, but maybe. Otherwise you'd have to custom-code it. The advantage of this method over just solid gray lines would be that this would allow some of the background to show through.

沙与沫 2024-08-11 00:20:13

这是一个有趣的问题,我从未真正思考过。我认为唯一真正的解决方案是将整个复杂图形渲染为一系列不重叠的线条或路径。我对 GDI+ 不以任何自动方式处理这种情况并不感到惊讶。

This is an interesting question that I never really thought about. I think the only real solution is to render the entire complex figure as a series of lines or paths that do not overlap anywhere. I'm not surprised that GDI+ doesn't handle this situation in any automatic way.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文