Java procedure for printing Olympic logo details

  • 2020-09-28 08:54:02
  • OfStack

Olympic five rings logo, it is composed of five Olympic rings socket, by blue, black, red, yellow, green 5 colors. The rings are connected from left to right, with blue, black and red rings above and yellow and green rings below. The whole shape is a small regular trapezoid at the bottom. According to the Olympic Charter, the rings symbolize the union of the five continents and the meeting of athletes from all over the world at the Olympic Games in a spirit of fair, frank competition and friendship. The Olympic Five rings logo was conceived and designed by Pierre DE Coubertin in 1913. It is determined by the Olympic Charter and also known as the Olympic five rings logo. It is the most widely recognized Olympic Games logo in the world. Taking a brief look at the origins of the five-ring logo, let's look at how to print out the Olympic logo in Java.

The code is as follows:


public class wuhuan extends Applet{
 private Color clr[]={Color.blue,Color.black,Color.red,Color.yellow,
 Color.green};   //clr[] Store color 
 private int[] x={100,136,172,118,154}; //x[] Storing the center of the circle x coordinates 
 private int[] y={60,60,60,91,91}; //y[] Storing the center of the circle y coordinates 
 private int[][] xy={{100,60},{136,60},{172,60},{118,91},{154,91}};    // Store the coordinates of the center of the circle 
 private int r=20,d=40;
 public void paint(Graphics g)  // Drawing method 
 { 
 Font font = new Font(" Regular script ",Font.PLAIN,20); // Text font, size 
 g.setFont(font);
 for(int i=0;i<5;i++)  // cycle 5 Time, 5 A ring 
 {
 g.setColor(clr[i]);
 g.drawOval(x[i], y[i], d, d); //d Represents the length and width of the ellipse tangent rectangle, equal represents the circle 
 }
 g.setColor(Color.blue);  // Set the color 
 g.setFont(font);
 g.drawString("Olympic Logo",120,169);
 }   
}

Let's run 1 and see what happens. To see more exciting content, please pay attention to this site!


Related articles: