home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / Gamelication / com / next / gt / TiledImage.java < prev    next >
Text File  |  1998-04-15  |  856b  |  38 lines

  1. /**
  2.  *
  3.  * TiledImage.java
  4.  * @author    Mark G. Tacchi (mtacchi@next.com) 
  5.  * @version    0.8
  6.  * Feb 24/1996
  7.  * 
  8.  * TiledImage is a simple class with the sole responsibility of
  9.  * replicating an image tile to produce a large tiled image.  This is
  10.  * useful for creating a background image.
  11.  * 
  12. */
  13.  
  14. package com.next.gt;
  15.  
  16. import java.awt.Graphics;
  17. import java.awt.Image;
  18.  
  19.  
  20. public class TiledImage extends java.lang.Object {
  21.   static Image        tiledImage;
  22.  
  23. public static Image createTiledImage(Image theImage, int width, int height,
  24.                      Gamelication owner) {
  25.   int        i, j;
  26.   
  27.   tiledImage= owner.createImage(width,height);
  28.   for (i= 0; i< width; i+= theImage.getWidth(null)) {
  29.     for (j= 0; j< height; j+= theImage.getHeight(null)) {
  30.       tiledImage.getGraphics().drawImage(theImage,i,j,owner);
  31.     }
  32.   }
  33.   return tiledImage;
  34. } /*TiledImage(,,,)*/
  35.  
  36.  
  37. } /*TiledImage*/
  38.