TendrilsSchemeDoc.tioga
Copyright Ó 1989 by Xerox Corporation. All rights reserved.
Michael Plass, December 2, 1991 4:52 pm PST
March 24, 1989
PCedar 2.0 — FOR INTERNAL XEROX USE ONLY
TendrilsScheme
More operations for Cedar Scheme
Michael F. Plass
© Copyright 1989 Xerox Corporation. All rights reserved.
Abstract: A collection of bits and pieces that still need to find a permanent home.
Created by: Michael F. Plass
Maintained by: Michael F. Plass <Plass.pa>
Keywords: Interpreter, LISP, Scheme, FFT, Interpress
XEROX  Xerox Corporation
   Palo Alto Research Center
   3333 Coyote Hill Road
   Palo Alto, California 94304

For Internal Xerox Use Only
Introduction
To make available the Scheme functions described in this document, evaluate the Scheme expression
(load "Tendrils")
Refer to SchemeDoc for more information about Scheme.
Interpress Input/Output
These are implemented by the module SchemeInterpressImpl.
open-interpress-output file-name  [Function]
Create an Interpress output handle.
declare-interpress-value interpress-output-handle object  [Function]
Declares a value (font, pixel-array, color, color-operator, etc.) that is likely to be used multiple times, so that it need be placed into the interpress master only once.
write-interpress-page interpress-output-handle page-action  [Function]
Write an interpress page; page-action takes one argument, the imager context to image into. The initial coordinate system of this context is meters.
close-interpress-output interpress-output-handle  [Function]
Close an Interpress output handle.
interpress-output? object  [Function]
Test for an Interpress output handle.
open-interpress-input file-name  [Function]
Opens an Interpress master for input.
interpress-input-page-count interpress-input-handle  [Function]
Returns the number of pages in the interpress master.
interpress-input? object  [Function]
Test for an Interpress input handle.
interpret-interpress-page interpress-input-handle page-number context  [Function]
Interpret an Interpress page into an imager context. The coordinate system is assumed to be in meters.
close-interpress-input interpress-input-handle  [Function]
Close an Interpress input handle.
xerox-compress-pixel-array pixel-array  [Function]
Make a xerox/compressed pixel-array from a one-bit-per-pixel pixel-array.
write-raster-encoding-standard-file filename res-description  [Function]
Creates a Xerox Raster Encoding Standard file. res-description is a list containing entries of the form:
(header string)
(image-scale (x-scale y-scale))
(x-dimension number)
(y-dimension number)
(mask-image pixel-array)
(color-image pixel-array)
(color-operator color-operator)
(image-properties image-property-list)
read-raster-encoding-standard-file filename  [Function]
Reads a Xerox Raster Encoding Standard file and returns an res-description as taken by write-raster-encoding-standard-file.
write-restricted-res output-port pixel-array resolution as-mask? [ name-string ]  [Function]
Creates a Xerox Restricted Raster Encoding Standard file. pixel-array should be a bitmap; resolution is in bits per inch; if as-mask?, the bitmap will be in the mask-image component; otherwise it will be in the color-image component with a gray-linear color operator.
The following are implemented by InterpressUtil.scheme, which must be explicitly loaded.
write-interpress filename thunk  [Function]
Makes a one-page interpress master; thunk should draw a picture to *default-context*, in point units.
read-ais-as-res filename white-pixel black-pixel  [Function]
Reads an AIS file, making an res-description (see above).
read-interpress-page filename page-number  [Function]
Makes a thunk that draws a picture to *default-context*, in point units.
add-filename-extension filename ext  [Function]
Strips directory, replaces or provides filename extension.
interpress->compressed filename [ page-number ... ] [Function]
Converts an interpress master to one that consists of compressed bitmaps; the output file gets an extension of ".cip". If page-number arguments are sullpied, only those pages are converted; otherwise the whole master is converted. The output resolution is controlled by the global res-bpi (default 300).
interpress->res filename compress? [ page-number ... ] [Function]
Converts an Interpress master to restricted RES (raster encoding standard) files. If compress? is true, the bitmaps will be a maskImage in the Xerox/Compressed encoding; otherwise they will be a colorImage in the packed encoding.
... finish this someday
Viewer Context Input
A viewer context a context that was created by the viewer-context function. The functions in this section just return #f unless the context argument is a viewer context. For an example of the use of these functions, refer to the file "Paint.scheme".
Getting the next input event
viewer-read &optional context  [Function]
Waits for mouse input from the viewer, and returns a list in one of the following forms:
(buttondown x y button ctrlshift)
Sent whenever a mouse button goes down. x and y are the mouse position in client coordinates, button is one of the symbols left, middle, or right, and ctrlshift encodes the control and left-shift keys as (+ (if ctrl 2 0) (if shift 1 0)).
(buttonup x y button ctrlshift)
Like buttondown, but sent whenever a mouse button goes up.
(mouseto x y ctrlshift)
Like buttondown, but sent whenever the mouse position changes while one or more of the buttons is down.
(erased width height)
Sent whenever the viewer contents are cleared for any reason, such as when the window manager moves or reshapes the viewer. width and height are the current width and height of the viewer in client coordinates.
(destroyed)
Sent when the viewer is destroyed.
The following functions are also provided for mnemonic access to input events:
event-kind event  [Function]
Returns one of buttondown, buttonup, mouseto, erased, or destroyed, as appropriate.
event-x event  [Function]
event-y event  [Function]
Returns the appropriate coordinate or, for erased events, the width or height, respectively.
event-button event  [Function]
Returns the button parameter for buttondown and buttonup events.
event-shift event  [Function]
Returns the ctrlshift parameter for buttondown, buttonup, and mouseto events.
Testing for available viewer input
viewer-input-ready? &optional context  [Function]
Returns #t if (viewer-read context) would succeed without having to wait.
FFT
Types
This package supports both one and two dimensional FFTs. For compact representation, a Scheme Vector object type is provided to represent vectors of complex numbers without having to pay the level of indirection; these behave like normal vectors to Scheme, except that an attempt to store a non-number signals an error, and also the numbers become inexact when stored.
Truth
#<primitive make-complex-vector: (k z) make a vector to hold inexact complex numbers>
#<primitive complex-vector?: (a) Test for a complex-vector>
#<primitive complex-vector-copy: (a) Copy a complex-vector>
#<primitive f-f-transform-rows!: (list inverse-bool) do in-situ FFT on elements of the list>
#<primitive in-situ-transpose!: (a) Transpose a square image>
#<primitive transpose: (a) Transpose an image>
#<primitive f-f-transform-image!: (square-image inverse-bool) do 2-D in-situ FFT on square image>
#<primitive complex-image-from-pixelmap: (pixelmap layer) make a list-of-complex-vector representation of an image>
#<primitive pixelmap-from-complex-image: (image) make a pixelmap representation of magnitude and phase of an image>
#<primitive complex-vector-transfer-real!: (dst src start end) transfer real parts>
#<primitive complex-vector-transfer-imaginary!: (dst src start end) transfer imaginary parts>
#<primitive complex-vector-transfer-magnitude!: (dst src start end) transfer magnitudes>
#<primitive complex-vector-transfer-angle!: (dst src start end) transfer angles>
#<primitive complex-vector-clip!: (v eps) set non-(positive-real)s to 0>
Operations
make-complex-vector size initial-value  [Proc]
Returns a complex-vector that can hold size elements, and answers #t to vector?
... finish this someday