2001-07-04 10:19:38 -04:00
|
|
|
;; author -> Norbert Freudemann
|
|
|
|
;; creation date : 18/06/2001
|
|
|
|
;; last change : 04/07/2001
|
|
|
|
|
2001-10-04 08:31:44 -04:00
|
|
|
;; clear-area paints a rectangular area in the specified window
|
|
|
|
;; according to the specified dimensions with the window's background
|
|
|
|
;; pixel or pixmap. If width/height is zero it is replaced by the
|
|
|
|
;; window's width/height - 1. See XClearArea.
|
2001-07-04 10:19:38 -04:00
|
|
|
|
2001-07-30 10:43:22 -04:00
|
|
|
(define (clear-area window x y width height exposures?)
|
2001-07-04 10:19:38 -04:00
|
|
|
(%clear-area (window-Xwindow window)
|
|
|
|
(display-Xdisplay (window-display window))
|
|
|
|
x y width height exposures?))
|
|
|
|
|
|
|
|
(import-lambda-definition %clear-area (Xwindow Xdisplay x y width height
|
|
|
|
exposures?)
|
2001-08-21 10:57:08 -04:00
|
|
|
"scx_Clear_Area")
|
2001-07-04 10:19:38 -04:00
|
|
|
|
2001-10-04 08:31:44 -04:00
|
|
|
;; copy-area combines the specified rectangle of src with the
|
|
|
|
;; specified rectangle of dest. See XCopyArea.
|
2001-07-04 10:19:38 -04:00
|
|
|
|
|
|
|
(define (copy-area src-drawable gcontext src-x src-y width height dst-drawable
|
|
|
|
dst-x dst-y)
|
|
|
|
(%copy-area (display-Xdisplay (drawable-display src-drawable))
|
|
|
|
(drawable-Xobject src-drawable)
|
|
|
|
(gcontext-Xgcontext gcontext)
|
|
|
|
src-x src-y width height
|
|
|
|
(drawable-Xobject dst-drawable)
|
|
|
|
dst-x dst-y))
|
|
|
|
|
|
|
|
(import-lambda-definition %copy-area (Xdisplay srcXdrawable Xgcontext srcx srcy
|
|
|
|
width height destXdrawable destx desty)
|
2001-08-21 10:57:08 -04:00
|
|
|
"scx_Copy_Area")
|
2001-07-04 10:19:38 -04:00
|
|
|
|
2001-10-04 08:31:44 -04:00
|
|
|
;; copy-plane uses a single bit plane of the specified source
|
|
|
|
;; rectangle combined with the specified GC to modify the specified
|
|
|
|
;; rectangle of dest. See XCopyPlane.
|
2001-07-04 10:19:38 -04:00
|
|
|
|
|
|
|
(define (copy-plane src-drawable gcontext plane src-x src-y width height
|
|
|
|
dst-drawable dst-x dst-y)
|
|
|
|
(%copy-plane (display-Xdisplay (drawable-display src-drawable))
|
|
|
|
(drawable-Xobject src-drawable)
|
|
|
|
(gcontext-Xgcontext gcontext)
|
|
|
|
plane
|
2001-10-30 09:31:36 -05:00
|
|
|
src-x src-y width height
|
2001-07-04 10:19:38 -04:00
|
|
|
(drawable-Xobject dst-drawable)
|
|
|
|
dst-x dst-y))
|
|
|
|
|
|
|
|
(import-lambda-definition %copy-plane (Xdisplay srcXdrawable Xgcontext plane
|
|
|
|
srcx srcy width height destXdrawable
|
|
|
|
destx desty)
|
2001-08-21 10:57:08 -04:00
|
|
|
"scx_Copy_Plane")
|
2001-07-04 10:19:38 -04:00
|
|
|
|
2001-10-04 08:31:44 -04:00
|
|
|
;; draw-point uses the foreground pixel and function components of the
|
|
|
|
;; GC to draw a single point into the specified drawable. A point is
|
|
|
|
;; specified as a pair (x . y). See XDrawPoint.
|
2001-07-04 10:19:38 -04:00
|
|
|
|
2001-10-04 08:31:44 -04:00
|
|
|
(define (draw-point drawable gcontext x-y)
|
2001-07-04 10:19:38 -04:00
|
|
|
(%draw-point (display-Xdisplay (drawable-display drawable))
|
|
|
|
(drawable-Xobject drawable)
|
|
|
|
(gcontext-Xgcontext gcontext)
|
2001-10-04 08:31:44 -04:00
|
|
|
(car x-y) (cdr x-y)))
|
2001-07-04 10:19:38 -04:00
|
|
|
|
|
|
|
(import-lambda-definition %draw-point (Xdisplay Xdrawable Xgcontext x y)
|
2001-08-29 10:43:49 -04:00
|
|
|
"scx_Draw_Point")
|
2001-07-04 10:19:38 -04:00
|
|
|
|
2001-10-04 08:31:44 -04:00
|
|
|
;; draw-points draws multiple points the same way as draw-point
|
|
|
|
;; does. The points have to be specified as a list of pairs. See
|
|
|
|
;; XDrawPoints.
|
2001-07-04 10:19:38 -04:00
|
|
|
|
2001-08-22 07:49:01 -04:00
|
|
|
(define (draw-points drawable gcontext points relative?)
|
2001-07-04 10:19:38 -04:00
|
|
|
(%draw-point (display-Xdisplay (drawable-display drawable))
|
|
|
|
(drawable-Xobject drawable)
|
|
|
|
(gcontext-Xgcontext gcontext)
|
2001-08-22 07:49:01 -04:00
|
|
|
(list->vector points)
|
2001-07-04 10:19:38 -04:00
|
|
|
relative?))
|
|
|
|
|
|
|
|
(import-lambda-definition %draw-points (Xdisplay Xdrawable Xgcontext vec
|
|
|
|
relative)
|
2001-08-21 10:57:08 -04:00
|
|
|
"scx_Draw_Points")
|
2001-07-04 10:19:38 -04:00
|
|
|
|
2001-10-04 08:31:44 -04:00
|
|
|
;; draw-line uses the components of the specified GC to draw a line
|
|
|
|
;; between the specified set of points (x1 . y1) and (x2 . y2). See
|
|
|
|
;; XDrawLine.
|
2001-07-04 10:19:38 -04:00
|
|
|
|
2001-10-04 08:31:44 -04:00
|
|
|
(define (draw-line drawable gcontext x-y-1 x-y-2)
|
2001-07-04 10:19:38 -04:00
|
|
|
(%draw-line (display-Xdisplay (drawable-display drawable))
|
|
|
|
(drawable-Xobject drawable)
|
|
|
|
(gcontext-Xgcontext gcontext)
|
2001-10-04 08:31:44 -04:00
|
|
|
(car x-y-1) (cdr x-y-1)
|
|
|
|
(car x-y-2) (cdr x-y-2)))
|
2001-07-04 10:19:38 -04:00
|
|
|
|
|
|
|
(import-lambda-definition %draw-line (Xdisplay Xdrawable Xgcontext x1 y1 x2 y2)
|
2001-08-21 10:57:08 -04:00
|
|
|
"scx_Draw_Line")
|
2001-07-04 10:19:38 -04:00
|
|
|
|
2001-10-04 08:31:44 -04:00
|
|
|
;; draw-lines uses the components of the specified GC to draw lines
|
|
|
|
;; between each pair of points (xi . yi) (xi+1 . yi+1) in the list
|
|
|
|
;; points. It draws the lines in the order given in the list. The
|
|
|
|
;; lines join correctly at all intermediate points, and if the first
|
|
|
|
;; and last points coincide, the first and last lines also join
|
|
|
|
;; correctly. See XDrawLines.
|
2001-07-04 10:19:38 -04:00
|
|
|
|
2001-08-22 07:49:01 -04:00
|
|
|
(define (draw-lines drawable gcontext points relative?)
|
2001-07-04 10:19:38 -04:00
|
|
|
(%draw-lines (display-Xdisplay (drawable-display drawable))
|
2001-08-29 10:43:49 -04:00
|
|
|
(drawable-Xobject drawable)
|
2001-07-04 10:19:38 -04:00
|
|
|
(gcontext-Xgcontext gcontext)
|
2001-08-22 07:49:01 -04:00
|
|
|
(list->vector points)
|
2001-07-04 10:19:38 -04:00
|
|
|
relative?))
|
|
|
|
|
|
|
|
(import-lambda-definition %draw-lines (Xdisplay Xdrawable Xgcontext vec rel)
|
2001-08-21 10:57:08 -04:00
|
|
|
"scx_Draw_Lines")
|
2001-07-04 10:19:38 -04:00
|
|
|
|
2001-10-04 08:31:44 -04:00
|
|
|
;; draw-segments function draws multiple, unconnected lines. The
|
|
|
|
;; points have to be specified as list of lists of 4 integers (x1 y1
|
|
|
|
;; x2 y2). Use points->segments to convert a list of points into a
|
|
|
|
;; list of segments. See XDraw Segements.
|
2001-07-04 10:19:38 -04:00
|
|
|
|
2001-08-29 10:43:49 -04:00
|
|
|
(define (draw-segments drawable gcontext points)
|
|
|
|
(%draw-segments (display-Xdisplay (drawable-display drawable))
|
2001-07-04 10:19:38 -04:00
|
|
|
(drawable-Xobject drawable)
|
|
|
|
(gcontext-Xgcontext gcontext)
|
2001-10-04 08:31:44 -04:00
|
|
|
(list->vector (map list->vector points))))
|
2001-07-04 10:19:38 -04:00
|
|
|
|
|
|
|
(import-lambda-definition %draw-segments (Xdisplay Xdrawable Xgcontext vec)
|
2001-08-29 10:43:49 -04:00
|
|
|
"scx_Draw_Segments")
|
2001-07-04 10:19:38 -04:00
|
|
|
|
2001-10-04 08:31:44 -04:00
|
|
|
;; draw-rectangle and draw-rectangles draw the outlines of the
|
|
|
|
;; specified rectangle or rectangles as if a five-point PolyLine
|
|
|
|
;; protocol request were specified for each rectangle. The rectangles
|
|
|
|
;; have to be specified as a list (x y width height). See
|
|
|
|
;; XDrawRectangle(s).
|
2001-07-04 10:19:38 -04:00
|
|
|
|
2001-10-04 08:31:44 -04:00
|
|
|
(define (draw-rectangle drawable gcontext rect)
|
2001-07-04 10:19:38 -04:00
|
|
|
(%draw-rectangle (display-Xdisplay (drawable-display drawable))
|
|
|
|
(drawable-Xobject drawable)
|
|
|
|
(gcontext-Xgcontext gcontext)
|
2001-10-04 08:31:44 -04:00
|
|
|
(list->vector rect)))
|
2001-07-04 10:19:38 -04:00
|
|
|
|
2001-10-04 08:31:44 -04:00
|
|
|
(import-lambda-definition %draw-rectangle (Xdisplay Xdrawable Xgcontext rect)
|
2001-08-21 10:57:08 -04:00
|
|
|
"scx_Draw_Rectangle")
|
2001-07-04 10:19:38 -04:00
|
|
|
|
2001-08-22 07:49:01 -04:00
|
|
|
(define (draw-rectangles drawable gcontext rectangles)
|
2001-07-04 10:19:38 -04:00
|
|
|
(%draw-rectangles (display-Xdisplay (drawable-display drawable))
|
2001-07-30 10:43:22 -04:00
|
|
|
(drawable-Xobject drawable)
|
2001-07-04 10:19:38 -04:00
|
|
|
(gcontext-Xgcontext gcontext)
|
2001-10-04 08:31:44 -04:00
|
|
|
(list->vector (map list->vector rectangles))))
|
2001-07-04 10:19:38 -04:00
|
|
|
|
2001-10-04 08:31:44 -04:00
|
|
|
(import-lambda-definition %draw-rectangles (Xdisplay Xdrawable Xgcontext vec)
|
2001-08-21 10:57:08 -04:00
|
|
|
"scx_Draw_Rectangles")
|
2001-07-04 10:19:38 -04:00
|
|
|
|
2001-10-04 08:31:44 -04:00
|
|
|
;; fill-rectangle and fill-rectangles fill the rectangle(s) outlined
|
|
|
|
;; with draw-rectangle(s). See XFillRectangle(s).
|
|
|
|
|
|
|
|
(define (fill-rectangle drawable gcontext rect)
|
|
|
|
(%fill-rectangle (display-Xdisplay (drawable-display drawable))
|
|
|
|
(drawable-Xobject drawable)
|
|
|
|
(gcontext-Xgcontext gcontext)
|
|
|
|
(list->vector rect)))
|
|
|
|
|
|
|
|
(import-lambda-definition %fill-rectangle (Xdisplay Xdrawable Xgcontext rect)
|
|
|
|
"scx_Fill_Rectangle")
|
2001-07-04 10:19:38 -04:00
|
|
|
|
2001-08-22 07:49:01 -04:00
|
|
|
(define (fill-rectangles drawable gcontext rectangles)
|
2001-07-04 10:19:38 -04:00
|
|
|
(%fill-rectangles (display-Xdisplay (drawable-display drawable))
|
2001-07-30 10:43:22 -04:00
|
|
|
(drawable-Xobject drawable)
|
2001-07-04 10:19:38 -04:00
|
|
|
(gcontext-Xgcontext gcontext)
|
2001-10-04 08:31:44 -04:00
|
|
|
(list->vector (map list->vector rectangles))))
|
2001-07-04 10:19:38 -04:00
|
|
|
|
2001-10-04 08:31:44 -04:00
|
|
|
(import-lambda-definition %fill-rectangles (Xdisplay Xdrawable Xgcontext vec)
|
2001-08-21 10:57:08 -04:00
|
|
|
"scx_Fill_Rectangles")
|
2001-07-04 10:19:38 -04:00
|
|
|
|
2001-10-04 08:31:44 -04:00
|
|
|
;; draw-arc(s) and fill-arc(s) draws a single/multiple circular or
|
|
|
|
;; elliptical arc(s). Each arc is specified by a rectangle and two
|
|
|
|
;; angles. The center of the circle or ellipse is the center of the
|
|
|
|
;; rectangle, and the major and minor axes are specified by the width
|
|
|
|
;; and height. Positive angles indicate counterclockwise motion, and
|
|
|
|
;; negative angles indicate clockwise motion.
|
|
|
|
;; angle1 specifies the start of the arc relative to the three-o'clock
|
|
|
|
;; position from the center, in units of degrees * 64. angle2
|
|
|
|
;; specifies the path and extent of the arc relative to the start of
|
|
|
|
;; the arc, in units of degrees * 64. If the magnitude of angle2 is
|
|
|
|
;; greater than 360 degrees it is truncated to 360 degrees.
|
2001-07-04 10:19:38 -04:00
|
|
|
|
|
|
|
(define (draw-arc drawable gcontext x y width height angle1 angle2)
|
|
|
|
(%draw-arc (display-Xdisplay (drawable-display drawable))
|
2001-07-30 10:43:22 -04:00
|
|
|
(drawable-Xobject drawable)
|
2001-07-04 10:19:38 -04:00
|
|
|
(gcontext-Xgcontext gcontext)
|
|
|
|
x y width height angle1 angle2))
|
|
|
|
|
|
|
|
(import-lambda-definition %draw-arc (Xdisplay Xdrawable Xgcontext x y
|
|
|
|
w h a1 a2)
|
2001-08-21 10:57:08 -04:00
|
|
|
"scx_Draw_Arc")
|
2001-07-04 10:19:38 -04:00
|
|
|
|
|
|
|
|
2001-07-30 10:43:22 -04:00
|
|
|
(define (fill-arc drawable gcontext x y width height angle1 angle2)
|
2001-07-04 10:19:38 -04:00
|
|
|
(%fill-arc (display-Xdisplay (drawable-display drawable))
|
2001-07-30 10:43:22 -04:00
|
|
|
(drawable-Xobject drawable)
|
2001-07-04 10:19:38 -04:00
|
|
|
(gcontext-Xgcontext gcontext)
|
|
|
|
x y width height angle1 angle2))
|
|
|
|
|
|
|
|
(import-lambda-definition %fill-arc (Xdisplay Xdrawable Xgcontext x y
|
|
|
|
w h a1 a2)
|
2001-08-21 10:57:08 -04:00
|
|
|
"scx_Fill_Arc")
|
2001-07-04 10:19:38 -04:00
|
|
|
|
2001-08-22 07:49:01 -04:00
|
|
|
(define (draw-arcs drawable gcontext data)
|
2001-07-04 10:19:38 -04:00
|
|
|
(%draw-arcs (display-Xdisplay (drawable-display drawable))
|
2001-07-30 10:43:22 -04:00
|
|
|
(drawable-Xobject drawable)
|
2001-07-04 10:19:38 -04:00
|
|
|
(gcontext-Xgcontext gcontext)
|
2001-08-22 07:49:01 -04:00
|
|
|
(list->vector data)))
|
2001-07-04 10:19:38 -04:00
|
|
|
|
|
|
|
(import-lambda-definition %draw-arcs (Xdisplay Xdrawable Xgcontext vec)
|
2001-08-21 10:57:08 -04:00
|
|
|
"scx_Draw_Arcs")
|
2001-07-04 10:19:38 -04:00
|
|
|
|
2001-08-22 07:49:01 -04:00
|
|
|
(define (fill-arcs drawable gcontext data)
|
2001-07-04 10:19:38 -04:00
|
|
|
(%fill-arcs (display-Xdisplay (drawable-display drawable))
|
2001-07-30 10:43:22 -04:00
|
|
|
(drawable-Xobject drawable)
|
2001-07-04 10:19:38 -04:00
|
|
|
(gcontext-Xgcontext gcontext)
|
2001-08-22 07:49:01 -04:00
|
|
|
(list->vector data)))
|
2001-07-04 10:19:38 -04:00
|
|
|
|
|
|
|
(import-lambda-definition %fill-arcs (Xdisplay Xdrawable Xgcontext vec)
|
2001-08-21 10:57:08 -04:00
|
|
|
"scx_Fill_Arcs")
|
2001-07-04 10:19:38 -04:00
|
|
|
|
2001-10-04 08:31:44 -04:00
|
|
|
;; fill-polygon fills the region closed by the specified path. The
|
|
|
|
;; path is closed automatically if the last point in the list does not
|
|
|
|
;; coincide with the first point. See XFillPolygon.
|
|
|
|
|
2001-08-22 07:49:01 -04:00
|
|
|
(define (fill-polygon drawable gcontext points relative? shape)
|
2001-07-04 10:19:38 -04:00
|
|
|
(%fill-polygon (display-Xdisplay (drawable-display drawable))
|
2001-07-30 10:43:22 -04:00
|
|
|
(drawable-Xobject drawable)
|
2001-07-04 10:19:38 -04:00
|
|
|
(gcontext-Xgcontext gcontext)
|
2002-02-08 12:09:43 -05:00
|
|
|
(list->vector points) relative?
|
|
|
|
(polygon-shape->integer shape)))
|
|
|
|
|
|
|
|
(define-enumerated-type polygon-shape :polygon-shape
|
|
|
|
polygon-shape? polygon-shapes polygon-shape-name polygon-shape-index
|
|
|
|
(complex non-convex convex))
|
|
|
|
|
|
|
|
(define (polygon-shape->integer v)
|
|
|
|
(polygon-shape-index v))
|
2001-07-04 10:19:38 -04:00
|
|
|
|
|
|
|
(import-lambda-definition %fill-polygon (Xdisplay Xdrawable Xgcontext
|
|
|
|
vec relative shape)
|
2001-08-29 10:43:49 -04:00
|
|
|
"scx_Fill_Polygon")
|
2001-10-04 08:31:44 -04:00
|
|
|
|
|
|
|
;; Now some auxiliary functions:
|
|
|
|
|
|
|
|
(define rectangle list)
|
|
|
|
|
|
|
|
(define (bounds x1 y1 x2 y2)
|
|
|
|
(rectangle x1 y2 (- x2 x1) (- y2 y1)))
|
|
|
|
|
|
|
|
;; converts '((x1 . y1) (x2 . y2) (x3 . y3) (x4 . y4)) -> '((x1 y1 x2
|
|
|
|
;; y2) (x3 y3 x4 y4))
|
|
|
|
|
|
|
|
(define (points->segments points)
|
|
|
|
(cdr (fold-right (lambda (this rest)
|
|
|
|
(if (null? (car rest))
|
|
|
|
(cons (list (car this)
|
|
|
|
(cdr this))
|
|
|
|
(cdr rest))
|
|
|
|
(cons '()
|
|
|
|
(cons (cons (car this)
|
|
|
|
(cons (cdr this)
|
|
|
|
(car rest)))
|
|
|
|
(cdr rest)))))
|
|
|
|
'(())
|
|
|
|
points)))
|
2002-02-08 12:09:43 -05:00
|
|
|
|