import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class ShearTest extends JFrame {
public ShearTest() {
super("Shear Transformation of Text");
add(new ShearPane());
setSize(800, 300);
}
public static void main(String[] args) {
new ShearTest().setVisible(true);
}
}
class ShearPane extends JPanel {
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
this.setBackground(Color.BLACK);
g2.setFont(new Font("Monologue", Font.PLAIN, 18));
String text = "java-forum.org";
g2.drawString(text, 30, 30);
for(int i = 0; i<=10; i++) {
AffineTransform at = new AffineTransform();
at.shear(0.2*i, 0.0);
g2.setTransform(at);
g2.setColor(new Color(240-20*i, 10*i, 15*i, 255-10*i));
g2.drawString(text, 30, 30 + 20*i);
}
}
}