import java.awt.*; import java.applet.*; import java.awt.*; class Sphere extends Thread implements Runnable { Applet app; long d; Point3D_sp c; Color cl1,cl2,cl3; public Sphere(long x,long y,long z,long d,Color cl){ c=new Point3D_sp(x,y,z); this.d=d; cl1=cl.darker(); cl2=cl; cl3=cl.brighter(); } public Sphere(){ c=Point3D_sp.ORIGIN; d=10; cl2=Color.blue; cl1=cl2.darker(); cl3=cl2.brighter(); } public Point3D_sp getCenter(){ return c; } public long getSize(){ return d; } public Color getColor(){ return cl2; } public void resize(long nd){ d=nd; } public void render(Graphics g,Dimension dm){ Point gc=new Point(dm.height/2,dm.width/2); Color col=g.getColor(); g.setColor(cl1); int fov=80; long dx=(long)((gc.x)/Math.tan(fov/2)); long dy=(long)((gc.y)/Math.tan(fov/2)); g.fillOval(gc.x+(Math.round((dx*c.x)/(c.z+gc.x*2))), gc.y+(Math.round((dx*c.y)/(c.z+gc.y*2))), Math.round(.1f*(d)*3500/(500-c.z)),Math.round(.1f*(d)*3500/(500-c.z))); g.setColor(cl2); g.fillOval(gc.x+(Math.round((dx*c.x)/(c.z+gc.x*2)))+(Math.round(d/12)), gc.y+(Math.round((dx*c.y)/(c.z+gc.y*2)))+(Math.round(d/12)), Math.round((.1f*(d)*(3500/(500-c.z)*5))/9),Math.round((.1f*(d)*(3500/(500-c.z)*5))/9)); g.setColor(cl3); g.fillOval(gc.x+(Math.round((dx*c.x)/(c.z+gc.x*2)))+(Math.round(d/8)), gc.y+(Math.round((dx*c.y)/(c.z+gc.y*2)))+(Math.round(d/8)), Math.round(.1f*(d)*(3500/(500-c.z)))/3,Math.round(.1f*(d)*(3500/(500-c.z)))/3); g.setColor(col); } }