#import "SquareView.h"

@implementation SquareView

- takeSliderInput:sender
{
	xSlider	= [sender floatValue];
	[self display];	
	return self;
}


- drawSelf:(const NXRect*)r :(int)c
{
	float side;			//temporary side of the square
	
    PSsetgray(NX_WHITE);
    NXRectFill(&bounds);	//erase the present view
    PSsetgray(NX_BLACK);
    PSsetlinewidth(5.0);
	/* Scale the side to the minimum of the view width and height. */
	side = xSlider*((bounds.size.width < bounds.size.height) ?
     					bounds.size.width : bounds.size.height);
	/* Draw the square. */
    PSnewpath();
	PSmoveto(bounds.size.width/2.0-side/2.0, bounds.size.height/2.0-side/2.0);
	PSrlineto(0.0, side);
	PSrlineto(side,0.0);
	PSrlineto(0.0,-side);
	PSclosepath();
    PSstroke();
    return self;
}

@end
