英文:
How can I paint a clover in Java?
问题
我只想知道是否有人知道如何在Java中使用Java Swing和Java AWT绘制一个四叶草。我只知道如何使用fillRect()或drawRect()以及其他内置的Java方法来绘制形状。然而,我不知道如何制作看起来像四叶草叶子或茎的形状。如果有人知道如何在Java中使用swing和awt绘制一个,请告诉我,谢谢。
英文:
I just wanted to know if anyone knows how to paint a four-leaf clover in java, using java swing and java awt. I only know how to do fillRect() or drawRec() and other built-in java methods. However, I don't know how to make shapes that look like the leaves in the clover or the stem. If anyone knows how to draw or paint one in java using swing and awt, please let me know, and thanks.
答案1
得分: 1
你有两个选择:
- 为你的三叶草创建一个形状(Shape),并使用 Graphics2D.draw/.fill(Shape) 来绘制你的三叶草。你可能想要查看 geom.Area 类的相关内容。
- (推荐)找一个带有透明背景的三叶草图标的图片。
无论哪种情况,一旦你拥有了你的三叶草“图章”,只需要平移和旋转 Graphics2D,将你的图章粘贴到想要的位置。
英文:
You have two options:
- Create a Shape for your clover and use Graphics2D.draw/.fill(Shape) to draw your clovers. You might want to check out the geom.Area class for this.
- (Recommended) Find an image of a clover icon with a transparent background
In either case, once you have your clover "stamp", it is just a matter of translating and rotating the graphics2D to paste your stamp where you want it.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论