Graphics
(require (planet "image.ss" ("kazzmir" "allegro.plt")))
Function list
arc-screen/translucent
arc-screen
arc/translucent
arc
calculate-spline
circle-fill-screen/translucent
circle-fill-screen
circle-fill/translucent
circle-fill
circle-screen/translucent
circle-screen
circle/translucent
circle
clear-screen
clear
color
copy-masked-screen
copy-masked-stretch-screen
copy-masked-stretch
copy-masked
copy-screen
copy-stretch-screen
copy-stretch
copy
create-from-file
create-sub-screen
create-sub
create
destroy
draw-character-screen
draw-character
draw-gouraud-screen
draw-gouraud
draw-horizontal-flip-screen
draw-horizontal-flip
draw-lit
draw-pivot-scaled-screen
draw-pivot-scaled-vertical-flip-screen
draw-pivot-scaled-vertical-flip
draw-pivot-scaled
draw-pivot-screen
draw-pivot-vertical-flip-screen
draw-pivot-vertical-flip
draw-pivot
draw-rotate-scaled-screen
draw-rotate-scaled-vertical-flip-screen
draw-rotate-scaled-vertical-flip
draw-rotate-scaled
draw-rotate-screen
draw-rotate-vertical-flip-screen
draw-rotate-vertical-flip
draw-rotate
draw-screen
draw-stretched
draw-translucent
draw-vertical-flip-screen
draw-vertical-flip
draw-vertical-horizontal-flip-screen
draw-vertical-horizontal-flip
draw
duplicate-screen
duplicate
ellipse-fill-screen/translucent
ellipse-fill-screen
ellipse-fill/translucent
ellipse-fill
ellipse-screen/translucent
ellipse-screen
ellipse/translucent
ellipse
fastline-screen/translucent
fastline-screen
fastline/translucent
fastline
floodfill-screen/translucent
floodfill-screen
floodfill/translucent
floodfill
get-rgb
getpixel-screen
getpixel
height
line-screen/translucent
line-screen
line/translucent
line
mask-color-screen
mask-color
polygon-screen/translucent
polygon-screen
polygon/translucent
polygon3d-screen/translucent
polygon3d-screen
polygon3d/translucent
polygon3d
polygon
print-center-screen
print-center
print-screen
print-translucent
print
putpixel-screen/translucent
putpixel-screen
putpixel/translucent
putpixel
quad3d-screen/translucent
quad3d-screen
quad3d/translucent
quad3d
rectangle-fill-screen/translucent
rectangle-fill-screen
rectangle-fill/translucent
rectangle-fill
rectangle-screen/translucent
rectangle-screen
rectangle/translucent
rectangle
save-screen
save
screen
spline-screen/translucent
spline-screen
spline/translucent
spline
triangle-screen/translucent
triangle-screen
triangle/translucent
triangle3d-screen/translucent
triangle3d-screen
triangle3d/translucent
triangle3d
triangle
width
Structure list
(define-struct image (bitmap width height))
Image is a collection of width, height, and an opaque bitmap type which represents a rectangular set of pixels.
The normal struct accessors are not provided, however. Instead use the width and height functions provided by image.ss.
top
(define-struct v3d (x y z u v c))
v3d
is a structure that represents a 3d coordinate( x
, y
, z
) with texture mapped coordinates( u
, v
), and a color c
.
All the normal define-struct
accessors are provided, make-v3d
, v3d-x
, v3d-y
, v3d-z
, v3d-u
, v3d-v
, v3d-c
, but you cannot mutate a v3d.
top
procedure: (width image) :: num
Returns the width of an image.
top
procedure: (height image) :: num
Returns the height of an image.
(define-struct image (bitmap width height))
top
procedure: (screen) :: image
A special image that represents the current graphics context. This image can be used in every context any other image can be used, except for destroying it, but screen
is physically different from images created by the user. screen
is a video bitmap whereas other images are memory bitmaps. Memory bitmaps live entirely in RAM and can be accessed very quickly but video bitmaps live in the graphics card's memory and mutating that memory from software is quite slow. Therefore it is best to always draw on a memory bitmap and then copy the memory bitmap to the screen in one swoop with copy.
top
procedure: (create width height [depth]) :: image
Create an image with the specified width
and height
. If depth
is given the image will use that for the number of bits per pixel, otherwise it will default to what the current graphics context uses. If there is not enough memory to create the image #f will be returned. Unless you are creating exceptionally large images you should not normally run out of memory.
top
procedure: (color red green blue) :: num
Convert the three parts of a pixel, red
, green
, and blue
into a single value that can be used wherever a color is required such as putpixel.
0 <= red
<= 255
0 <= green
<= 255
0 <= blue
<= 255
;; black (color 0 0 0) ;; white (color 255 255 255) ;; magic pink, the masking color (color 255 0 255)
top
procedure: (get-rgb color) :: (values red green blue)
Convert a color into the three color components, red, green, and blue.
top
procedure: (create-from-file filename) :: image
Load an image from disk and return it. This image is treated exactly the same as if it was created with create except the initial pixels are copied from the file. It is perfectly safe to mutate this image.
top
procedure: (create-sub image x y width height) :: image
Create a new image which is a cut out of the parent image. x
,y
is the upper left hand corner of the new image and width
, height
are the width and height respectively. 0,0 of the new image is the equivalent to x
,y
of the parent image. Any changes made to the sub bitmap are reflected in the parent bitmap. This is useful for create a very large bitmap and sectioning parts off to give to various functions that want to deal with absolute coordinates.
(define m (create-sub (screen) 100 100 20 20)) ;; the next two lines do the same exact thing (rectangle m 2 2 12 12 (color 255 0 0)) (rectangle (screen) 102 102 114 114 (color 255 0 0))
top
procedure: (create-sub-screen x y width height) :: image
Exactly like create-sub except the first argument is implicitly screen.
top
procedure: (putpixel image x y color) :: void
Set the pixel on image
at x
, y
to color
.
top
procedure: (putpixel-screen x y color) :: void
Exactly like putpixel except the first argument is implicitly screen.
top
procedure: (putpixel/translucent image red green blue alpha x y color) :: void
Like putpixel but use red
, blue
, green
, and alpha
to set the translucency. See set-trans-blender! and set-drawing-mode-translucent!.
top
procedure: (putpixel-screen/translucent red green blue alpha x y color) :: void
Exactly like putpixel/translucent except the first argument is implicitly screen.
top
procedure: (getpixel image x y) :: num
Get the value of the pixel on image
at x
, y
top
procedure: (getpixel-screen x y) :: num
Exactly like getpixel except the first argument is implicitly screen.
top
procedure: (quad3d image type texture v1 v2 v3 v4) :: void
Draw a 3d quad onto image
. texture
will be painted on the face of the quad. type
should be one of
texture :: image v1 :: v3d v2 :: v3d v3 :: v3d v4 :: v3d
'POLYTYPE-FLAT
= A simple flat shaded polygon, taking the color from the c
value of the first vertex. This polygon type is affected by the drawing mode( set-drawing-mode-solid!, set-drawing-mode-translucent!, set-drawing-mode-xor! ), so it can be used to render XOR or translucent polygons.'POLYTYPE-GCOL
= A single-color gouraud shaded polygon. The colors for each vertex are taken from the c
value, and interpolated across the polygon.'POLYTYPE-GRGB
= A gouraud shaded polygon which interpolates RGB triplets rather than a single color. The colors for each vertex are taken from the c
value, which is interpreted as a 24-bit RGB triplet (0xFF0000 is red, 0x00FF00 is green, and 0x0000FF is blue).'POLYTYPE-ATEX
= An affine texture mapped polygon. This stretches the texture across the polygon with a simple 2d linear interpolation, which is fast but not mathematically correct. It can look ok if the polygon is fairly small or flat-on to the camera, but because it doesn't deal with perspective foreshortening, it can produce strange warping artifacts.'POLYTYPE-PTEX
= A perspective-correct texture mapped polygon. This uses the z
value from the vertex structure as well as the u
/v
coordinates, so textures are displayed correctly regardless of the angle they are viewed from. Because it involves division calculations in the inner texture mapping loop, this mode is a lot slower than 'POLYTYPE-ATEX
.'POLYTYPE-ATEX-MASK
= Like 'POLYTYPE-ATEX
but pixels with a value of 0 are skipped.'POLYTYPE-PTEX-MASK
= Like 'POLYTYPE-PTEX
but pixels with a value of 0 are skipped.'POLYTYPE-ATEX-LIT
= Like 'POLYTYPE-ATEX
but blends the pixels using the light level taken from the c
component of each vertex according to how set-trans-blender! was used.'POLYTYPE-PTEX-LIT
= Like 'POLYTYPE-PTEX
but blends the pixels using the light level taken from the c
component of each vertex according to how set-trans-blender! was used.'POLYTYPE-ATEX-MASK-LIT
= A combination of 'POLYTYPE-ATEX-LIT
and 'POLYTYPE-ATEX-MASK
.'POLYTYPE-PTEX-MASK-LIT
= A combination of 'POLYTYPE-PTEX-LIT
and 'POLYTYPE-PTEX-MASK
.'POLYTYPE-ATEX-TRANS
= Like 'POLYTYPE-ATEX
but renders the texture translucently according to how set-trans-blender! was used.'POLYTYPE-PTEX-TRANS
= Like 'POLYTYPE-PTEX
but renders the texture translucently according to how set-trans-blender! was used.'POLYTYPE-ATEX-MASK-TRANS
= A combination of 'POLYTYPE-ATEX-MASK
and 'POLYTYPE-ATEX-TRANS
.'POLYTYPE-PTEX-MASK-TRANS
= A combination of 'POLYTYPE-PTEX-MASK
and 'POLYTYPE-PTEX-TRANS
.
All the rest act the same as their respective name minus the /ZBUF but these types account for z-buffering to cull quads that don't need to be drawn.
'POLYTYPE-FLAT/ZBUF
'POLYTYPE-GCOL/ZBUF
'POLYTYPE-GRGB/ZBUF
'POLYTYPE-ATEX/ZBUF
'POLYTYPE-PTEX/ZBUF
'POLYTYPE-ATEX-MASK/ZBUF
'POLYTYPE-PTEX-MASK/ZBUF
'POLYTYPE-ATEX-LIT/ZBUF
'POLYTYPE-PTEX-LIT/ZBUF
'POLYTYPE-ATEX-MASK-LIT/ZBUF
'POLYTYPE-PTEX-MASK-LIT/ZBUF
'POLYTYPE-ATEX-TRANS/ZBUF
'POLYTYPE-PTEX-TRANS/ZBUF
'POLYTYPE-ATEX-MASK-TRANS/ZBUF
'POLYTYPE-PTEX-MASK-TRANS/ZBUF
top
procedure: (quad3d-screen type texture v1 v2 v3 v4) :: void
Exactly like quad3d except the first argument is implicitly screen.
top
procedure: (quad3d/translucent image red green blue alpha type texture v1 v2 v3 v4) :: void
Like quad3d but use red
, blue
, green
, and alpha
to set the translucency. See set-trans-blender! and set-drawing-mode-translucent!.
top
procedure: (quad3d-screen/translucent red green blue alpha type texture v1 v2 v3 v4) :: void
Exactly like quad3d/translucent except the first argument is implicitly screen.
top
procedure: (polgyon3d image type texture v3ds) :: void
Like quad3d except v3ds
is a list of at least 3 v3d's.
top
procedure: (polygon3d-screen type texture v3ds) :: void
Exactly like polygon3d except the first argument is implicitly screen.
top
procedure: (polygon3d/translucent image red green blue alpha type texture v3ds) :: void
Like polygon3d but use red
, blue
, green
, and alpha
to set the translucency. See set-trans-blender! and set-drawing-mode-translucent!.
top
procedure: (polygon3d-screen/translucen red green blue alpha type texture v3ds) :: void
Exactly like polygon3d/translucent except the first argument is implicitly screen.
top
procedure: (triangle3d image type texture v1 v2 v3) :: void
Like quad3d except there are only 3 vertexes, v1
, v2
, and v3
.
top
procedure: (triangle3d-screen type texture v1 v2 v3) :: void
Exactly like triangle3d except the first argument is implicitly screen.
top
procedure: (triangle3d/translucent image red green blue alpha type texture v1 v2 v3) :: void
Like triangle3d but use red
, blue
, green
, and alpha
to set the translucency. See set-trans-blender! and set-drawing-mode-translucent!.
top
procedure: (triangle3d-screen/translucent image red green blue alpha type texture v1 v2 v3) :: void
Exactly like triangle3d/translucent except the first argument is implicitly screen.
top
procedure: (mask-color image) :: num
Return the masking color of an image. This is always (color 255 0 255)
but the function is provided for your convienence.
top
procedure: (mask-color-screen) :: num
Return the masking color of the screen.
top
procedure: (destroy image) :: void
Destroy an image that was created by the user( basically anything except screen ).
top
procedure: (duplicate image) :: image
Create a new image and copy the contents from image
onto it.
top
procedure: (duplicate-screen) :: image
Exactly like duplicate except the first argument is implicitly screen.
top
procedure: (line image x1 y1 x2 y2 color) :: void
Draw a straight line from x1
,y1
to x2
,y2
using color
for the pixel value. Clipping will be performed if the coordinates do not lie within image
's area.
top
procedure: (line-screen x1 y1 x2 y2 color) :: void
Exactly like line except the first argument is implicitly screen.
top
procedure: (line/translucent image red green blue alpha x1 y1 x2 y2 color) :: void
Like line but use red
, blue
, green
, and alpha
to set the translucency. See set-trans-blender! and set-drawing-mode-translucent!.
top
procedure: (line-screen/translucent red green blue alpha x1 y1 x2 y2 color) :: void
Exactly like line/translucent except the first argument is implicitly screen.
top
procedure: (fastline image x1 y1 x2 y2 color) :: void
Much like line except clipping is performed slightly differently in an optimized fashion.
top
procedure: (fastline-screen x1 y1 x2 y2 color) :: void
Exactly like fastline except the first argument is implicitly screen.
top
procedure: (fastline/translucent image red green blue alpha x1 y1 x2 y2 color) :: void
Like fastline but use red
, blue
, green
, and alpha
to set the translucency. See set-trans-blender! and set-drawing-mode-translucent!.
top
procedure: (fastline-screen/translucent red green blue alpha x1 y1 x2 y2 color) :: void
Exactly like fastline/translucent except the first argument is implicitly screen.
top
procedure: (polygon image points color) :: void
Draws a polygon with an arbitrary list of coordinates onto image
using color
as the pixel values.points
should be a flat list of coordinates pairs. The length of points
must be even.
;; draw a red triangle with vertexes at (10,10), (20, 20), and (50,50) (polygon some-image '(10 10 20 20 50 50) (color 255 0 0))
top
procedure: (polygon-screen points color) :: void
Exactly like polygon except the first argument is implicitly screen.
top
procedure: (polygon/translucent image red green blue alpha points color) :: void
Like polygon but use red
, blue
, green
, and alpha
to set the translucency. See set-trans-blender! and set-drawing-mode-translucent!.
top
procedure: (polygon-screen/translucent red green blue alpha points color) :: void
Exactly like polygon/translucent except the first argument is implicitly screen.
top
procedure: (arc image x y angle1 angle2 radius color) :: void
Draws a circular arc with center x
, y
in an anticlockwise direction starting from the angle angle1
and ending when it reaches angle2
. The angles range from 0 to 256, with 256 equal to a full circle, 64 a right angle, etc. Zero is to the right of the center point, and larger values rotate anticlockwise from there. Example:
;; draw a white arc from 4 to 1 o'clock (arc (screen) 100 100 21 43 50 (color 255 255 255))
top
procedure: (arc-screen x y angle1 angle2 radius color) :: void
Exactly like arc except the first argument is implicitly screen.
top
procedure: (arc/translucent image red green blue alpha x y angle1 angle2 radius color) :: void
Like arc but use red
, blue
, green
, and alpha
to set the translucency. See set-trans-blender! and set-drawing-mode-translucent!.
top
procedure: (arc-screen/translucent red green blue alpha x y angle1 angle2 radius color) :: void
Exactly like arc/translucent except the first argument is implicitly screen.
top
procedure: (calculate-spline x1 y1 x2 y2 x3 y3 x4 y4 points) :: list-of x,y pairs
Calculates a series of npts values along a bezier spline, return them as a list of x,y pairs. The bezier curve is specified by the four x/y control points in the points array: x1
, y1
contain the coordinates of the first control point, x2
, y2
are the second point, etc. Control points 1 and 4 are the ends of the spline, and points 2 and 3 are guides. The curve probably won't pass through points 2 and 3, but they affect the shape of the curve between points 1 and 4 (the lines p1-p2 and p3-p4 are tangents to the spline). The easiest way to think of it is that the curve starts at p1, heading in the direction of p2, but curves round so that it arrives at p4 from the direction of p3. In addition to their role as graphics primitives, spline curves can be useful for constructing smooth paths around a series of control points.
;; calculate 4 points (calculate-spline 1 1 10 10 5 9 20 3 4) -> ((1 . 1) (7 . 7) (10 . 7) (20 . 3)) ;; calculate 20 points (calculate-spline 1 1 10 10 5 9 20 3 20) -> ((1 . 1) (2 . 2) (3 . 4) (4 . 5) (5 . 5) (6 . 6) (6 . 7) (7 . 7) (7 . 7) (8 . 8) (9 . 8) (9 . 8) (10 . 7) (11 . 7) (12 . 7) (13 . 6) (14 . 5) (16 . 5) (18 . 4) (20 . 3))
top
procedure: (spline image x1 y1 x2 y2 x3 y3 x4 y4 color) :: void
Draws a bezier spline using the four control points specified by x1
, y1
, x2
, y2
, x3
, y3
, x4
, y4
. Read the description of calculate-spline for information on how the spline is generated.
top
procedure: (spline-screen x1 y1 x2 y2 x3 y3 x4 y4 color) :: void
Exactly like spline except the first argument is implicitly screen.
top
procedure: (spline/translucent image red green blue alpha x1 y1 x2 y2 x3 y3 x4 y4 color) :: void
Like spline but use red
, blue
, green
, and alpha
to set the translucency. See set-trans-blender! and set-drawing-mode-translucent!.
top
procedure: (spline-screen/translucent red green blue alpha x1 y1 x2 y2 x3 y3 x4 y4 color) :: void
Exactly like spline/translucent except the first argument is implicitly screen.
top
procedure: (floodfill image x y color) :: void
Fill image
with the specified color
starting at x
, y
. All pixels with the same value at x
, y
that can be traced back to x
, y
without going over a gap will be overwritten with color
.
top
procedure: (floodfill-screen x y color) :: void
Exactly like floodfill except the first argument is implicitly screen.
top
procedure: (floodfill/translucent image red green blue alpha x y color) :: void
Like floodfill but use red
, blue
, green
, and alpha
to set the translucency. See set-trans-blender! and set-drawing-mode-translucent!.
top
procedure: (floodfill-screen/translucent red green blue alpha x y color) :: void
Exactly like floodfill/translucent except the first argument is implicitly screen.
top
procedure: (triangle image x1 y1 x2 y2 x3 y3 color) :: void
Draw a filled triangle on image
using x1
, y1
, x2
, y2
, x3
, y3
as the vertexes with a pixel value of color
.
top
procedure: (triangle-screen x1 y1 x2 y2 x3 y3 color) :: void
Exactly like triangle except the first argument is implicitly screen.
top
procedure: (triangle/translucent image x1 y1 x2 y2 x3 y3 color) :: void
Like triangle but use red
, blue
, green
, and alpha
to set the translucency. See set-trans-blender! and set-drawing-mode-translucent!.
top
procedure: (triangle-screen/translucent x1 y1 x2 y2 x3 y3 color) :: void
Exactly like triangle/translucent except the first argument is implicitly screen.
top
procedure: (circle image x y radius color) :: void
Draw a circle on image
at x
, y
with radius
and a pixel value of color
.
top
procedure: (circle-screen x y radius color) :: void
Exactly like circle except the first argument is implicitly screen.
top
procedure: (circle/translucent image red green blue alpha x y radius color) :: void
Like circle but use red
, blue
, green
, and alpha
to set the translucency. See set-trans-blender! and set-drawing-mode-translucent!.
top
procedure: (circle-screen/translucent red green blue alpha x y radius color) :: void
Exactly like circle/translucent except the first argument is implicitly screen.
top
procedure: (circle-fill image x y radius color) :: void
Draws a filled circle on image
at x
, y
with radius
and a pixel value of color
.
top
procedure: (circle-fill-screen x y radius color) :: void
Exactly like circle-fill except the first argument is implicitly screen.
top
procedure: (circle-fill/translucent image red green blue alpha x y radius color) :: void
Like circle-fill but use red
, blue
, green
, and alpha
to set the translucency. See set-trans-blender! and set-drawing-mode-translucent!.
top
procedure: (circle-fill-screen/translucent red green blue alpha x y radius color) :: void
Exactly like circle-fill/translucent except the first argument is implicitly screen.
top
procedure: (ellipse image x y rx ry color) :: void
Draw an ellipse on image
at x
, y
with an x radius of rx
and a y radius of ry
using a pixel value of color
.
top
procedure: (ellipse-screen x y rx ry color) :: void
Exactly like ellipse except the first argument is implicitly screen.
top
procedure: (ellipse/translucent image red green blue alpha x y rx ry color) :: void
Like ellipse but use red
, blue
, green
, and alpha
to set the translucency. See set-trans-blender! and set-drawing-mode-translucent!.
top
procedure: (ellipse-screen/translucent red green blue alpha x y rx ry color) :: void
Exactly like ellipse/translucent except the first argument is implicitly screen.
top
procedure: (ellipse-fill image x y rx ry color) :: void
Draw a filled ellipse on image
at x
, y
with an x radius of rx
and a y radius of ry
using a pixel value of color
.
top
procedure: (ellipse-fill-screen x y rx ry color) :: void
Exactly like ellipse-fill except the first argument is implicitly screen.
top
procedure: (ellipse-fill/translucent image red green blue alpha x y rx ry color) :: void
Like ellipse-fill but use red
, blue
, green
, and alpha
to set the translucency. See set-trans-blender! and set-drawing-mode-translucent!.
top
procedure: (ellipse-fill-screen/translucent red green blue alpha x y rx ry color) :: void
Exactly like ellipse-fill/translucent except the first argument is implicitly screen.
top
procedure: (rectangle image x1 y1 x2 y2 color) :: void
Draw a rectangle on image
from x1
,y1
to x2
,y2
with a pixel value of color
.
top
procedure: (rectangle-screen x1 y1 x2 y2 color) :: void
Exactly like rectangle except the first argument is implicitly screen.
top
procedure: (rectangle/translucent image red green blue alpha x1 y1 x2 y2 color) :: void
Like rectangle but use red
, blue
, green
, and alpha
to set the translucency. See set-trans-blender! and set-drawing-mode-translucent!.
top
procedure: (rectangle-screen/translucent red green blue alpha x1 y1 x2 y2 color) :: void
Exactly like rectangle/translucent except the first argument is implicitly screen.
top
procedure: (rectangle-fill image x1 y1 x2 y2 color) :: void
Draw a filled rectangle on image
from x1
,y1
to x2
,y2
with a pixel value of color
.
top
procedure: (rectangle-fill-screen x1 y1 x2 y2 color) :: void
Exactly like rectangle-fill except the first argument is implicitly screen.
top
procedure: (rectangle-fill/translucent image red green blue alpha x1 y1 x2 y2 color) :: void
Like rectangle-fill but use red
, blue
, green
, and alpha
to set the translucency. See set-trans-blender! and set-drawing-mode-translucent!.
top
procedure: (rectangle-fill-screen/translucent red green blue alpha x1 y1 x2 y2 color) :: void
Exactly like rectangle-fill/translucent except the first argument is implicitly screen.
top
procedure: (print image x y color background-color message) :: void
Print message
on image
starting at x
,y
. The foreground color will be color
and the backgrond color will be background-color
. If you pass -1 for the background-color
then the background will be left alone.
;; print hello world in red text (print some-image 20 30 (color 255 0 0) -1 "Hello World!")
top
procedure: (print-screen x y color background-color message) :: void
Exactly like print-screen except the first argument is implicitly screen.
top
procedure: (print-translucent image x y color alpha message) :: void
Print message
onto image
starting at x
, y
with an transparency level of alpha
.
0 <= alpha
<= 255
Where 0 = translucent and 255 = opaque.
top
procedure: (print-center image x y color background-color message) :: void
Like print except x
, y
will be the middle of the string instead of the left hand side.
top
procedure: (print-center-screen x y color background-color message) :: void
Exactly like print-center except the first argument is implicitly screen.
top
procedure: (clear image [color]) :: void
Set all pixels on image
to color
. If color
is not specified it defaults to (color 0 0 0)
, black.
top
procedure: (clear-screen) ::
Exactly like clear except the first argument is implicitly screen.
top
procedure: (draw image sprite x y) :: void
sprite :: image
Copy sprite
onto image
starting at x
, y
but not overwriting pixels in image
when the pixel value in sprite
is (color 255 0 255), the masking color.
top
procedure: (draw-screen sprite x y) :: void
Exactly like draw except the first argument is implicitly screen.
top
procedure: (draw-translucent image sprite [x] [y]) :: void
Like draw except sprite
is drawn translucently. Call set-trans-blender! at some point before using this function. If x
and y
are not given they default to 0, 0.
top
procedure: (draw-lit image sprite [x] [y] [alpha]) :: void
Like draw except sprite
is drawn with a lightning level of alpha
. Call set-trans-blender! at some point before using this function. If x
, y
, and alpha
are not given they default to 0, 0, 0.
top
procedure: (draw-vertical-flip image sprite x y) :: void
Like draw but flip sprite
over the x-axis in the middle of the sprite.
top
procedure: (draw-vertical-flip-screen sprite x y) :: void
Exactly like draw-vertical-flip except the first argument is implicitly screen.
top
procedure: (draw-horizontal-flip image sprite x y) :: void
Like draw but sprite
is flipped over the y-axis in the middle of the sprite.
top
procedure: (draw-horizontal-flip-screen sprite x y) :: void
Exactly like draw-horizontal-flip-screen except the first argument is implicitly screen.
top
procedure: (draw-vertical-horizontal-flip image sprite x y) :: void
A combination of draw-vertical-flip and draw-horizontal-flip.
top
procedure: (draw-vertical-horizontal-flip-screen sprite x y) :: void
Exactly like draw-vertical-horizontal-flip except the first argument is implicitly screen.
top
procedure: (draw-gouraud image sprite x y upper-left upper-right lower-left lower-right) :: void
0 <= upper-left
<= 255
0 <= upper-right
<= 255
0 <= lower-left
<= 255
0 <= lower-right
<= 255
Like draw-lit but the lighting is interpolated across the 4 corners.
top
procedure: (draw-gouraud-screen sprite x y upper-left upper-right lower-left lower-right) :: void
Exactly like draw-gouraud except the first argument is implicitly screen.
top
procedure: (draw-character image sprite x y color background) :: void
Draws sprite
onto image
starting at x
, y
but only using color
for the foreground pixels and transparent pixels in the background
color, or skipping them completely if backgrond
is -1.
;; draw logo silhouette in red (draw-character some-image logo 200 200 (color 255 0 0) -1)
top
procedure: (draw-character-screen sprite x y color background) :: void
Exactly like draw-character except the first argument is implicitly screen.
top
procedure: (draw-rotate image sprite x y angle) :: void
Like draw but rotate the sprite around its center using angle
.
0 <= angle
<= 255
0 lies on the positive x-axis, 64 on the positive y-axis, 128 on the negative x-axis, and 192 on the negative y-axis.
top
procedure: (draw-rotate-screen sprite x y angle) :: void
Exactly like draw-rotate except the first argument is implicitly screen.
top
procedure: (draw-rotate-vertical-flip image sprite x y angle) :: void
Like draw-rotate but sprite
is flipped over the x-axis.
top
procedure: (draw-rotate-vertical-flip-screen sprite x y angle) :: void
Exactly like draw-rotate-vertical-flip except the first argument is implicitly screen.
top
procedure: (draw-rotate-scaled image sprite x y angle scale) :: void
Like draw-rotate but sprite
is scaled as well according to scale
.
0 <= angle
<= 255
0 <= scale
<= +infinity
top
procedure: (draw-rotate-scaled-screen sprite x y angle scale) :: void
Exactly like draw-rotate-scaled-screen except the first argument is implicitly screen.
top
procedure: (draw-rotate-scaled-vertical-flip image sprite x y angle scale) :: void
Like draw-rotate-scaled but flipped over the x-axis.
top
procedure: (draw-rotate-scaled-vertical-flip-screen sprite x y angle scale) :: void
Exactly like draw-rotate-scaled-vertical-flip except the first argument is implicitly screen.
top
procedure: (draw-pivot image sprite x y center-x center-y angle) :: void
Draw sprite
onto image
at x
, y
rotating the sprite around center-x
, center-y
by angle
.
;; draw my-sprite onto some-image at 50,100 anchoring my-sprite at 5,5 ;; and rotating it 64 units( 90 degrees ) (draw-pivot some-image my-sprite 50 100 5 5 64)
top
procedure: (draw-pivot-screen image sprite x y center-x center-y angle) :: void
Exactly like draw-pivot except the first argument is implicitly screen.
top
procedure: (draw-pivot-vertical-flip image sprite x y center-x center-y angle) :: void
Like draw-pivot but flip sprite
over the x-axis.
top
procedure: (draw-pivot-vertical-flip-screen sprite x y center-x center-y angle) :: void
Exactly like draw-pivot-vertical-flip except the first argument is implicitly screen.
top
procedure: (draw-pivot-scaled image sprite x y center-x center-y angle scale) :: void
Like draw-pivot but scale sprite
as well.
top
procedure: (draw-pivot-scaled-screen sprite x y center-x center-y angle scale) :: void
Exactly like draw-pivot-scaled except the first argument is implicitly screen.
top
procedure: (draw-pivot-scaled-vertical-flip image sprite x y center-x center-y angle scale) :: void
A combination of draw-pivot-scaled and draw-pivot-vertical-flip.
top
procedure: (draw-pivot-scaled-vertical-flip-screen sprite x y center-x center-y angle scale) :: void
Exactly like draw-pivot-scaled-vertical-flip except the first argument is implicitly screen.
top
procedure: (copy image-dest image-src [x y] [width height] [dest-x dest-y]) :: void
Copy each pixel from image-src
to image-dest
. x
, y
, dest-x
, and dest-y
default to 0 if not given. width
and height
default to the dimensions of image-src
if not given.
x
, y
specify the upper left corner within image-src
to start copying pixels from.width
, height
specify the width and height respectively from x
, y
to copy from.dest-x
, dest-y
spcify the upper left corner within image-dest
to copy pixels to.
top
procedure: (copy image-src [x y] [width height] [dest-x dest-y]) :: void
Exactly like copy except the first argument is implicitly screen.
top
procedure: (copy-masked image-dest image-src [x y] [width height] [dest-x dest-y]) :: void
Like copy except masking pixels( (color 255 0 255)
) in image-src
are not copied to image-dest
.
top
procedure: (copy-masked-screen image-src [x y] [width height] [dest-x dest-y]) :: void
Exactly like copy-masked except the first argument is implicitly screen.
top
procedure: (copy-stretch image-dest image-src source-x source-y source-width source-height dest-x dest-y dest-width dest-height) :: void
Like copy except the area specified by source-x
, source-y
, source-width
, source-height
is copied in such a way to take up the area specified by dest-x
, dest-y
, dest-width
, dest-height
.
top
procedure: (copy-stretch-screen image-src source-x source-y source-width source-height dest-x dest-y dest-width dest-height) :: void
Exactly like copy-stretch except the first argument is implicitly screen.
top
procedure: (copy-masked-stretch image-dest image-src source-x source-y source-width source-height dest-x dest-y dest-width dest-height) :: void
Like copy-stretch but skip masking pixels like copy-masked.
top
procedure: (copy-masked-stretch-screen image-src source-x source-y source-width source-height dest-x dest-y dest-width dest-height) :: void
Exactly like copy-masked-stretch except the first argument is implicitly screen.
top
procedure: (draw-stretched image sprite x y width height) :: void
Draw sprite
onto image
like in draw but stretch the sprite so its width and height match that of width
and height
.
top
procedure: (save image filename) :: void
Save image
to a file named by filename
.
top
procedure: (save-screen filename) :: void
Exactly like save except the first argument is implicitly screen. Useful for screenshots.