<HTML> 
<HEAD>
<TITLE>DirectAnimation SDK, JScript sample</TITLE>
<SCRIPT LANGUAGE="JScript">
<!--
if (window.top.frames.length!=0 && window.top.frames[0].ShowNoButtons!=null)
    window.top.frames[0].ShowNoButtons();
//-->
</SCRIPT>
</HEAD>	 

<BODY BGCOLOR=WHITE TOPMARGIN=15 LEFTMARGIN=20>
<FONT FACE="Verdana, Arial, Helvetica" SIZE=2> 
<CENTER>
<H1>Image Cropping</H1>
</CENTER>

This is an example of overlaying two images where one is cropped.  Here the same image is 
constructed twice using two different colors.  The second image is cropped by two points
moving along a path.  The rectangle also moves along the path and provides a border for 
the cropped image.  The two images are overlayed together to give this nice effect.

<OBJECT ID="DAControl"
  STYLE="position:absolute; left:20%; top:100;width:500;height:300" 
  CLASSID="CLSID:B6FFC24C-7E13-11D0-9B47-00C04FC2F51D">
</OBJECT>

<SCRIPT LANGUAGE="JScript">
<!--
  // The DirectAnimation library.
  m = DAControl.MeterLibrary;
  
  // Use "Webdings" as the fontstyle.
  fs = m.Font( "Webdings", 42, m.Black);

  // "3456:Xi" creates image you see in the "Webdings" fontstyle.
  textImg1 = m.StringImage("3456:Xi", fs).Transform(m.Translate2(0,-.004));
  textImg2 = m.StringImage("3456:Xi", fs.Color(m.Blue)).Transform(m.Translate2(0,-.004));
  
  // Path start point.
  start = m.Point2(-.05,0);
  
  // Path end point.
  end   = m.Point2(.05,0);    
  
  // Make a path transform that follows the line between the 
  // two points in 3 seconds, and repeat the motion forever.
  mp =  m.FollowPath(m.Line(start,end), 3).RepeatForever(); 

  // Move two points along the same path.
  max = m.Point2( .008, .008).Transform(mp);
  min = m.Point2(-.008,-.008).Transform(mp);

  // Crop the first text image by the moving points.
  cropImg = textImg1.Crop(min,max);

  // Draw a rectangle and transform it along the path.
  rectImg = m.Rect(.016,.016).Draw(m.DefaultLineStyle).Transform(mp);

  // Overlay all the elements together.
  finalImg = m.Overlay(m.Overlay(rectImg, cropImg), textImg2);

  // Set the image into the control.
  DAControl.Image = finalImg; 
  
  // Set the background in case of a non-windowless browser (like IE3)
  DAControl.BackgroundImage = m.SolidColorImage(m.Blue);     
     
  // Start the animation. 
  DAControl.Start()
//-->
</SCRIPT>
</FONT>
</BODY>
</HTML>
