ColorizeViewPointBackdoor.mesa
Copyright Ó 1989 by Xerox Corporation. All rights reserved.
Eric Nickell, May 17, 1989 10:46:06 pm PDT
Bob Coleman, September 6, 1990 12:47:05 pm PDT
DIRECTORY
ColorizeViewPoint, Profiles, Real, SymTab;
ColorizeViewPointBackdoor: CEDAR DEFINITIONS
IMPORTS Real
~ BEGIN
OPEN ColorizeViewPoint;
Registration Mechanisms
Colorization: TYPE ~ PROC [ip: ROPE, palette: Profiles.Profile, checkSystemSetting: CheckSystemSettingProc, mapData: MapData] RETURNS [newIP: ROPE];
InstallNewColorization: PROC [colorization: Colorization, setting: Setting];
colorization will be called to colorize masters
RegisterKeywords: PROC [keywordsList: LIST OF ROPE];
allows Colorizations to register keywords (to aid correct parsing of colorizing cmds)
Underlying Colorizations
ColorizeColorVP, ColorizeBasicGraphics, ColorizeProIllustrator, ColorizeText: Colorization;
All of these colorize the interpress ROPE to another interpress ROPE according to the palette.
Interacting With The Palette
SubpaletteSearchList: PROC [prefixesIn: LIST OF ROPE, profile: Profiles.Profile] RETURNS [allPrefixes: LIST OF ROPE];
makes a correctly ordered, unduplicated list of prefixes, including the custom palette, Colorization-specific prefixesIn , document-wide prefixes listed in profile, and the "Default"
GetRecursiveValue: PROC [key: ROPE, palette: Profiles.Profile, subpaletteList: LIST OF ROPE, mapData: MapData, levelsAllowed: INTINT.FIRST, customOnly, noMappings: BOOLFALSE] RETURNS [value: LIST OF ROPENIL, levelsExceeded: BOOLFALSE];
Looks up key in palette. Continues to recurse with palette values until final values are reached. EG, palette entry "0%A: c13" will not return c13 but will look up c13 & return "1.0 .6 .2". subpaletteList gives the ordered list of subpalettes to check for values. If levelsAllowed is defaulted, it sets to a reasonable value. If exceeded, levelsExceeded gets TRUE. levelsAllowed=-1 will return the key, parsed into it's lookupVal (eg, C04 returns as C4). levelsAllowed=0 returns the palette value w/o further lookup. If customOnly, only looks in mapping and custom palettes. If nomappings, doesn't apply mappings to values found
SetProfileBoolean: PROC [profile: Profiles.Profile, key: ROPE, val: BOOL];
Allows limited access to changing the palette on the fly: the ability to change a boolean setting.
Color Mapping
Color mapping allows easy, temporary altering of colorization to get a b&w version for handouts, a saturated color version for overheads, a gray level version, etc.
MappingProc: TYPE ~ PROC [valueIn: LIST OF ROPE, name: ROPE, palette: Profiles.Profile, data: REFNIL] RETURNS [mapped: LIST OF ROPE]; --takes, eg, an RGB value and returns a gray value of 1.0-(.253r+.684g+.063b). By convention, MappingProcs guarantee that values enclosed in {} will not be touched. name & data are from ColorMappingRep
ColorMapping: TYPE ~ REF ColorMappingRep;
ColorMappingRep: TYPE ~ RECORD [name: ROPE, mappingProc: MappingProc, setTrue: LIST OF ROPE, data: REFNIL, bad: BOOLFALSE]; --setTrue: some mappings need to register their activity by setting palette entries, eg "IP2: TRUE" for the mapping to Black&White. data may be needed by MappingProc. If mapping ever found bad (as in a bad formula supplied by user), bad is set.
MapData: TYPE ~ REF MapDataRep;
MapDataRep: TYPE ~ RECORD [installedMappings, requestedMappings: LIST OF ColorMapping, exceptionsPalette: Profiles.Profile--holds exceptions to the mappings--];
GetMappings: PROC [palette: Profiles.Profile] RETURNS [mapData: MapData];
gets mappings specified by current document
ApplyMappings: PROC [toMap: REF, palette: Profiles.Profile, mapData: MapData, mapOnly: ROPENIL, subpaletteList: LIST OF ROPENIL] RETURNS [mappedRope: ROPENIL, mappedList: LIST OF ROPENIL];
Can return either a ROPE or LIST OF ROPE. If mapOnly#NIL, just apply that single mapping
Utilities
SampledColorIPFragments: TYPE ~ RECORD [
beforeTransform, afterTransform: ROPENIL,
sweepAngleMod360: [0..360) ← 0, --Determines the angle for the transformation
removeDefiningObject: BOOLFALSE --Specifies whether to remove the object which spatially defines the sweep transformation
];
IPFragmentForColorSetting: PROC [def: LIST OF ROPE, palette: Profiles.Profile] RETURNS [frag: REF];
IPFragmentForColorDefinition: PROC [def: LIST OF ROPE, palette: Profiles.Profile] RETURNS [frag: REF];
Builds an interpress fragment from a list of tokens, e.g. as built by Profiles.ListOfToken.
frag NARROWs to either a Rope.ROPE or a REF SampledColorIPFragments.
IPRopeFromName: PROC [xeroxName: ROPE] RETURNS [header, ip: ROPE];
IPRopeFromRope: PROC [xeroxRope: ROPE] RETURNS [header, ip: ROPE];
xeroxName is a file name.
xeroxRope is a ROPE containing the ip master, including header
header is the Interpress header
ip is (probably) a RopeFile of the chars in the master
Neither header nor ip contain the delimiting space character
IO.RIS[rope: Rope.Cat[header, " ", ip]] provides an IO.STREAM equivalent to an FS.StreamOpen on xeroxName
CleanupUserCommands: PROC [commands: ROPE, palette: Profiles.Profile] RETURNS [cleanCommands: ROPE];
cleans up the Custom Colors commands found both in the document CustomColorsPage and in the rope slices handed into ColorizeViewPoint.Do (like printer messages). The intent is to allow users wide latitude in their custom color commands, and then use CleanupUserCommands to transform them into well-defined command specs.
LineProcessor: TYPE ~ PROC [line, in: ROPE] RETURNS [newLine: ROPENIL];
ProcessLinesMatching: PROC [pattern, in: ROPE, lineProcessor: LineProcessor] RETURNS [new: ROPE];
finds lines in "in" that match pattern and hands each line (and "in") to lineProcessor. lineProcessor hands back a newLine if it changed it, otherwise NIL.
AltRound: PROC [x: REAL] RETURNS [INT] ~ INLINE {RETURN [IF x<0.0 THEN Real.Fix[x-.5] ELSE Real.Fix[x+.5]]};
This is a proc to get around the fact that DCedar and PCedar rounding is different wrt decimals at exactly .5. DCedar rounds up or down depending on odd or even; PCedar always rounds up. We will emulate PCedar.
END.