gpt4 book ai didi

java - Java Swing中的Graphics2D填充方法

转载 作者:行者123 更新时间:2023-11-29 04:24:36 24 4
gpt4 key购买 nike

我刚刚读到 Java 中的 fill 方法在右侧和底部绘制的像素少了一个。

例如,如果您绘制一个 new Rectangle2D.Double(0,0,10,20),则该绘图包含具有 x = 10y = 20。如果您填充同一个矩形,则不会绘制这些像素。

为什么这些方法在同一个对象上工作并执行相似的任务却返回不同的结果?有什么原因,还是只是一个错误?

最佳答案

Graphics API 解释了绘制 轮廓和填充 内部之间的区别:

Coordinates are infinitely thin and lie between the pixels of the output device. Operations that draw the outline of a figure operate by traversing an infinitely thin path between pixels with a pixel-sized pen that hangs down and to the right of the anchor point on the path. Operations that fill a figure operate by filling the interior of that infinitely thin path.

特别是,

If you draw a figure that covers a given rectangle, that figure occupies one extra row of pixels on the right and bottom edges as compared to filling a figure that is bounded by that same rectangle.

关于java - Java Swing中的Graphics2D填充方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47013485/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com