Note: This is taken from the Chicken Wiki, where a more recent version could be available.

xmi

Description

An interface to the libxmi 2-D rasterization library. The library source itself are included in this egg.

Author

Felix Winkelmann

Usage

 (require-extension xmi)

Download

xmi.egg

Documentation

The following functions are provided. For more information consult the libxmi info(1) documentation.

 (xmi:new-painted-set) --> PAINTEDSET
 (xmi:delete-painted-set PAINTEDSET)
 (xmi:painted-set? X)  --> BOOL
 (xmi:clear-painted-set PAINTEDSET)
 
 (xmi:new-gc U32VECTOR)            --> GC
 (xmi:delete-gc GC)
 (xmi:copy-gc GC)                  --> GC
 (xmi:gc? X)                       --> BOOL
 (xmi:set-gcpixels GC U32VECTOR)
 (xmi:set-gcdashes GC U32VECTOR OFFSET)
 (xmi:set-gcattrib GC ATTRIB VALUE)
 
 xmi:gc-fill-rule   --> ATTRIB
 xmi:gc-join-style  --> ATTRIB
 xmi:gc-cap-style   --> ATTRIB
 xmi:gc-line-style  --> ATTRIB
 xmi:gc-arc-mode    --> ATTRIB
 xmi:gc-line-width  --> ATTRIB
 
 xmi:even-odd-rule  --> FILL-RULE 
 xmi:winding-rule   --> FILL-RULE
 
 xmi:join-miter      --> JOIN-STYLE
 xmi:join-round      --> JOIN-STYLE
 xmi:join-bevel      --> JOIN-STYLE
 xmi:join-triangular --> JOIN-STYLE
 
 xmi:cap-not-last    --> CAP-STYLE
 xmi:cap-butt        --> CAP-STYLE
 xmi:cap-round       --> CAP-STYLE
 xmi:cap-projecting  --> CAP-STYLE
 xmi:cap-triangular  --> CAP-STYLE
 
 xmi:line-solid       --> LINE-STYLE
 xmi:line-on-off-dash --> LINE-STYLE
 xmi:line-double-dash --> LINE-STYLE
 
 xmi:arc-chord      --> ARC-MODE
 xmi:arc-pie-slice  --> ARC-MODE
 
 (xmi:set-gcmiter-limit GC DOUBLE)
 
 (xmi:draw-points PAINTEDSET GC COORD-MODE S32VECTOR)
 (xmi:draw-lines PAINTEDSET GC COORD-MODE S32VECTOR)
 (xmi:fill-polygon PAINTEDSET GC COORD-MODE S32VECTOR)
 (xmi:draw-rectangles PAINTEDSET GC S32VECTOR)
 (xmi:fill-rectangles PAINTEDSET GC S32VECTOR)
 (xmi:draw-arcs PAINTEDSET GC S32VECTOR)
 (xmi:fill-arcs PAINTEDSET GC S32VECTOR)
 (xmi:draw-arcs-r PAINTEDSET GC S32VECTOR ELLIPSE-CACHE)
 
 xmi:coord-mode-origin   --> COORD-MODE
 xmi:coord-mode-previous --> COORD-MODE
 
 xmi:shape-general --> POLYGON-SHAPE
 xmi:shape-convex  --> POLYGON-SHAPE
 
 (xmi:new-ellipse-cache)  --> ELLIPSE-CACHE
 (xmi:delete-ellipse-cache ELLLIPSE-CACHE)
 (xmi:ellipse-cache? X)  --> BOOL
 
 (xmi:new-canvas WIDTH HEIGHT INIT-PIXEL)  --> CANVAS
 (xmi:delete-canvas CANVAS)
 (xmi:canvas? X)                           --> BOOL
 (xmi:copy-canvas CANVAS)                  --> CANVAS
 
 (xmi:set-canvas-stipple CANVAS S32VECTOR [XOFFSET YOFFSET])
 (xmi:set-canvas-texture CANVAS U32VECTOR [XOFFSET YOFFSET])
 (xmi:set-pixel-merge2 CANVAS PROC)
 (xmi:set-pixel-merge3 CANVAS PROC)
 
 (xmi:copy-painted-set-to-canvas PAINTEDSET GC [XORIGIN YORIGIN])
 (xmi:canvas-pixmap CANVAS [DESTINATION]) --> U32VECTOR

Examples

 ; The example from the libxmi documentation. Draws a few lines
 ; and a circle and writes a PPM file to stdout:
 
 (use xmi)
    
 (define points '#s32(25 5 5 5 5 25 35 22))
 (define arc '#s32(20 15 30 16 0 17280))
 (define pixels '#u32(1 2 3 4))
 (define dashes '#u32(4 2))
 (define gc (xmi:new-gc pixels))
 
 (xmi:set-gcattrib gc xmi:gc-line-style xmi:line-on-off-dash)
 (xmi:set-gcdashes gc dashes 0)
 (xmi:set-gcattrib gc xmi:gc-line-width 0)
      
 (define painted-set (xmi:new-painted-set))
 
 (xmi:draw-lines painted-set gc xmi:coord-mode-origin points)
 (xmi:draw-arcs painted-set gc arc)
 
 (define canvas (xmi:new-canvas 60 35 0))
 
 (xmi:copy-painted-set-to-canvas painted-set canvas)
 
 (define buffer (xmi:canvas-pixmap canvas))
 
 (display "P3\n60 35\n5\n")
 
 (do ([i 0 (add1 i)])
     ((>= i 35))
   (do ([j 0 (add1 j)])
       ((>= j 60))
     (let ([c (u32vector-ref buffer (+ (* i 60) j))])
       (printf "~a ~a ~a  " c c c) ) )
   (newline) )
 
 (xmi:delete-canvas canvas)
 (xmi:delete-gc gc)
 (xmi:delete-painted-set painted-set)

Changelog

License

 Copyright (c) 2005, Felix L. Winkelmann
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are
 met:
 
   Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
 
   Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
 
   Neither the name of the author nor the names of its contributors may
   be used to endorse or promote products derived from this software
   without specific prior written permission.
 
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
 TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
 USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 DAMAGE.