import java.awt.*;
import java.awt.geom.*;
public class SimpleLetterC extends Frame{
public SimpleLetterC()
{
addWindowListener(new MyFinishWindow());
}
public void paint(Graphics g)
{
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
BasicStroke bs = new BasicStroke(3.0f);
g2d.setStroke(bs);
int xc1 = 50;
int yc1 = 250;
int xc2 = 250;
int yc2 = 50;
int xc3 = 50;
int yc3 = 50;
int xc4 = 250;
int yc4 = 450;
int xc5 = 50;
int yc5 = 450;
QuadCurve2D.Double d1 = new QuadCurve2D.Double(xc1,yc1,xc3,yc3,xc2,yc2);
g2d.draw(d1);
QuadCurve2D.Double d2 = new QuadCurve2D.Double(xc1,yc1,xc5,yc5,xc4,yc4);
g2d.draw(d2);
drawSmallRect(xc1,yc1,g2d);
drawSmallRect(xc11,yc11,g2d);
drawSmallRect(xc2,yc2,g2d);
drawSmallRect(xc3,yc3,g2d);
drawSmallRect(xc4,yc4,g2d);
drawSmallRect(xc5,yc5,g2d);
g2d.setFont(new Font("serif",Font.PLAIN,24));
g2d.drawString("P11'",xc1-10,yc1-5);
g2d.drawString("P2'",xc2+10,yc2+10);
g2d.drawString("P3'",xc3-35,yc3+4);
g2d.drawString("P4'",xc4+10,yc4+10);
g2d.drawString("P5'",xc5+10,yc5+10);
}
public static void drawSmallRect(int x, int y, Graphics2D g2d)
{
Rectangle rect = new Rectangle(x-4,y-3,8,8);
g2d.fill(rect);
}
public static void main(String[] args) {
SimpleLetterC f = new SimpleLetterC();
f.setTitle("The letter C");
f.setSize(420,500);
f.setVisible(true);
}
}
What I have tried:
This code draws the shape of the letter C using Java 2D graphics, I need to draw the shape of A, H, F letters using same code but I do not know where can I change or modify in the code.. I tried my best to understand the role of control points and how they can change the shape of the letter
Please help