Je souhaite transformer l'exemple ci-dessous en une figure utilisant des rectangles arrondis au lieu de rectangles normaux. Je sais qu'il existe des possibilités avec le cadre de découpage. Mais je ne sais pas vraiment comment ils s'appliqueraient à ma situation actuelle, car je n'utilise pas de fonction g2d.fillXXX() actuellement.Dessin Rectangle arrondi
L'image: example http://img827.imageshack.us/img827/6048/cardbackgroundcut.jpg
Le code:
private void createImage() {
bufferedImage = new BufferedImage(dimension.width, dimension.height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = (Graphics2D)bufferedImage.createGraphics();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
int colorRed = 128;
int colorGreen = 0;
int colorBlue = 128;
for (int x = 0; x < dimension.width; x++) {
for (int y = 0; y < dimension.height; y++) {
int dx = Math.min(x, dimension.width - x);
int dy = Math.min(y, dimension.height - y);
if (dx < 10 || dy < 10) {
g2d.setColor(new Color(colorRed, colorGreen, colorBlue, 255 - Math.min(dx, dy)));
g2d.drawLine(x, y, x, y);
}
else {
g2d.setColor(new Color(colorRed, colorGreen, colorBlue, 192 - Math.min(dx, dy)));
g2d.drawLine(x, y, x, y);
}
}
}
}
Donc, fondamentalement, je ne voudrais à la fois le bord extérieur et le bord intérieur de l'image ont un rectangle arrondi, tandis que preversing les changements de couleur .
Des indices sur la façon d'accomplir cela?
Cordialement.