package swastika;



import java.awt.*;
import java.awt.geom.Path2D;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;


public class Pentagram
{
	final double degrees = Math.toRadians(144);

	private int width, height;

	public static void main(String[] args)
	{
		new Pentagram(640, 640);
	}

	public Pentagram(int width, int height)
	{
		this.width = width;
		this.height = height;
		drawAndWriteImage();
	}

	private void drawPentagram(Graphics2D g, int len, int x1, int y1)
	{
		double angle = 0;
		for (int i = 0; i < 5; i++)
		{
			int x2 = x1 + (int) (Math.cos(angle) * len);
			int y2 = y1 + (int) (Math.sin(-angle) * len);
			g.drawLine(x1, y1, x2, y2);
			x1 = x2;
			y1 = y2;
			angle += degrees;
		}
	}

	private void fillPentagram(Graphics2D g, int len, int x, int y)
	{
		double angle = 0;
		Path2D.Float p = new Path2D.Float();
		p.moveTo(x, y);
		for (int i = 0; i < 10; i++)
		{
			x = x + (int) (Math.cos(angle) * len);
			y = y + (int) (Math.sin(-angle) * len);
			p.lineTo(x, y);
			angle -= (i % 2 == 0 ? 0.5 : -1) * degrees;
		}
		p.closePath();
		g.fill(p);
	}
	
	private void drawAndWriteImage()
	{
		BufferedImage bim = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
		Graphics2D g = bim.createGraphics();
		RenderingHints qualityHints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
		qualityHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
		g.setRenderingHints(qualityHints);
		g.setStroke(new BasicStroke(5, BasicStroke.CAP_ROUND, 0));
		g.setColor(new Color(197, 197, 139));
		fillPentagram(g, 190, 72, 375);
		g.setColor(new Color(87, 87, 43));
		drawPentagram(g, 500, 70, 375);
		g.dispose();
		try
		{
			ImageIO.write(bim, "PNG", new File("C:\\Users\\raymond\\Pictures\\Pentagram_with_Java.png"));
		}
		catch (Exception e)
		{
		}
	}
}

Save code as Pentagram.java, and running it, creates: