import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;
/** An example of shear transformations on a rectangle.
*
***********************
public class ShearExample extends JPanel {
private static int gap=10, width=100;
private Rectangle rect = new Rectangle(gap, gap, 100, 100);
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D)g;
for (int i=0; i<5; i++) {
g2d.setPaint(Color.red);
g2d.fill(rect);
// Each new square gets 0.2 more x shear.
g2d.shear(0.2, 0.0);
g2d.translate(2*gap + width, 0);
}
}
public static void main(String[] args) {
String title =
"Shear: x shear ranges from 0.0 for the leftmost" +
"'square' to 0.8 for the rightmost one.";
WindowUtilities.openInJFrame(new ShearExample(),
20*gap + 5*width,
5*gap + width,
title);
}
}
Note: Brought from our old site: http://www.salearningschool.com/example_codes/ on Jan 2nd, 2017
From: http://sitestree.com/?p=10381
Categories:Programming Code Examples, Java/J2EE/J2ME, Drawing
Tags:Java/J2EE/J2MEDrawing
Post Data:2017-01-02 16:04:39
Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada
