/**
* Creates a new {@code Paint} that is a checkered effect using the specified colors.
* <p>
* While this method supports transparent colors, this implementation performs painting
* operations using the second color after it performs operations using the first color. This
* means that to create a checkered paint with a fully-transparent color, you MUST specify that
* color first.
*
* @param c1
* the first color
* @param c2
* the second color
* @param size
* the size of the paint
* @return a new {@code Paint} checkering the supplied colors
*/
public static Paint getCheckerPaint(Paint c1, Paint c2, int size) {
BufferedImage img = GraphicsUtilities.createCompatibleTranslucentImage(size, size);
Graphics2D g = img.createGraphics();
try {
g.setPaint(c1);
g.fillRect(0, 0, size, size);
g.setPaint(c2);
g.fillRect(0, 0, size / 2, size / 2);
g.fillRect(size / 2, size / 2, size / 2, size / 2);
} finally {
g.dispose();
}
return new TexturePaint(img,new Rectangle(0,0,size,size));
}
PaintUtils.java 文件源码
java
阅读 22
收藏 0
点赞 0
评论 0
项目:swingx
作者:
评论列表
文章目录