From: Chris Hanson Date: Fri, 24 Jul 1992 23:39:59 +0000 (+0000) Subject: Define STREAM-FIRST and STREAM-REST. Rewrite Pictures section of X-Git-Tag: 20090517-FFI~9200 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=2107106503562d5fd8c319441be2b0d539a5d7ae;p=mit-scheme.git Define STREAM-FIRST and STREAM-REST. Rewrite Pictures section of Graphics chapter. --- diff --git a/v7/doc/ref-manual/scheme.texinfo b/v7/doc/ref-manual/scheme.texinfo index 743b75178..f8418ce15 100644 --- a/v7/doc/ref-manual/scheme.texinfo +++ b/v7/doc/ref-manual/scheme.texinfo @@ -65,7 +65,7 @@ @ifinfo This file documents the MIT Scheme system. -Copyright @copyright{} 1988, 1989, 1990, 1991 Massachusetts Institute of Technology +Copyright @copyright{} 1988-92 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and Computer @@ -104,9 +104,9 @@ literature without prior written consent from MIT in each case. @titlepage @title{MIT Scheme Reference Manual} -@subtitle Edition 1.1 +@subtitle Edition 1.2 alpha @subtitle for Scheme Release 7.1.3 -@subtitle November 1991 +@subtitle July 1992 @author by Chris Hanson @author the MIT Scheme Team @author and a cast of thousands @@ -114,7 +114,7 @@ literature without prior written consent from MIT in each case. @page @vskip 0pt plus 1filll -Copyright @copyright{} 1988, 1989, 1990, 1991 Massachusetts Institute of Technology +Copyright @copyright{} 1988-92 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and Computer @@ -162,6 +162,7 @@ facilities available for developing programs in MIT Scheme, and the @end ifinfo @menu +* Acknowledgements:: Acknowledgements * Overview:: Overview * Special Forms:: Special Forms * Equivalence Predicates:: Equivalence Predicates @@ -390,12 +391,20 @@ Graphics * Custom Graphics Operations:: Custom Graphics Operations * X Graphics:: X Graphics * Starbase Graphics:: Starbase Graphics +* Pictures:: Pictures (MIT 6.001 implementation only) X Graphics * X Graphics Type:: X Graphics Type * Utilities for X Graphics:: Utilities for X Graphics * Custom Operations on X Graphics Devices:: Custom Operations on X Graphics Devices + +Pictures (MIT 6.001 implementation only) + +* Construction of Pictures:: Construction of Pictures +* Manipulating Pictures:: Manipulating Pictures +* Displaying Pictures:: Displaying Pictures +* Saving and Restoring Pictures:: Saving and Restoring Pictures @end menu @node Acknowledgements, Overview, Top, Top @@ -7650,22 +7659,26 @@ promise. Otherwise returns @code{#f}. This could have been defined by @end deffn @deffn {procedure+} stream-car stream +@deffnx {procedure+} stream-first stream @findex car @findex head Returns the first element in @var{stream}. @code{stream-car} is equivalent to @code{car}.@footnote{@code{head}, a synonym for @code{stream-car}, is provided for compatibility with old code; use -@code{stream-car} in new code.} +@code{stream-car} in new code.} @code{stream-first} is a synonym for +@code{stream-car}. @end deffn @deffn {procedure+} stream-cdr stream +@deffnx {procedure+} stream-rest stream @findex force @findex cdr @findex tail Returns the first tail of @var{stream}. Equivalent to @code{(force (cdr @var{stream}))}.@footnote{@code{tail}, a synonym for @code{stream-cdr}, is provided for compatibility with old code; use -@code{stream-cdr} in new code.} +@code{stream-cdr} in new code.} @code{stream-rest} is a synonym for +@code{stream-cdr}. @end deffn @deffn {procedure+} stream-null? stream @@ -11669,8 +11682,8 @@ operations, such as control of colors. * Clipping of Graphics Output:: Clipping of Graphics Output * Custom Graphics Operations:: Custom Graphics Operations * X Graphics:: X Graphics -* Pictures:: Pictures (MIT 6.001 implementation only) * Starbase Graphics:: Starbase Graphics +* Pictures:: Pictures (MIT 6.001 implementation only) @end menu @node Opening and Closing of Graphics Devices, Coordinates for Graphics, Graphics, Graphics @@ -12039,7 +12052,7 @@ For information on the custom operations for a particular device, see the documentation for its type. @end deffn -@node X Graphics, Pictures, Custom Graphics Operations, Graphics +@node X Graphics, Starbase Graphics, Custom Graphics Operations, Graphics @section X Graphics @cindex X graphics @@ -12300,141 +12313,7 @@ These procedures extract components of objects of type in documentation of the @code{XLoadQueryFont} Xlib call. @end deffn -@node Pictures, Starbase Graphics, X Graphics, Graphics -@section Pictures (MIT 6.001 implementation only) - -@cindex pictures -A `picture' data object is a two-dimensional array of floating point -numbers that represents a grey-scale image on the screen. The grey -level that the value of each element represents is determined relative -to the range of values of the array. - -The width of a picture is the number of elements in each row and the height is -the number of elements in each column. The elements are referenced by giving -the horizontal component first and the vertical one second, with the origin at -the bottom left corner of the displayed picture. - -Coordinates (i,j) are "valid coordinates" of picture p if and only if: - - i,j are both exact integers and - 0 <= i < (picture-width p) and 0 <= j < (picture-height p) - -@subsection Construction of Pictures - -@findex make-picture -@deffn {procedure+} make-picture X Y [K] - Returns a picture of width X and height Y. If K is specified then each - picture element is initialized to K, otherwise the value of each is - unspecified. X and Y must be exact integers and K must be real (if - specified). -@end deffn - -@findex procedure->picture -@deffn {procedure+} procedure->picture X Y F - F must be a real-valued function of two variables. - Returns a picture of width X and height Y, such that the value of each - element is the value of F at its indices, in floating point notation. - -@example -@group -(picture-ref (procedure->picture width height f) i j) -@result{} (exact->inexact (f i j)) for all valid coordinates (i,j) -@end group -@end example -@end deffn - -@cindex pgm-file -@findex pgm-file->picture -@deffn {procedure+} pgm-file->picture FILENAME - Converts a grey-scale image stored in pgm format into a picture whose - graphical representation will closely resemble that of the saved image. -@end deffn - -@subsection Selecting Picture Components - -@findex picture? -@deffn {procedure+} picture? OBJECT - Returns `#t' if OBJECT is a picture, otherwise returns `#f'. Note that - this means that the type-descriptor for OBJECT must be `eq?' to that of - the picture-type for this procedure to return `#t'. -@end deffn - -@findex picture-width -@findex picture-height -@deffn {procedure+} picture-width PICTURE -@deffnx {procedure+} picture-height PICTURE - These procedures return the width and height, respectively, of PICTURE. -@end deffn - -@findex picture-min -@findex picture-max -@deffn {procedure+} picture-min PICTURE -@deffnx {procedure+} picture-max PICTURE - These procedures return the least and the greatest values stored in - PICTURE. -@end deffn - -@findex picture-ref -@deffn {procedure+} picture-ref PICTURE I J - Returns the value of element (I,J) of PICTURE (always a floating point - number). I and J must both be valid coordinates of PICTURE. -@end deffn - -@findex picture-set! -@deffn {procedure+} picture-set! PICTURE I J K - Stores K at element (I,J) in PICTURE and returns an unspecified value. - K must be a real number and I and J must be valid coordinates of PICTURE. -@end deffn - -@subsection Picture Operations - -@findex picture-map -@deffn {procedure+} picture-map F PICTURE ... - F must be an n-ary function where n is the number of PICTURE arguments - passed to picture-map, and each PICTURE argument must have the same - dimensions. Returns a newly allocated picture with each element containing - the value of F applied to the list of corresponding elements of the - PICTURE arguments. - - i.e. (picture-ref (picture-map f p1 p2 ... ) i j) - => (f (picture-ref p1 i j) (picture-ref p2 i j) ... ). -@end deffn - -@subsection Displaying and Saving Pictures - - To display pictures, a scheme graphics window must first be created. - Although, any scheme window may be used, the colormap will not be - guaranteed to be correct for grey-scale pictures, therefore the - recommended way of creating windows for displaying pictures is to use the - MAKE-WINDOW procedure. - -@findex picture-display -@deffn {procedure+} picture-display W PICTURE [MIN [MAX]] - Displays, in the window W, the largest integer scaling of PICTURE that - can be contained in W. If MIN and MAX are specified then the grey levels - will be computed using these values as PICTURE's minimum and maximum - values, otherwise the actual least and greatest values of PICTURE will be - used. The value returned by this procedure is unspecified. -@end deffn - -@cindex pgm-file -@findex picture->pgm-file -@deffn {procedure+} picture->pgm-file PICTURE FILENAME - Saves the contents of PICTURE in a file in the current directory with the - name FILENAME. The PICTURE is written in pgm format. If FILENAME - already exists, then it will be lost after evaluating this procedure. -@end deffn - -@subsection Windows for Pictures - -@findex make-window -@deffn {procedure+} make-window W H X Y - Returns a scheme graphics device of width W, height H and screen-position - X,Y (as would be given in an X geometry string) with a grey scale colormap - attached. -@end deffn - -@node Starbase Graphics, , Pictures, Graphics +@node Starbase Graphics, Pictures, X Graphics, Graphics @section Starbase Graphics @cindex starbase graphics @@ -12540,6 +12419,153 @@ These operations alter the current values of the text characteristics. They have no effect on text drawn prior to their invocation. @end defop +@node Pictures, , Starbase Graphics, Graphics +@section Pictures (MIT 6.001 implementation only) + +@cindex pictures +A @dfn{picture} data object is a two-dimensional array of real numbers +that represents a grey-scale image on the screen. The grey level that +the value of each element represents is determined relative to the range +of values of the array. + +The width of a picture is the number of elements in each row and the +height is the number of elements in each column. The elements are +referenced by giving the horizontal component first and the vertical one +second, with the origin at the bottom left corner of the displayed +picture. + +Coordinates (@var{i},@var{j}) are @dfn{valid coordinates} of picture +@var{p} if and only if: + +@example +@group +(and (exact-nonnegative-integer? @var{i}) + (exact-nonnegative-integer? @var{j}) + (< @var{i} (picture-width @var{p})) + (< @var{j} (picture-height @var{p}))) +@end group +@end example + +@menu +* Construction of Pictures:: Construction of Pictures +* Manipulating Pictures:: Manipulating Pictures +* Displaying Pictures:: Displaying Pictures +* Saving and Restoring Pictures:: Saving and Restoring Pictures +@end menu + +@node Construction of Pictures, Manipulating Pictures, Pictures, Pictures +@subsection Construction of Pictures + +@code{make-picture} and @code{procedure->picture} are simple ways to +make pictures. @code{picture-map} is a way to create a new picture by +applying a procedure to one or more pictures. Pictures can also be made +by reading files: see @code{pgm-file->picture}. + +@deffn {procedure+} make-picture x y [k] +@var{X} and @var{y} must be exact positive integers and @var{k}, if +specified, must be a real number. Returns a picture of width @var{x} +and height @var{y}. If @var{k} is specified then each picture element +is initialized to @var{k}, otherwise the elements are unspecified. +@end deffn + +@deffn {procedure+} procedure->picture x y f +@var{X} and @var{y} must be exact positive integers, and @var{f} must be +a real-valued procedure of two variables. Returns a picture of width +@var{x} and height @var{y}, where the value of each element is the +result of applying @var{f} to the element's coordinates. +@end deffn + +@deffn {procedure+} picture-map f picture @dots{} +@var{F} must be a procedure, and each @var{picture} argument must have +the same dimensions. Returns a newly allocated picture, each element of +which is obtained by calling @var{f}, passing it as arguments the +corresponding element of each @var{picture} argument. (Thus @var{f} +must accept the same number of arguments as there are @var{picture} +arguments to @code{picture-map}.) + +In other words, each element could have been initialized as follows: + +@example +@group +(picture-set! @var{result} @var{i} @var{j} + (@var{f} (picture-ref @var{picture} @var{i} @var{j}) @dots{})) +@end group +@end example +@end deffn + +@node Manipulating Pictures, Displaying Pictures, Construction of Pictures, Pictures +@subsection Manipulating Pictures + +@deffn {procedure+} picture? object +Returns @code{#t} if @var{object} is a picture, otherwise returns +@code{#f}. +@end deffn + +@deffn {procedure+} picture-width picture +@deffnx {procedure+} picture-height picture +These procedures return the width and height, respectively, of +@var{picture}. +@end deffn + +@deffn {procedure+} picture-min picture +@deffnx {procedure+} picture-max picture +These procedures return, respectively, the least and the greatest values +stored in @var{picture}. +@end deffn + +@deffn {procedure+} picture-ref picture i j +Returns the value of element (@var{i},@var{j}) of @var{picture} (always +a real number). @var{I} and @var{j} must be valid coordinates for +@var{picture}. +@end deffn + +@deffn {procedure+} picture-set! picture i j k +Stores @var{k} at element (@var{i},@var{j}) in @var{picture} and returns +an unspecified value. @var{K} must be a real number and @var{I} and +@var{j} must be valid coordinates for @var{picture}. +@end deffn + +@node Displaying Pictures, Saving and Restoring Pictures, Manipulating Pictures, Pictures +@subsection Displaying Pictures + +To display pictures, a scheme graphics window must first be created. +Although, any scheme window may be used, the colormap will not be +guaranteed to be correct for grey-scale pictures, therefore the +recommended way of creating windows for displaying pictures is to use +the @code{make-window} procedure. + +@deffn {procedure+} picture-display w picture [min [max]] +Displays, in the window @var{w}, the largest integer scaling of +@var{picture} that can be contained in @var{w}. If @var{min} and +@var{max} are specified then the grey levels will be computed using +these values as @var{picture}'s minimum and maximum values, otherwise +the actual least and greatest values of @var{picture} will be used. The +value returned by this procedure is unspecified. +@end deffn + +@deffn {procedure+} make-window w h x y +Returns a scheme graphics device of width @var{w}, height @var{h} and +screen position @var{x},@var{y} (as would be given in an X geometry +string) with a grey-scale colormap attached. +@end deffn + +@node Saving and Restoring Pictures, , Displaying Pictures, Pictures +@subsection Saving and Restoring Pictures + +Pictures can be read from or written to files in @sc{pgm} format using +the following procedures. + +@deffn {procedure+} pgm-file->picture pathname +Reads a grey-scale image stored in @sc{pgm} format from the file +@var{pathname}, returning a picture whose graphical representation will +closely resemble that of the saved image. +@end deffn + +@deffn {procedure+} picture->pgm-file picture pathname +Saves @var{picture} in @sc{pgm} format in the file @var{pathname}. +Overwrites any previously existing file of that name. +@end deffn + @node Procedure Index, Concept Index, Graphics, Top @unnumbered Index of Procedures, Special Forms, and Variables @printindex fn