CSC151.02 2010S Functional Problem Solving : Reference
Primary: [Front Door] [Schedule] - [Academic Honesty] [Instructions]
Current: [Outline] [EBoard] [Reading] [Lab] - [Assignment] [Quiz]
Groupings: [Assignments] [EBoards] [Examples] [Exams] [Handouts] [Labs] [Outlines] [Projects] [Quizzes] [Readings]
References: [A-Z] [By Topic] - [Scheme Report (R5RS)] [R6RS] [TSPL4]
Related Courses: [CSC151.01 2010S (Weinman)] [CSC151 2009F (Rebelsky)]
Misc: [SamR] [MediaScript] [GIMP]
(image-new
width
height
)
(image-load
filename
)
(image-save
image
fname
)
image
in the specified file
(which should provide the full path to the file). The type
of the image (JPEG, GIF, PNG, etc.) is determined by the suffix
of the file name.
(image-show
image
)
(image-height
image
)
(image-width
image
)
(image-blot!
image
col
row
)
(image-draw-line!
image
col1
row1
col2
row2
)
(image-get-pixel
image
column
row
)
(image-set-pixel!
image
column
row
rgb-color
)
(image-transform-pixel!
image
column
row
func
)
col
,row
)
in image
by applying
func
to its old color and setting that
pixel to the resulting color.
(image-calculate-pixels!
image
fun
fun
to
the column and row.
fun
should have the
form (lambda (col row) color)
.
Unlike image-compute-pixels!
, which can compute
pixels in any order, image-calculate-pixels!
is
guaranteed to do a row-by-row, left-to-right scan through
the image. However, image-calculate-pixels!
is likely to be slower than image-compute-pixels!
(although faster than coding the iteration yourself).
(image-compute
pos2color
width
height
)
pos2color
(a function of the form (lambda (col row) color)
)
to compute the color at each position in the image. compute
(image-compute-pixels!
image
pos2color
)
function
to the position of the pixel.
function
must have
the form (lambda (col row) expression-to-compute-color)
.
(image-scan
image
proc!
)
proc!
the the
column, row, and color at each position. proc!
should have the form (lambda (col row color) ...)
.
In contrast to many of the other image iteration procedures,
image-scan
is guaranteed to scan row-by-row
from top-to-bottom, scanning each row from left to right.
(image-transform!
image
fun
)
image
in place by setting
each pixel to the result of applying fun
to
that current pixel color.
(image-variant
image
fun
)
image
, each of whose pixels is computed
by applying fun
to the color of the
corresponding pixel in image
.
(region-calculate-pixels!
image
left
top
width
height
fun
fun
at
each position in the region.
fun
should have the
form (lambda (col row) color)
.
Unlike region-compute-pixels!
, which can compute
pixels in any order, region-calculate-pixels!
is
guaranteed to do a row-by-row, left-to-right scan through
the image. However, region-calculate-pixels!
is likely to be slower than region-compute-pixels!
(although faster than coding the iteration yourself).
(region-compute-pixels!
image
left
top
width
height
pos2color
)
function
to the position of the pixel.
function
must be a function of
the form (lambda (col row) expression-to-compute-color)
.
(region-scan
image
left
top
width
height
proc!
)
proc!
at
each position in the region. proc!
should have the
form (lambda (col row color) ...)
. In contrast to
many of the other region procedures, region-scan
is
guaranteed to scan row-by-row from top-to-bottom, scanning each
row from left to right.
(image-select-all!
image
)
(image-select-ellipse!
image
selection-type
left
top
width
height
)
left
, top margin is
top
, width is width
and height is height
.
If selection-type
is
REPLACE
, the ellipse replaces the
current selection. If selection-type
is ADD
, the ellipse is added to the
current selection. If selection-type
is SUBTRACT
, the ellipse is subtracted from
the current selection. If selection-type
is INTERSECT
, the ellipse is intersected
with the current selection (that is, only points that are in
both the current selection and the ellipse remain selected).
(image-select-inverse!
image
)
(image-select-nothing!
image
)
(image-select-polygon!
image
selection-type
positions
)
position-new
).
If selection-type
is
REPLACE
, the polygon replaces the
current selection. If selection-type
is ADD
, the polygon is added to the
current selection. If selection-type
is SUBTRACT
, the polygon is subtracted from
the current selection. If selection-type
is INTERSECT
, the polygon is intersected
with the current selection (that is, only points that are in
both the current selection and the polygon remain selected).
(image-select-rectangle!
image
selection-type
left
top
width
height
)
left
, top margin is
top
, width is width
and height is height
.
If selection-type
is
REPLACE
, the rectangle replaces the
current selection. If selection-type
is ADD
, the rectangle is added to the
current selection. If selection-type
is SUBTRACT
, the rectangle is subtracted from
the current selection. If selection-type
is INTERSECT
, the rectangle is intersected
with the current selection (that is, only points that are in
both the current selection and the rectangle remain selected).
(image-fill-selection!
image
)
(image-stroke-selection!
image
)
Primary: [Front Door] [Schedule] - [Academic Honesty] [Instructions]
Current: [Outline] [EBoard] [Reading] [Lab] - [Assignment] [Quiz]
Groupings: [Assignments] [EBoards] [Examples] [Exams] [Handouts] [Labs] [Outlines] [Projects] [Quizzes] [Readings]
References: [A-Z] [By Topic] - [Scheme Report (R5RS)] [R6RS] [TSPL4]
Related Courses: [CSC151.01 2010S (Weinman)] [CSC151 2009F (Rebelsky)]
Misc: [SamR] [MediaScript] [GIMP]
Copyright (c) 2007-10 Janet Davis, Matthew Kluber, Samuel A. Rebelsky, and Jerod Weinman. (Selected materials copyright by John David Stone and Henry Walker and used by permission.)
This material is based upon work partially supported by the National Science Foundation under Grant No. CCLI-0633090. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.
This work is licensed under a Creative Commons
Attribution-NonCommercial 2.5 License. To view a copy of this
license, visit http://creativecommons.org/licenses/by-nc/2.5/
or send a letter to Creative Commons, 543 Howard Street, 5th Floor,
San Francisco, California, 94105, USA.