如何在Java中绘制一个三叶草?

huangapple go评论71阅读模式
英文:

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

你有两个选择:

  1. 为你的三叶草创建一个形状(Shape),并使用 Graphics2D.draw/.fill(Shape) 来绘制你的三叶草。你可能想要查看 geom.Area 类的相关内容。
  2. (推荐)找一个带有透明背景的三叶草图标的图片。

无论哪种情况,一旦你拥有了你的三叶草“图章”,只需要平移和旋转 Graphics2D,将你的图章粘贴到想要的位置。

英文:

You have two options:

  1. 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.
  2. (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.

huangapple
  • 本文由 发表于 2020年10月8日 23:32:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/64265862.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定