// Graffiti.java // www.seb.cc // import java.applet.*; import java.net.*; import java.awt.*; import java.io.*; import java.awt.image.*; public class Graffiti extends Applet { private Dimension appletsize; private Image gui_image; private Image[] images; private Image buffer; private MediaTracker loader; private TextField name; private AppletContext browser; private Font font; private Graphics g; // State private boolean sketching; private int currentimage=0; private int currentbrush=2; private int brushsize=32; public void init() { int i; int numimgs=0; // Get Applet & Browser Parameters browser=getAppletContext(); this.setBackground(Color.black); this.setForeground(Color.white); // Load font font=new Font("Helvetica",Font.BOLD,14); // Create off screen buffer appletsize=size(); buffer=createImage(appletsize.width,appletsize.height); g=buffer.getGraphics(); g.setFont(font); g.setColor(Color.black); g.drawString("loading images, please wait...",20,20); this.getGraphics().drawImage(buffer,0,0,this); repaint(); // Read images parameters, and preload images for (i=0; getParameter("Img"+i)!=null ; i++) numimgs++; loader = new MediaTracker(this); images=new Image[numimgs]; for (i=0; i=77) { sketching=true; g.clipRect(x-brushsize/2,y-brushsize/2,brushsize,brushsize); g.drawImage(images[currentimage],0,60,this); paintGUI(g); repaint(); } else { if ( (x>=652) && (x<=720)) { URL seb=null; try{ seb=new URL("http://www.seb.cc"); } catch (MalformedURLException ex) {;} this.getAppletContext().showDocument(seb); return true; } if ( (x>=400) && (x<=570)) { currentimage=Math.round((x-402)/58); paintGUI(g); repaint(); return true; } if ( (x>=248) && (x<=374) ) { currentbrush=Math.round((x-248)/40); brushsize=(currentbrush+1)*16; paintGUI(g); repaint(); return true; } } return true; } public boolean mouseDrag(Event e,int x, int y) { g=buffer.getGraphics(); if (y>77+brushsize/2) { g.clipRect(x-brushsize/2,y-brushsize/2,brushsize,brushsize); g.drawImage(images[currentimage],0,77,this); repaint(); } else { g.clipRect(x-brushsize/2,y-brushsize/2,brushsize,brushsize); g.drawImage(images[currentimage],0,77,this); paintGUI(g); repaint(); } return true; } public boolean mouseUp(Event e, int x,int y) { sketching=false; return true; } }