1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
BufferedImage haloImage = new BufferedImage(2*100,2*100,BufferedImage.TYPE_INT_ARGB);
Graphics2D haloGraphics = haloImage.createGraphics();
haloGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
float[] fractions = {0.7999f,0.8f,1f};
Color[] colors = {new Color(141,178,209),new Color(141,178,209,255),new Color(255,255,255,0)};
RadialGradientPaint paint = new RadialGradientPaint(2*50,2*50,2*45,fractions,colors);
haloGraphics.setPaint(paint);
haloGraphics.fill(new Rectangle2D.Double(0,0,haloImage.getWidth(),haloImage.getHeight()));
haloGraphics.setPaint(Color.BLUE);
haloGraphics.fill(new Ellipse2D.Double(2*15,2*15,2*70,2*70));
haloGraphics.dispose();
Kernel kernel = new Kernel(3, 3,
new float[] {
1f/9f, 1f/9f, 1f/9f,
1f/9f, 1f/9f, 1f/9f,
1f/9f, 1f/9f, 1f/9f});
BufferedImageOp op = new ConvolveOp(kernel);
haloImage = op.filter(haloImage, null);
return haloImage; |
Partager