//
// Draw a simple house import java.awt.*; public class House extends BufferedApplet { double points[][] = {{-.9,-1,0},{1,-1,0},{1,.8,0},{0,1.5,0},{-1,.8,0},{-1,-1,0},{.9,.8,0},{-.9,.8,0},{.9,-.9,0}}; double a[] = {0,0,0}, b[] = {0,0,0}; int w, h; public void render(Graphics g) { w = bounds().width; // FIND OUT HOW BIG THE APPLET WINDOW IS h = bounds().height; g.setColor(Color.white); // MAKE A CLEAR WHITE BACKGROUND g.fillRect(0,0,w,h); g.setColor(Color.black); // SET THE DRAWING COLOR TO BLACK for (int i = 1 ; i < points.length ; i++) { // LOOP THROUGH ALL THE LINES IN THE SHAPE transform(points[i-1], a); // TRANSFORM BOTH ENDPOINTS OF LINE transform(points[i ], b); g.drawLine(x(a[0]), y(a[1]), x(b[0]), y(b[1])); // DRAW ONE LINE ON THE SCREEN } } int x(double t) { return w/2 + (int)(t*w/4); } // CONVERT X COORDINATE TO SCREEN PIXELS int y(double t) { return h/2 - (int)(t*w/4); } // CONVERT Y COORDINATE TO SCREEN PIXELS void transform(double src[], double dst[]) { ///////// THIS IS THE PART YOU SHOULD REPLACE, TO DO COOL TRANSFORMATIONS ///////// dst[0] = src[0]; dst[1] = src[1]; dst[2] = src[2]; //////////////////////////////////////////////////////////////////////////////////// } }