Switch to full style
General Java code examples
Post a reply

Shearing in java

Tue Nov 11, 2008 9:15 pm

Shearing in java graphics
Code:
import java.awt.*;
import javax.swing.*;
import java.awt.geom.*;

public class 
ShearWithTransform extends JComponent {
  
Shape shape;
  
   public 
ShearWithTransform() {
    
shape create();
  }
  private 
Shape create() {
    return new 
Ellipse2D.Double(1005010050);
  }
  public 
void paint(Graphics g) {
    
Graphics2D g2d = (Graphics2Dg;
    
AffineTransform affineTransform1 AffineTransform.
          
getTranslateInstance(00);
    
g2d.transform(affineTransform1);
    
g2d.setPaint(Color.red);
    
g2d.draw(shape);

    
AffineTransform affineTransform2 AffineTransform.
          
getTranslateInstance(00);
      
affineTransform2.shear(-.80);
      
g2d.transform(affineTransform2);
      
g2d.transform(AffineTransform.getTranslateInstance(100100));
      
    
Stroke stroke = new BasicStroke(1BasicStroke.CAP_BUTT,
        
BasicStroke.JOIN_BEVEL0, new float[] { 3}, 0);
    
g2d.setStroke(stroke);
    
g2d.draw(shape);
  }
  public static 
void main(String[] a) {
    
JFrame frame = new JFrame("Shear the oval");
    
frame.getContentPane().add(new ShearWithTransform());
    
frame.setSize(300250);
    
frame.show();
  }



Attachments
shear.gif
shear in java
shear.gif (4.96 KiB) Viewed 8087 times

Post a reply
  Related Posts  to : Shearing in java
 2d game in java-Monster-Java 2D Game Graphics and Animation     -  
 need help in java     -  
 What is Java API?!!!     -  
 Using FTP in java     -  
 java or .net     -  
 what is java     -  
 Java course     -  
 How java access URL     -  
 java program     -  
 Grids in java     -  

Topic Tags

Java Graphics