ftp.nice.ch/pub/next/developer/hardware/powerglove/PGlove.N.bs.tar.gz#/PowerGlove/GloveWatch/MultibitCompView.m

This is MultibitCompView.m in view mode; [Download] [Up]

//
// MultibitComp.m
//  
// Copyright (c) 1991 by Jiro Nakamura
// All Rights Reserved.
//
// Original Author:	Jiro Nakamura
// Created:		Jan 6, 1991
//
// RCS Information
// Revision Number->	$Revision: 2.1 $
// Last Revised->	$Date: 91/07/02 17:38:40 $
// ------------------
// History:
//	 3-Jun-91	Jiro Nakamura at The Shaman Group (jiro@shaman.com)
//		Frozen for Release 2.0 of ScanApp
// 	 6-Jan-91	Jiro Nakamura 
//		Created.

static char rcsid[]="$Id: MultibitCompView.m,v 2.1 91/07/02 17:38:40 jiro Exp Locker: jiro $";
static char copyrightid[] = "Copyright (C) 1991 by Jiro Nakamura. All Rights Reserved.";


#import "MultibitCompView.h"
#import <math.h>
#import <dpsclient/psops.h>
#import <dpsclient/wraps.h>

@implementation MultibitCompView
+ newFrame: (const NXRect *) frameRect
{
	self = [super newFrame: frameRect];
	brightness = contrast = 128;
	return self;
}

- drawSelf: (const NXRect *) rects : (int) rectCount
{
	double	bottomIntersection, topIntersection;
	double m, b;	// as in y = mx + b ....
	
	#ifdef DEBUG
		fprintf(stderr, "MultibitView: Updating, b = %d, c = %d\n",
			brightness, contrast);
	#endif
	
//	m =  tan( ((double) contrast * (M_PI/(256*2))));
//	b = brightness - 128;	
//	bottomIntersection = ((-128.0 - b) / m) + 128;
//	topIntersection = ((255.0 - 128.0 - b) / m) + 128;

	m =  tan( ((double) contrast * 45.0 / 128.0 * M_PI / 180.0));
	b = 128 - 128 * (brightness - 128) / 128;
  
	bottomIntersection = (-128.0 / m) + b;
	topIntersection = ((255.0 - 128.0) / m) + b;
	
	#ifdef DEBUG
		fprintf(stderr, "MultibitView: m=%f, b=%f, bi=%f, ti=%f\n",
			m, b, bottomIntersection, topIntersection);
	#endif

	[self lockFocus];
	
        PSsetgray (NX_WHITE);
        NXRectFill (&bounds);
	PSsetgray( NX_BLACK);
	PSsetlinewidth( 2.0 );
	PSscale( 0.5, 0.5 );
	PSmoveto( 0.0, 0.0 );
	PSlineto( bottomIntersection, 0.0);
	PSlineto( topIntersection, 255.0);
	PSlineto( 255.0, 255.0 );
	PSstroke();
	[self unlockFocus];	
	return self;
}
- setBrightness: (int) b andContrast: (int) c
{
	brightness = b;
	contrast = c;
	[self display];
	return self;
}

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.