IPColorImpl.mesa
Last edited by:
Doug Wyatt, July 7, 1983 11:53 am
DIRECTORY
IPBasic USING [Integer, Operator, Vector],
IPErrors USING [AppearanceWarning, MasterError, MasterWarning],
IPImager USING [Imager, Vars],
IPImagerBasic USING [Color, ColorRep, PixelArray, PixelArrayRep, Transformation],
IPImagerOps USING [],
IPState USING [State, StateRep],
Real USING [RoundC];
IPColorImpl: CEDAR PROGRAM
IMPORTS IPErrors, Real
EXPORTS IPImagerOps, IPBasic
= BEGIN OPEN IPImagerBasic, IPBasic;
State: TYPE = IPState.State;
StateRep: PUBLIC TYPE = IPState.StateRep; -- export to IPBasic
MakePixelArray: PUBLIC PROC[xPixels, yPixels: Integer,
samplesPerPixel, maxSampleValue: Integer,
samplesInterleaved: BOOL,
m: Transformation, samples: Vector]
RETURNS[PixelArray] = {
pa: PixelArray = NEW[PixelArrayRep ← [xPixels: xPixels, yPixels: yPixels,
maxSampleValue: maxSampleValue, samplesPerPixel: samplesPerPixel,
samplesInterleaved: samplesInterleaved, m: m, samples: samples]];
RETURN[pa];
};
FindDecompressor: PUBLIC PROC[self: State, v: Vector] RETURNS[Operator] = {
ERROR IPErrors.MasterError[Unimplemented];
};
MakeGray: PUBLIC PROC[f: REAL] RETURNS[Color] = {
IF f<0 THEN { SIGNAL IPErrors.MasterWarning[InvalidArgs]; f ← 0 };
IF f>1 THEN { SIGNAL IPErrors.MasterWarning[InvalidArgs]; f ← 1 };
{ x: CARDINAL = Real.RoundC[(1-f)*LAST[CARDINAL]];
RETURN[NEW[ColorRep[constant] ← [constant[r: x, g: x, b: x]]]]
};
};
FindColor: PUBLIC PROC[self: State, v: Vector] RETURNS[Color] = {
SIGNAL IPErrors.MasterWarning[Unimplemented];
RETURN[MakeGray[0]];
};
FindColorOperator: PUBLIC PROC[self: State, v: Vector] RETURNS[Operator] = {
ERROR IPErrors.MasterError[Unimplemented];
};
FindColorModelOperator: PUBLIC PROC[self: State, v: Vector] RETURNS[Operator] = {
ERROR IPErrors.MasterError[Unimplemented];
};
MakeSampledBlack: PUBLIC PROC[pa: PixelArray, um: Transformation,
transparent: BOOLFALSE] RETURNS[Color] = {
RETURN[NEW[ColorRep[sampled][0] ← [sampled[
transparent: transparent, pa: pa, m: um, colorMap: ]]]];
SIGNAL IPErrors.AppearanceWarning[Unimplemented];
RETURN[MakeGray[0.5]];
};
MakeSampledColor: PUBLIC PROC[pa: PixelArray, um: Transformation,
colorOperator: Operator] RETURNS[Color] = {
SIGNAL IPErrors.MasterWarning[Unimplemented];
RETURN[MakeGray[0]];
};
SetGray: PUBLIC PROC[self: State, f: REAL] = {
imager: IPImager.Imager = self.imager;
vars: IPImager.Vars = imager.vars;
vars.color ← MakeGray[f];
};
END.