mirror of
https://github.com/softdorothy/GliderPRO.git
synced 2024-11-29 07:49:46 +00:00
7a70d18ba6
Sources for Glider PRO, a Macintosh game written by John Calhoun and published by Casady & Greene, Inc. I believe it was using CodeWarrior IDE to create a fat (68K and PowerPC) binary.
1 line
6.3 KiB
C
Executable File
1 line
6.3 KiB
C
Executable File
|
|
//============================================================================
|
|
//----------------------------------------------------------------------------
|
|
// ColorUtils.c
|
|
//----------------------------------------------------------------------------
|
|
//============================================================================
|
|
|
|
|
|
#include "Externs.h"
|
|
#include <Palettes.h>
|
|
|
|
|
|
//============================================================== Functions
|
|
//-------------------------------------------------------------- ColorText
|
|
|
|
// Given a string and a color index (index into the current palette),É
|
|
// this function draws text in that color. It assumes the current port,É
|
|
// the current font, the current pen location, etc.
|
|
|
|
void ColorText (StringPtr theStr, long color)
|
|
{
|
|
RGBColor theRGBColor, wasColor;
|
|
|
|
GetForeColor(&wasColor);
|
|
Index2Color(color, &theRGBColor);
|
|
RGBForeColor(&theRGBColor);
|
|
DrawString(theStr);
|
|
RGBForeColor(&wasColor);
|
|
}
|
|
|
|
//-------------------------------------------------------------- ColorRect
|
|
|
|
// Given a rectangle and color index, this function draws a solidÉ
|
|
// rectangle in that color. Current port, pen mode, etc. assumed.
|
|
|
|
void ColorRect (Rect *theRect, long color)
|
|
{
|
|
RGBColor theRGBColor, wasColor;
|
|
|
|
GetForeColor(&wasColor);
|
|
Index2Color(color, &theRGBColor);
|
|
RGBForeColor(&theRGBColor);
|
|
PaintRect(theRect);
|
|
RGBForeColor(&wasColor);
|
|
}
|
|
|
|
//-------------------------------------------------------------- ColorOval
|
|
|
|
// Given a rectangle and color index, this function draws a solidÉ
|
|
// oval in that color. Current port, pen mode, etc. assumed.
|
|
|
|
void ColorOval (Rect *theRect, long color)
|
|
{
|
|
RGBColor theRGBColor, wasColor;
|
|
|
|
GetForeColor(&wasColor);
|
|
Index2Color(color, &theRGBColor);
|
|
RGBForeColor(&theRGBColor);
|
|
PaintOval(theRect);
|
|
RGBForeColor(&wasColor);
|
|
}
|
|
|
|
//-------------------------------------------------------------- ColorRegion
|
|
|
|
// Given a region and color index, this function draws a solidÉ
|
|
// region in that color. Current port, pen mode, etc. assumed.
|
|
|
|
void ColorRegion (RgnHandle theRgn, long color)
|
|
{
|
|
RGBColor theRGBColor, wasColor;
|
|
|
|
GetForeColor(&wasColor);
|
|
Index2Color(color, &theRGBColor);
|
|
RGBForeColor(&theRGBColor);
|
|
PaintRgn(theRgn);
|
|
RGBForeColor(&wasColor);
|
|
}
|
|
|
|
//-------------------------------------------------------------- ColorLine
|
|
|
|
// Given a the end points for a line and color index, this functionÉ
|
|
// draws a line in that color. Current port, pen mode, etc. assumed.
|
|
|
|
void ColorLine (short h0, short v0, short h1, short v1, long color)
|
|
{
|
|
RGBColor theRGBColor, wasColor;
|
|
|
|
GetForeColor(&wasColor);
|
|
Index2Color(color, &theRGBColor);
|
|
RGBForeColor(&theRGBColor);
|
|
MoveTo(h0, v0);
|
|
LineTo(h1, v1);
|
|
RGBForeColor(&wasColor);
|
|
}
|
|
|
|
//-------------------------------------------------------------- HiliteRect
|
|
|
|
// Given a rect and two hilite colors, this function frames the top andÉ
|
|
// left edges of the rect with color 1 and frames the bottom and rightÉ
|
|
// sides with color 2. A rect can be made to appear "hi-lit" or "3D"É
|
|
// in this way.
|
|
|
|
void HiliteRect (Rect *theRect, short color1, short color2)
|
|
{
|
|
ColorLine(theRect->left, theRect->top, theRect->right - 2,
|
|
theRect->top, color1);
|
|
ColorLine(theRect->left, theRect->top, theRect->left,
|
|
theRect->bottom - 2, color1);
|
|
ColorLine(theRect->right - 1, theRect->top, theRect->right - 1,
|
|
theRect->bottom - 2, color2);
|
|
ColorLine(theRect->left + 1, theRect->bottom - 1, theRect->right - 1,
|
|
theRect->bottom - 1, color2);
|
|
}
|
|
|
|
//-------------------------------------------------------------- ColorFrameRect
|
|
|
|
// Given a rectangle and color index, this function frames aÉ
|
|
// rectangle in that color. Current port, pen mode, etc. assumed.
|
|
|
|
void ColorFrameRect (Rect *theRect, long color)
|
|
{
|
|
RGBColor theRGBColor, wasColor;
|
|
|
|
GetForeColor(&wasColor);
|
|
Index2Color(color, &theRGBColor);
|
|
RGBForeColor(&theRGBColor);
|
|
FrameRect(theRect);
|
|
RGBForeColor(&wasColor);
|
|
}
|
|
|
|
//-------------------------------------------------------------- ColorFrameWHRect
|
|
|
|
// Given a the top-left corner of a rectangle, its width and height,É
|
|
// and a color index, this function frames a rectangle in that color.
|
|
// Current port, pen mode, etc. assumed.
|
|
|
|
void ColorFrameWHRect (short left, short top, short wide, short high, long color)
|
|
{
|
|
Rect theRect;
|
|
|
|
theRect.left = left;
|
|
theRect.top = top;
|
|
theRect.right = left + wide;
|
|
theRect.bottom = top + high;
|
|
ColorFrameRect(&theRect, color);
|
|
}
|
|
|
|
//-------------------------------------------------------------- ColorFrameOval
|
|
|
|
// Given a rectangle and color index, this function frames anÉ
|
|
// oval in that color. Current port, pen mode, etc. assumed.
|
|
|
|
void ColorFrameOval (Rect *theRect, long color)
|
|
{
|
|
RGBColor theRGBColor, wasColor;
|
|
|
|
GetForeColor(&wasColor);
|
|
Index2Color(color, &theRGBColor);
|
|
RGBForeColor(&theRGBColor);
|
|
FrameOval(theRect);
|
|
RGBForeColor(&wasColor);
|
|
}
|
|
|
|
//-------------------------------------------------------------- LtGrayForeColor
|
|
|
|
// This function finds the closest match to a "light gray" in theÉ
|
|
// current palette and sets the pen color to that.
|
|
|
|
void LtGrayForeColor (void)
|
|
{
|
|
RGBColor color;
|
|
|
|
color.red = (unsigned short) 0xBFFF;
|
|
color.green = (unsigned short) 0xBFFF;
|
|
color.blue = (unsigned short) 0xBFFF;
|
|
|
|
RGBForeColor(&color);
|
|
}
|
|
|
|
//-------------------------------------------------------------- GrayForeColor
|
|
|
|
// This function finds the closest match to a "medium gray" in theÉ
|
|
// current palette and sets the pen color to that.
|
|
|
|
void GrayForeColor (void)
|
|
{
|
|
RGBColor color;
|
|
|
|
color.red = (unsigned short) 0x7FFF;
|
|
color.green = (unsigned short) 0x7FFF;
|
|
color.blue = (unsigned short) 0x7FFF;
|
|
|
|
RGBForeColor(&color);
|
|
}
|
|
|
|
//-------------------------------------------------------------- DkGrayForeColor
|
|
|
|
// This function finds the closest match to a "dark gray" in theÉ
|
|
// current palette and sets the pen color to that.
|
|
|
|
void DkGrayForeColor (void)
|
|
{
|
|
RGBColor color;
|
|
|
|
color.red = (unsigned short) 0x3FFF;
|
|
color.green = (unsigned short) 0x3FFF;
|
|
color.blue = (unsigned short) 0x3FFF;
|
|
|
|
RGBForeColor(&color);
|
|
}
|
|
|
|
//-------------------------------------------------------------- RestoreColorsSlam
|
|
|
|
// This function forces the Macintosh to rebuild the palette. It isÉ
|
|
// called to restore a sense or normality after some serious mungingÉ
|
|
// with the palette.
|
|
|
|
void RestoreColorsSlam (void)
|
|
{
|
|
RestoreDeviceClut(nil);
|
|
PaintBehind(nil, GetGrayRgn());
|
|
DrawMenuBar();
|
|
}
|
|
|