Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
/**
*
*/
package de.tutorials;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.Polygon;
import java.awt.TexturePaint;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import javax.swing.JFrame;
/**
* @author Thomas.Darimont
*
*/
public class PolygonFillingExample extends JFrame {
Paint paint;
int textureWidth = 32;
int stepWidth = 4;
Color textureColor = Color.BLUE;
public PolygonFillingExample() {
super("PolygonFillingExample");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(640, 480);
paint = new TexturePaint(createTexture(), new Rectangle2D.Double(0, 0,
textureWidth, textureWidth));
setVisible(true);
}
private BufferedImage createTexture() {
BufferedImage texture = new BufferedImage(textureWidth, textureWidth,
BufferedImage.TYPE_INT_ARGB);
Graphics2D g = texture.createGraphics();
g.setColor(textureColor);
for (int x = -textureWidth; x < textureWidth; x += stepWidth) {
g.drawLine(x, 0, textureWidth + x, textureWidth);
}
return texture;
}
/**
* @param args
*/
public static void main(String[] args) {
new PolygonFillingExample();
}
@Override
public void paint(Graphics gra) {
super.paint(gra);
Graphics2D g = (Graphics2D) gra;
Polygon polygon = new Polygon(new int[] { 100, 150, 200, 250, 175 },
new int[] { 100, 200, 200, 100, 50 }
, 5);
g.drawPolygon(polygon);
g.setPaint(paint);
g.fillPolygon(polygon);
}
}