Created
February 22, 2020 18:44
-
-
Save MinSomai/855dde657f7151eeaa47f68cbb48e4f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package hw; | |
import java.awt.Graphics; | |
import java.util.Scanner; | |
import javax.swing.JFrame; | |
public class ShearingY13 extends JFrame { | |
static int x1, y1, x2, y2, x3, y3, x4, y4, shy; | |
int py1,py2,py3,py4; | |
public ShearingY13(){ | |
setTitle("Y-Direction Shear"); | |
setSize(1000,1000); | |
setVisible(true); | |
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
py1 = x1 + y1*shy; | |
py2 = x2 + y2*shy; | |
py3 = x3+ y3 *shy; | |
py4 = x4+ y4 * shy; | |
} | |
public void paint(Graphics g) { | |
//before shear | |
g.drawLine(x1, y1, x2, y2); | |
g.drawLine(x2, y2, x3, y3); | |
g.drawLine(x3, y3, x4, y4); | |
g.drawLine(x4, y4, x1, y1); | |
//after shear | |
g.drawLine(x1,py1, x2, py2); | |
g.drawLine(x2,py2, x3, py3); | |
g.drawLine(x3,py3, x4, py4); | |
g.drawLine(x4,py4, x1, py1); | |
} | |
public static void main(String args[]){ | |
System.out.println("Enter x1, y1, x2, y2, x3, y3, x4, y4, shy"); | |
Scanner bg =new Scanner(System.in); | |
x1 = bg.nextInt(); | |
y1 = bg.nextInt(); | |
x2 = bg.nextInt(); | |
y2 = bg.nextInt(); | |
x3 = bg.nextInt(); | |
y3 = bg.nextInt(); | |
x4 = bg.nextInt(); | |
y4 = bg.nextInt(); | |
shy = bg.nextInt(); | |
new ShearingY13(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment