尽管使用了“butt”和“miter”,为什么我的 Racket 笔会在两条线连接处绘制额外的像素?
Why does my Racket pen draw extra pixels where two lines join despite using 'butt and 'miter?
我正在制作两个正方形,如下图所示。One red and one blue square
黄色圆圈不是图像的一部分,但它显示了一些我认为不存在的像素。我没有计算机图形方面的经验,但根据我在文档中阅读的内容,这些像素不应该存在。是我有不切实际的期望还是我做错了什么来获得这些 'overflow' 像素,如上图中黄色圆圈所示?
这是生成框的代码。
#lang racket/gui
(define dc (new svg-dc%
[width 64]
[height 64]
[output "boxes.svg"]
[exists 'replace]))
(send dc start-doc "boxes.svg")
(send dc start-page)
(define old-brush (send dc get-brush))
(define old-pen (send dc get-pen))
(send dc set-brush
(new brush% [style 'solid]
[color "White"]))
(send dc set-pen
(new pen% [width 0]
[color "Black"]
[cap 'butt]
[join 'miter]))
(send dc set-pen old-pen)
(send dc set-brush old-brush)
(send dc set-pen
(new pen% [width 0]
[color "Black"]
[cap 'butt]
[join 'miter]))
(send dc set-brush
(new brush% [style 'solid]
[color "Red"]))
(define path (new dc-path%))
(send path move-to 0 0)
(send path line-to 10 0)
(send path line-to 10 10)
(send path line-to 0 10)
(send path close)
(send dc draw-path path 0 0)
(send dc set-pen old-pen)
(send dc set-brush old-brush)
(send dc set-pen
(new pen% [width 0]
[color "Black"]
[cap 'butt]
[join 'miter]))
(send dc set-brush
(new brush% [style 'solid]
[color "Blue"]))
(define path2 (new dc-path%))
(send path2 move-to 0 0)
(send path2 line-to 10 0)
(send path2 line-to 10 10)
(send path2 line-to 0 10)
(send path2 close)
(send dc draw-path path2 10 0)
(send dc set-pen old-pen)
(send dc set-brush old-brush)
(send dc end-page)
(send dc end-doc)
这只是一条评论,但我还需要更多 space。
注意事项:
anti aliasing - turn it of
smoothing - is the mode unsmoothed or aligned?
假设第一个像素具有对角 (0,0) 和 (1,1)。
如果没有对齐,您可以选择大小和
在 (0.5,0.5) 处画一个点,以免在像素外绘制。
如果事情一致,您需要相应地进行调整。
见set-smoothing
。
更新
据我所知,添加以下行:
(send dc set-smoothing 'aligned)
开头会解决问题。
我正在制作两个正方形,如下图所示。One red and one blue square
黄色圆圈不是图像的一部分,但它显示了一些我认为不存在的像素。我没有计算机图形方面的经验,但根据我在文档中阅读的内容,这些像素不应该存在。是我有不切实际的期望还是我做错了什么来获得这些 'overflow' 像素,如上图中黄色圆圈所示?
这是生成框的代码。
#lang racket/gui
(define dc (new svg-dc%
[width 64]
[height 64]
[output "boxes.svg"]
[exists 'replace]))
(send dc start-doc "boxes.svg")
(send dc start-page)
(define old-brush (send dc get-brush))
(define old-pen (send dc get-pen))
(send dc set-brush
(new brush% [style 'solid]
[color "White"]))
(send dc set-pen
(new pen% [width 0]
[color "Black"]
[cap 'butt]
[join 'miter]))
(send dc set-pen old-pen)
(send dc set-brush old-brush)
(send dc set-pen
(new pen% [width 0]
[color "Black"]
[cap 'butt]
[join 'miter]))
(send dc set-brush
(new brush% [style 'solid]
[color "Red"]))
(define path (new dc-path%))
(send path move-to 0 0)
(send path line-to 10 0)
(send path line-to 10 10)
(send path line-to 0 10)
(send path close)
(send dc draw-path path 0 0)
(send dc set-pen old-pen)
(send dc set-brush old-brush)
(send dc set-pen
(new pen% [width 0]
[color "Black"]
[cap 'butt]
[join 'miter]))
(send dc set-brush
(new brush% [style 'solid]
[color "Blue"]))
(define path2 (new dc-path%))
(send path2 move-to 0 0)
(send path2 line-to 10 0)
(send path2 line-to 10 10)
(send path2 line-to 0 10)
(send path2 close)
(send dc draw-path path2 10 0)
(send dc set-pen old-pen)
(send dc set-brush old-brush)
(send dc end-page)
(send dc end-doc)
这只是一条评论,但我还需要更多 space。
注意事项:
anti aliasing - turn it of
smoothing - is the mode unsmoothed or aligned?
假设第一个像素具有对角 (0,0) 和 (1,1)。 如果没有对齐,您可以选择大小和 在 (0.5,0.5) 处画一个点,以免在像素外绘制。
如果事情一致,您需要相应地进行调整。
见set-smoothing
。
更新
据我所知,添加以下行:
(send dc set-smoothing 'aligned)
开头会解决问题。