/*
 * Module:
 *	NeXTshades
 *
 * Author:
 *	Doug "Kareth" McClure
 *	asd@cc.purdue.edu
 *	XASD@PURCCVM.BITNET
 *
 * Version: 1.0
*/

#import "NeXTshadesView.h"
#import "Thinker.h"
#import "NeXTshadesWraps.h"
#import <appkit/NXImage.h>
#import <appkit/Window.h>
#import <appkit/Panel.h>                // for NXRunAlertPanel()
#import <dpsclient/wraps.h>
#import <libc.h>
#import <math.h>

#define DSC_CHANGE	0.025		// incremental change of scale
#define SETG_CHANGE	0.01		// incremental change of color
#define XTRANS_CHANGE	4.0		// incremental change of X position
#define YTRANS_CHANGE	2.0		// incremental change of Y position

@implementation NeXTshadesView

- oneStep
{
  static int sgtest = NO;
  static float xTrans = 400.0, yTrans = 300.0, xScale = .5, yScale = .5;
  static float dscx = DSC_CHANGE, dscy = DSC_CHANGE;
  static float rota = 0.0, setg = 0.0;
  
  PSsendfloat(setg);
  PSsendfloat(rota);
  PSsendfloat(xScale);
  PSsendfloat(yScale);
  PSsendfloat(xTrans);
  PSsendfloat(yTrans);
  psNeXTLogoShades();
  
  xTrans += XTRANS_CHANGE;
  if ( xTrans > xSize )
    {
      xTrans = 0.0;
    }
  
  yTrans += YTRANS_CHANGE;
  if ( yTrans > ySize )
    {
      yTrans = 0.0;
    }
  
  xScale += dscx;
  if ( xScale > 1.0 )
    {
      dscx = - DSC_CHANGE;
    }
  else if ( xScale < 0.1 )
    {
      dscx = DSC_CHANGE;
    }
  
  yScale += dscy;
  if ( yScale > 1.0 )
    {
      dscy = - DSC_CHANGE;
    }
  else if ( yScale < 0.1 )
    {
      dscy = DSC_CHANGE;
    }
  
  rota++;
  if ( rota > 360.0 ) 
    {
      rota = 0.0;
    }
  
  if ( sgtest == NO )
    {
      setg += SETG_CHANGE;
      if ( setg > 1.0 )
	{
	  sgtest = YES;
	}
    }
  else
    {
      setg -= SETG_CHANGE;
      if ( setg < 0.0 )
	{
	  sgtest = NO;
	}
    }
  
  return self;
}


- initFrame:(NXRect *)frameRect
{
  [super initFrame:frameRect];
  [self newSize];

  return self;
}


- sizeTo:(NXCoord)width :(NXCoord)height
{
  [super sizeTo:width :height];
  [self newSize];

  return self;
}


- newSize
{
  xSize = bounds.size.width;
  ySize = bounds.size.height;

  return self;
}


@end
