Next: , Previous: Audio, Up: Top   [Contents][Index]


10 SDL_gfx by Andreas Schiffler

10.1 Graphics Primitives

Procedure: draw-point surface x y color

On surface, draw a point at location x,y with color color.

Procedure: draw-hline surface x1 x2 y color

On surface, draw a horizontal line segment from x1,y to x2,y, with color color.

Procedure: draw-vline surface x y1 y2 color

On surface, draw a vertical line segment from x,y1 to x,y2, with color color.

Procedure: draw-rectangle surface x1 y1 x2 y2 color [fill]

On surface, draw a rectangle with opposite points x1,y1 and x2,y2, with color color. Optional arg fill means to fill the rectangle as well.

Procedure: draw-rounded-rectangle surface x1 y1 x2 y2 rad color [fill]

On surface, draw a rectangle with opposite points x1,y1 and x2,y2, with rounded corners radius rad in color color. Optional arg fill means to fill the rectangle as well.

Procedure: draw-line surface x1 y1 x2 y2 color

On surface, draw a line segment from x1,y1 to x2,y2, with color color.

Procedure: draw-aa-line surface x1 y1 x2 y2 color

On surface, draw an anti-aliased line segment from x1,y1 to x2,y2, with color color.

Procedure: draw-thick-line surface x1 y1 x2 y2 width color

On surface, draw a line segment from x1,y1 to x2,y2, with thickness width in color color.

Procedure: draw-arc surface x y r start end color

On surface, draw arc with center x,y and radius r, going from start to end (degrees), with color color.

If start is greater than end, the effective range of the arc is taken to be end to start (that is, these arguments are internally reversed).

Procedure: draw-circle surface x y r color [fill]

On surface, draw a circle with center x,y and radius r, with color color. Optional arg fill means to fill the circle as well.

Procedure: draw-aa-circle surface x y r color

On surface, draw an anti-aliased circle with center x,y and radius r, with color color.

Procedure: draw-ellipse surface x y rx ry color [fill]

On surface, draw an ellipse with center x,y x-radius rx, y-radius ry, with color color. Optional arg fill means to fill the ellipse as well.

Procedure: draw-aa-ellipse surface x y rx ry color

On surface, draw an anti-aliased ellipse with center x,y, x-radius rx, y-radius ry, with color color.

Procedure: draw-pie-slice surface x y rad start end color [fill]

On surface, draw a pie slice with center x,y and radius rad, going from start to end (degrees), with color color. Optional arg fill means to fill the slice as well.

Procedure: draw-trigon surface x1 y1 x2 y2 x3 y3 color [fill]

On surface, draw a triangle with vertices at x1,y1, x2,y2 and x3,y3, with color color. Optional arg fill means to fill the triangle as well.

Procedure: draw-aa-trigon surface x1 y1 x2 y2 x3 y3 color

On surface, draw an anti-aliased triangle with vertices at x1,y1, x2,y2 and x3,y3, with color color.

Procedure: draw-polygon surface vx vy color [fill]

On surface, draw a polygon whose points are specified by corresponding pairs from the s16 uniform vectors vx and vy, in color color. Optional arg fill means to fill the polygon as well.

Procedure: draw-aa-polygon surface vx vy color

On surface, draw an anti-aliased polygon whose points are specified by corresponding pairs from the s16 uniform vectors vx and vy, in color color.

Procedure: draw-textured-polygon surface vx vy texture tdx tdy

On surface, draw a polygon whose points are specified by corresponding pairs from the s16 uniform vectors vx and vy, filling from texture (a surface) with offset tdx, tdy.

Procedure: draw-bezier surface vx vy s color

On surface, draw a bezier curve whose points are specified by corresponding pairs from the s16 uniform vectors vx and vy, with s steps in color color.

Procedure: draw-character surface x y c color

On surface at position x,y, draw char c with color (a number).

Procedure: draw-string surface x y text color

On surface at position x,y, draw string text with color (a number).

Procedure: font-rotation! rotation

Set the rotation for glyphs drawn by draw-character and draw-string to rotation (an integer or symbol), one of:

0  none
1  clockwise
2  upside-down
3  counter-clockwise

10.2 Rotation / Zooming

Procedure: roto-zoom-surface surface angle [zoom [smooth]]

Return a new surface made from rotating surface by angle degrees. Optional third arg zoom (default value 1.0) changes the size as well. Optional fourth arg smooth turns on anti-aliasing.

Procedure: roto-zoom-surface-xy surface angle [zoomx [zoomy [smooth]]]

Return a new surface made from rotating surface by angle degrees. Optional third and fourth args zoomx and zoomy (default value 1.0 for both) changes the size as well. Optional fifth arg smooth turns on anti-aliasing.

Procedure: zoom-surface surface zoomx [zoomy [smooth]]

Return a new scaled copy of surface. zoomx and zoomy specify the scaling factor. If omitted, zoomy defaults to zoomx. Optional fourth arg smooth turns on anti-aliasing.

Procedure: shrink-surface surface factorx factory

Return a new shrunken copy of surface. factorx and factory are positive integers specifying the inverse scaling factor. For example, 2 means half size, 3 means one-third size, etc.

The returned surface is antialiased by “averaging the source box RGBA or Y information” and is in 32-bit RGBA format.

10.3 Managing Frame Rate

Procedure: make-fps-manager [n]

Return a FPS manager object to be passed as the first arg to fps-manager-set!, fps-manager-get and fps-manager-delay!. Optional arg n specifies the value in Hz to initialize the object (default 30 if not specified).

Procedure: fps-manager-set! mgr n

Arrange for FPS manager mgr to try to maintain a frame rate of n Hz. Return #f if not successful.

Procedure: fps-manager-get mgr

Return the frame rate of FPS manager mgr in Hz, or #f if unsuccessful.

Procedure: fps-manager-delay! mgr

Request an appropriate delay from FPS manager mgr.

10.4 RGBA Extras

Procedure: set-pixel-alpha! surface alpha

If surface is 32-bit, set each pixel’s alpha value to alpha, an integer 0-255, inclusive, and return #t. Otherwise, do nothing and return #f.

Procedure: blit-rgba src srect dst drect

Blit from 32-bit surface src rectangle srect to 32-bit surface dst rectangle drect. Return #t if there are no problems.

Note that unlike blit-surface (see Video), all arguments must be fully specified. This restriction may be relaxed in the future.

10.5 Image Filtering

Procedure: imfi-mmx? [setting]

If setting is #t, enable MMX instructions for the image filter procs (if possible); if #f, disable; otherwise do nothing. Return the (boolean) value of the setting afterwards.

Procedure: imfi-add src1 src2 dst

D = saturation255 (S1 + S2).

Procedure: imfi-mean src1 src2 dst

D = S1/2 + S2/2.

Procedure: imfi-sub src1 src2 dst

D = saturation0 (S1 - S2).

Procedure: imfi-abs-diff src1 src2 dst

D = | S1 - S2 |.

Procedure: imfi-mult src1 src2 dst

D = saturation (S1 * S2).

Procedure: imfi-mulnor src1 src2 dst

D = S1 * S2 (non-MMX).

Procedure: imfi-muldiv2 src1 src2 dst

D = saturation255 (S1/2 * S2).

Procedure: imfi-muldiv4 src1 src2 dst

D = saturation255 (S1/2 * S2/2).

Procedure: imfi-logand src1 src2 dst

D = S1 & S2.

Procedure: imfi-logior src1 src2 dst

D = S1 | S2.

Procedure: imfi-div src1 src2 dst

D = S1 / S2 (non-MMX).

Procedure: imfi-not src dst

D = !S.

Procedure: imfi-add-c src dst c

D = saturation255 (S + C).

Procedure: imfi-add-c-to-half src dst c

D = saturation255 (S/2 + C).

Procedure: imfi-sub-c src dst c

D = saturation0 (S - C).

Procedure: imfi-ashr src dst n

D = saturation0 (S >> N).

Procedure: imfi-lshr src dst n

D = saturation0 ((uint) S >> N).

Procedure: imfi-mul-c src dst c

D = saturation255 (S * C).

Procedure: imfi-ashr-mul-c src dst n c

D = saturation255 ((S >> N) * C).

Procedure: imfi-bshl src dst n

D = (S << N).

Procedure: imfi-lshl src dst n

D = ((uint) S << N).

Procedure: imfi-ashl src dst n

D = saturation255 (S << N).

Procedure: imfi-binarize src dst t

D = (S < T ? 0 : 255).

Procedure: imfi-clip src dst tmin tmax

D = (Tmin <= S <= Tmax) ? 255 : 0.

Procedure: imfi-normalize-linear src dst cmin cmax nmin nmax

D = saturation255 ((Nmax - Nmin) / (Cmax - Cmin) * (S - Cmin) + Nmin).


Next: , Previous: Audio, Up: Top   [Contents][Index]