在Android的刷哈奇风格风格、哈奇、Android

2023-09-06 21:48:22 作者:單身yě不寂寞

我需要帮助绘制斜线上粗帆布(斜线)的矩形。现在我不能找到比手动使其没有其他办法。任何想法?

I need help with drawing hatched rectangle on canvas (diagonal stroke). Now I cant find out no other way than make it manually. Any ideas?

推荐答案

您可以创建一个小的位图阴影图案,并使用了的 BitmapShader 。有一个在 ApiDemos /图形示例,名为 Pattern.java 将告诉您如何做到这一点。尽管如此,如果你只需要画一个矩形的阴影,这可能是更容易只是手动孵化那里。

You can create a hatching pattern on a small bitmap, and use that with a BitmapShader. There's a sample in ApiDemos/graphics, called Pattern.java that shows you how to do it. Although, if you only need to draw a hatched rectangle, it might be easier to just do the hatching there manually.