btcq.net
当前位置:首页 >> 用JAVA语言写一个二维平面图形(如长方形)的平移,旋... >>

用JAVA语言写一个二维平面图形(如长方形)的平移,旋...

import java.applet.Applet; import java.awt.Graphics; import java.awt.Color; public class LX3_3 extends Applet { public void paint(Graphics g) { g.setColor(Color.red);//设置红颜色 g.drawOval(35,35,100,60);//画椭圆(圆心、宽和高) g.fillOval(200,

网上很多这样的.class Point2D{ int x, y; Point2D(){ } Point2D(int i,int j) { x=i; y=j; } void offset(int a, int b) { x=x+a; y=y+b; } void distance(Point2D a,Point2D b) { float m; m=(float)Math.sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); System.out.print("二

class Rectangle{ double x1, y1, x2, y2; Rectangle(){ this(0,0,0,0); } Rectangle(double x1, double y1, double x2, double y2){ this.x1 = x1; this.y1 = y1; this.x2 = x2; this.y2 = y2; } double getArea(){ return Math.abs((x1-x2)*(y1-y2))/2; } double getPemi(){

abstract class Shape{ abstract double area(); } class Circle extends Shape { private double r; private final double PI=3.14; public Circle(double r) { this.r = r; } @Override double area() { return PI*r*r; } } class Rectangle extends Shape { private double w

如果上半圆的半径和下面扇形的半径是一样的,那么沿虚线剪开图形,把剪下的部分绕半圆直径的两个端点,旋转90°,即可以得到一个长方形

逆时针旋转左边的图形

最简单的方法删除:用白色的线,在原位置按原大小再画一个.移动:删除旧的,再在新位置重新画一个

正方形ABCD,AB平移到DC,AB旋转到CD,AB关于AC轴对称到AD.

int[][] rect = new int[][]{{X坐标,Y坐标 },{X坐标+WIDTH, Y坐标+HIGH}};即{左上角坐标,右下角坐标}

网站首页 | 网站地图
All rights reserved Powered by www.btcq.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com