WEB开发网
开发学院WEB开发Jsp 实现阴影、镂空、离散等特种文字效果 阅读

实现阴影、镂空、离散等特种文字效果

 2008-01-05 09:49:58 来源:WEB开发网   
核心提示:如何实现阴影、镂空、离散等特种文字效果? 下面是从http://www.javaworld.com/javaworld/javatips/jw-javatip81.Html 得到 的一些实现特种文字效果的代码片断,感爱好的网友可以自己去看原文,实现阴影、镂空、离散等特种文字效果, // Shadow g.s

  如何实现阴影、镂空、离散等特种文字效果?
  
   下面是从http://www.javaworld.com/javaworld/javatips/jw-javatip81.Html 得到
   的一些实现特种文字效果的代码片断。感爱好的网友可以自己去看原文。
  
   // Shadow
   g.setColor(new Color(50, 50, 50));
   g.drawString("Shadow", ShiftEast(x, 2), ShiftSouth(y, 2));
   g.setColor(new Color(220, 220, 220));
   g.drawString("Shadow", x, y);
  
   // Engrave
   g.setColor(new Color(220, 220, 220));
   g.drawString("Engrave", ShiftEast(x, 1), ShiftSouth(y, 1));
   g.setColor(new Color(50, 50, 50));
   g.drawString("Engrave", x, y);
  
   file://Outline
   g.setColor(Color.red);
   g.drawString("Outline", ShiftWest(x, 1), ShiftNorth(y, 1));
   g.drawString("Outline", ShiftWest(x, 1), ShiftSouth(y, 1));
   g.drawString("Outline", ShiftEast(x, 1), ShiftNorth(y, 1));
   g.drawString("Outline", ShiftEast(x, 1), ShiftSouth(y, 1));
   g.setColor(Color.yellow);
   g.drawString("Outline", x, y);
  
   file://Hollow
   g.setColor(Color.black);
   g.drawString("Hollow", ShiftWest(x, 1), ShiftNorth(y, 1));
   g.drawString("Hollow", ShiftWest(x, 1), ShiftSouth(y, 1));
   g.drawString("Hollow", ShiftEast(x, 1), ShiftNorth(y, 1));
   g.drawString("Hollow", ShiftEast(x, 1), ShiftSouth(y, 1));
   g.setColor(bg);
   g.drawString("Hollow", x, y);
  
   file://Segment
   int w = (g.getFontMetrics()).stringWidth("Segment");
   int h = (g.getFontMetrics()).getHeight();
   int d = (g.getFontMetrics()).getDescent();
   g.setColor(new Color(220, 220, 220));
   g.drawString("Segment", x, y);
   g.setColor(bg);
   for (int i = 0; i < h; i += 3)
   g.drawLine(x, y + d - i, x + w, y + d - i);
  
   file://3D Effects
   Color top_color = new Color(200, 200, 0);
   Color side_color = new Color(100, 100, 0);
   for (int i = 0; i < 5; i++)
   {
   g.setColor(top_color);
   g.drawString("3-Dimension", ShiftEast(x, i), ShiftNorth(ShiftSouth(y, i), 1));
   g.setColor(side_color);
   g.drawString("3-Dimension", ShiftWest(ShiftEast(x, i), 1), ShiftSouth(y, ii));
   }
   g.setColor(Color.yellow);
   g.drawString("3-Dimension", ShiftEast(x, 5), ShiftSouth(y, 5));
  
   file://Motion
   for (int i = 0; i < 20; i++)
   {
   font_size = 12 + i;
   g.setFont(new Font("TimesRoman", Font.PLAIN, font_size));
   w = (g.getFontMetrics()).stringWidth("Motion");
   g.setColor(new Color(0, 65 + i * 10, 0));
   g.drawString("Motion", (width - w) / 2, ShiftSouth(y, speed * i));
   }

Tags:实现 阴影 镂空

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接