import com.stevesoft.phreida.*; import java.awt.*; import java.io.*; import java.net.*; public class Test5 { public static void main(String[] args) throws Exception { // Create the graphics object. Page size is about the // same as a paperback novel. PGraphics pg = new PGraphics("test5.pdf",0,0,300,460); Toolkit tk = Toolkit.getDefaultToolkit(); // This program is the same as Test4, but there's a clip pg.setClip(makeStar(125,125,50,80)); URL url = Test5.class.getResource("onintro.gif"); Image im = tk.getImage(url); pg.drawImage(im,65,95,null); int del = 4; int radius = 50; int x = 100, y = 100; for(int i=0;i <= 460;i+=20) { radius += 2*del; y -= del; x -= del; pg.setColor(Color.green); pg.drawArc(x,y,radius,radius,i,300); pg.setColor(Color.blue); pg.drawArc(x,y,radius,radius,i+300,60); } // Finish pg.dispose(); // writes out file System.exit(0); // Graphics thread is running still } public static Polygon makeStar(int xc,int yc,int r1,int r2) { int[] xpoints = new int[10]; int[] ypoints = new int[10]; for(int i=0;i<10;i++) { double a = Math.PI/5*i+Math.PI/10; double r = r1+r2*(i%2); xpoints[i] = xc+(int)(r*Math.cos(a)+.5); ypoints[i] = yc+(int)(r*Math.sin(a)+.5); } return new Polygon(xpoints,ypoints,10); } }