use of java.awt.RadialGradientPaint in project jdk8u_jdk by JetBrains.
the class RadialGradientPrintingTest method doPaint.
public void doPaint(Graphics2D g2d) {
g2d.translate(DIM * 0.2, DIM * 0.2);
Shape s = new Rectangle2D.Float(0, 0, DIM * 2, DIM * 2);
// RadialGradientPaint
Point2D centre = new Point2D.Float(DIM / 2.0f, DIM / 2.0f);
float radius = DIM / 2.0f;
Point2D focus = new Point2D.Float(DIM / 3.0f, DIM / 3.0f);
float[] stops = { 0.0f, 1.0f };
Color[] colors = { Color.red, Color.white };
RadialGradientPaint rgp = new RadialGradientPaint(centre, radius, focus, stops, colors, RadialGradientPaint.CycleMethod.NO_CYCLE);
g2d.setPaint(rgp);
g2d.fill(s);
g2d.translate(DIM * 2.2, 0);
Color[] colors1 = { Color.red, Color.blue, Color.green };
float[] stops1 = { 0.0f, 0.5f, 1.0f };
RadialGradientPaint rgp1 = new RadialGradientPaint(centre, radius, focus, stops1, colors1, RadialGradientPaint.CycleMethod.REFLECT);
g2d.setPaint(rgp1);
g2d.fill(s);
g2d.translate(-DIM * 2.2, DIM * 2.2);
Color[] colors2 = { Color.red, Color.blue, Color.green, Color.white };
float[] stops2 = { 0.0f, 0.3f, 0.6f, 1.0f };
RadialGradientPaint rgp2 = new RadialGradientPaint(centre, radius, focus, stops2, colors2, RadialGradientPaint.CycleMethod.REPEAT);
g2d.setPaint(rgp2);
g2d.fill(s);
}
use of java.awt.RadialGradientPaint in project jdk8u_jdk by JetBrains.
the class MlibOpsTest method createSrcImage.
private static BufferedImage createSrcImage() {
BufferedImage img = createImage();
Graphics2D g = img.createGraphics();
Color[] colors = { Color.red, Color.green, Color.blue };
float[] dist = { 0.0f, 0.5f, 1.0f };
Point2D center = new Point2D.Float(0.5f * w, 0.5f * h);
RadialGradientPaint p = new RadialGradientPaint(center, 0.5f * w, dist, colors);
g.setPaint(p);
g.fillRect(0, 0, w, h);
g.dispose();
return img;
}
use of java.awt.RadialGradientPaint in project jdk8u_jdk by JetBrains.
the class WritingInterruptionTest method createTestImage.
private static BufferedImage createTestImage() {
int w = 1024;
int h = 768;
BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
Graphics2D g = img.createGraphics();
Color[] colors = { Color.red, Color.green, Color.blue };
float[] dist = { 0.0f, 0.5f, 1.0f };
Point2D center = new Point2D.Float(0.5f * w, 0.5f * h);
RadialGradientPaint p = new RadialGradientPaint(center, 0.5f * w, dist, colors);
g.setPaint(p);
g.fillRect(0, 0, w, h);
g.dispose();
return img;
}
use of java.awt.RadialGradientPaint in project poi by apache.
the class DrawPaint method createRadialGradientPaint.
protected Paint createRadialGradientPaint(GradientPaint fill, Graphics2D graphics) {
Rectangle2D anchor = DrawShape.getAnchor(graphics, shape);
Point2D pCenter = new Point2D.Double(anchor.getX() + anchor.getWidth() / 2, anchor.getY() + anchor.getHeight() / 2);
float radius = (float) Math.max(anchor.getWidth(), anchor.getHeight());
float[] fractions = fill.getGradientFractions();
Color[] colors = new Color[fractions.length];
int i = 0;
for (ColorStyle fc : fill.getGradientColors()) {
colors[i++] = applyColorTransform(fc);
}
return new RadialGradientPaint(pCenter, radius, fractions, colors);
}
use of java.awt.RadialGradientPaint in project playn by threerings.
the class JavaGradient method createRadial.
static JavaGradient createRadial(float x, float y, float r, float[] positions, int[] colors) {
Point2D.Float center = new Point2D.Float(x, y);
RadialGradientPaint p = new RadialGradientPaint(center, r, positions, convertColors(colors));
return new JavaGradient(p);
}
Aggregations