使用java畫出寶馬圖標代碼



使用java畫出寶馬圖標代碼

//創建畫布
  BufferedImage image = new BufferedImage(340,200,BufferedImage.TYPE_INT_RGB);
  //創建畫筆
  Graphics g= image.getGraphics();
  
  g.fillRect(0, 0, 500, 500);
  
  g.setColor(new Color(0,0,0));
  
  g.fillArc(15, 15, 150, 150,0,360);
  
  g.setColor(new Color(0,0,255));
  
  g.fillArc(40, 40, 100, 100, 90, 90);
  
  g.setColor(new Color(255,255,255));
  
  g.fillArc(40, 40, 100, 100, 180, 90);
  
  g.setColor(new Color(0,0,255));
  
  g.fillArc(40, 40, 100, 100,270, 90);
  
  g.setColor(new Color(255,255,255));
  
  g.fillArc(40, 40, 100, 100, 360, 90);
  
  //畫出BMW3個字母
  g.setColor(new Color(255,255,255));
  g.setFont(new Font("Arial Black",Font.PLAIN,22));
  g.drawString("B", 35, 60);
  g.drawString("M", 80, 40);
  g.drawString("W", 125,60);
  g.dispose();
  
  //輸出圖片
  ImageIO.write(image, "jpg", response.getOutputStream());

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章