can anyone tell me how to rotate the inner yellow star within the blue star

import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Path2D;

public class app extends Applet
{
   final static int OFFSET = 30;
   final static int OFFSETS = 30;

   public void paint(Graphics g)
   {
      Graphics2D g2 = (Graphics2D) g;
      int width = getWidth()-2*OFFSET;
      int height = getHeight()-2*OFFSET;
      g2.translate(width/2-height/2+OFFSETS, OFFSETS);
      width = height;
      g2.setColor(Color.white);
      setBackground(Color.white);
      Path2D star = new Path2D.Float();
      star.moveTo(width/5F, height-1);
      star.lineTo(width/2F, 0);
      star.lineTo(4*width/5F, height-1);
      star.lineTo(0, 2*height/5F);
      star.lineTo(width-1, 2*height/5F);
      star.closePath();
      g2.draw(star);
      g2.setColor(Color.blue);
      g2.fill(star);
      
   ////////////////////////// inner star//////////////////////////////////  


      int widths = getWidth()-3*90;
      int heights = getHeight()-3*37;
      g2.translate(widths/2-heights/2+OFFSETS, OFFSETS);
      widths = heights;      
      g2.setColor(Color.white);
      setBackground(Color.white);
      Path2D star1 = new Path2D.Float();
      star1.moveTo(widths/5F, heights-1);
      star1.lineTo(widths/2F, 0);
      star1.lineTo(4*widths/5F, heights-1);
      star1.lineTo(0, 2*heights/5F);
      star1.lineTo(widths-1, 2*heights/5F);
      star1.closePath();
      g2.draw(star1);
      g2.setColor(Color.yellow);
      g2.fill(star1);
   }
}

You could use the transform(AffineTransform at) method on your Path2D star1, with an AffineTransform obtained from AffineTransform.getRotateInstance(double theta, double anchorx, double anchory) to rotate it by any desired angle

AffineTransformations look very scary, and often they are, but in essence they take a shape and change it by stretching, skewing, sheering, rotating etc. All you need is a simple rotation, which the method I suggested will give you.

API documentation is in the usual place.

You can also rotate the current graphics context with the .rotate() method of the Graphics2D class.

This part of the Java tutorial discusses these transformations.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.