J
Jenny
Hi,
The java doc says rotate() will be rotating with a positive angle
theta rotates points on the positive x axis toward the positive y
axis. It seems the positive angle theta does the opposite.
Here is the code with a positive angle theta for you to see.
import java.awt.*;
import javax.swing.*;
import java.awt.geom.*;
public class TryFont extends JFrame {
public TryFont() {
super("Rectangles");
setSize(410, 430);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
RectPanel r = new RectPanel();
Container content = getContentPane();
content.add(r);
setContentPane(content);
setVisible(true);
}
public static void main(String[] arguments) {
TryFont rect = new TryFont();
}
}
class RectPanel extends JPanel {
public void paintComponent(Graphics comp) {
super.paintComponent(comp);
Graphics2D comp2D = (Graphics2D) comp;
setBackground(Color.white);
comp2D.rotate(-.4,200,200);
Font f = new Font("Garbage",Font.BOLD,40);
Font f1 = new Font("Times New Roman",Font.BOLD,40);
comp2D.setColor(Color.green);
comp2D.setFont(f);
comp2D.drawString("Happy", 50,150);
comp2D.setColor(Color.red);
comp2D.setFont(f1);
comp2D.drawString("Birthday!", 50,200);
}}
The java doc says rotate() will be rotating with a positive angle
theta rotates points on the positive x axis toward the positive y
axis. It seems the positive angle theta does the opposite.
Here is the code with a positive angle theta for you to see.
import java.awt.*;
import javax.swing.*;
import java.awt.geom.*;
public class TryFont extends JFrame {
public TryFont() {
super("Rectangles");
setSize(410, 430);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
RectPanel r = new RectPanel();
Container content = getContentPane();
content.add(r);
setContentPane(content);
setVisible(true);
}
public static void main(String[] arguments) {
TryFont rect = new TryFont();
}
}
class RectPanel extends JPanel {
public void paintComponent(Graphics comp) {
super.paintComponent(comp);
Graphics2D comp2D = (Graphics2D) comp;
setBackground(Color.white);
comp2D.rotate(-.4,200,200);
Font f = new Font("Garbage",Font.BOLD,40);
Font f1 = new Font("Times New Roman",Font.BOLD,40);
comp2D.setColor(Color.green);
comp2D.setFont(f);
comp2D.drawString("Happy", 50,150);
comp2D.setColor(Color.red);
comp2D.setFont(f1);
comp2D.drawString("Birthday!", 50,200);
}}