Java2D:填充凸圆角多边形(QuadCurves)
如果我有一个像这样的 QuadCurve (+
= node):
+ +
\ ./
+--⁻⁻
我用 Java 2D 填充它,结果是这样的: (x
= colored)
+xxxxxxxxx+
\xxxxxx./
+--⁻⁻
但我想为另一侧着色:
+ +
x\ ./x
xxx +--⁻⁻xx
xxxxxxxxxxx
通过以我想要为另一侧着色的颜色在曲线周围绘制一个矩形,然后用背景颜色填充曲线来成功。
但这还不足以填充凸圆形(基于 QuadCurves)多边形。如果矩形的某些坐标(如我使用的技巧中所解释的)与多边形的其他部分重叠。这里有两张图片(绿色区域是我的多边形):
alt text http://img204 .imageshack.us/img204/7823/convexpolygon.png 替代文本 http: //img708.imageshack.us/img708/3669/convexpolygon2.png
所以,问题很简单:“如何为曲线的形状构建着色?”
但我认为答案并不简单...
任何建议都将非常非常感激。
提前致谢。
如果我没有得到答案,也许我会为这个问题悬赏
If I have a QuadCurve like this (+
= node):
+ +
\ ./
+--⁻⁻
And I fill it in Java 2D the result is something like this: (x
= colored)
+xxxxxxxxx+
\xxxxxx./
+--⁻⁻
But I want to color the other side:
+ +
x\ ./x
xxx +--⁻⁻xx
xxxxxxxxxxx
This succeeds by drawing a rectangle around the curve in the color I want to color the other side and then fill the curve with the background color.
But this isn't good enough to fill a convex rounded (based on QuadCurves) polygon. In case of some coordinates for the rectangles (as explained in the trick I used) overlap other pieces of the polygon. Here are two images (the green area is my polygon):
alt text http://img204.imageshack.us/img204/7823/convexpolygon.png alt text http://img708.imageshack.us/img708/3669/convexpolygon2.png
So, the question is simple: "How can I color a shape build of curves?"
But to the answer will not be simple I think...
Any advice would be VERY VERY appreciated.
Thanks in advance.
Maybe I'm going to make a bounty for this question if I don't get an answer
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
选择一个已知位于多边形内部的点。
了解“边界颜色”(在本例中为黑色)。
您可以根据需要进行调整以满足您的特定需求。
这适用于完全有界形状的任何填充。您还需要合并特殊条件(例如图片的边缘)。
Pick a point known to be inside the Polygon.
Know the "boundary color" (in this case, black).
You can adapt this as necessary to suit your specific needs.
This works for any fill for a completely bounded shape. You'll also want to incorporate special conditions (edges of the picture, for example).