home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 14 / IOPROG_14.ISO / soft / sdkjava / dxma.exe / DXMA05.cab / samples / da / java / exercises / Image / Image.java next >
Encoding:
Java Source  |  1997-11-13  |  1013 b   |  35 lines

  1. // This applet illustrates importing, scale to fit and rotating an image
  2. //
  3. // Copyright (c) 1997 Microsoft Corporation
  4.  
  5. import com.ms.dxmedia.*;
  6. import java.net.*;
  7.  
  8. class ImgModelEx extends Model {
  9.  
  10.   // Create the animation in the createModel method.
  11.   public void createModel(BvrsToRun blist) {
  12.     // Build up a URL to import relative to.
  13.     URL mediaBase = getImportBase();
  14.     URL imgBase = buildURL(mediaBase, "image/");    
  15.  
  16.     // Create an image behavior by importing a bitmap.
  17.     ImageBvr img = importImage(buildURL(imgBase, "phantom.jpg"));
  18.  
  19.     // make the image wiggle
  20.     img = img.transform(rotate(mul(sin(localTime), toBvr(0.25))));
  21.     // make the image oscillate
  22.     img = img.transform(translate(vector2(mul(sin(localTime), 
  23.                           toBvr(2*cm)), toBvr(0))));
  24.  
  25.     setImage(overlay(img, solidColorImage(black)));
  26.   }
  27. }
  28.  
  29. public class Image extends DXMApplet {
  30.   public void init() {
  31.     super.init() ;
  32.     setModel(new ImgModelEx());
  33.   }
  34. }
  35.