srfi-203
Introduction
This egg implements SRFI-203 using code from the sicp egg.
Author
Vasilij Schneidermann
Repository
https://depp.brause.cc/srfi-203
API
The procedures listed below expect a proper list of numbers for their data representation. Vector and frame accessors are therefore defined as follows:
(define origin-frame car) (define edge1-frame cadr) (define edge2-frame caddr) (define xcor-vect car) (define ycor-vect cadr)
If you chose to use a different internal representation, you'll need to define appropriate conversion procedures. For example a pair representation can be transformed as follows:
(define (fixup-vector vector) (list (xcor-vect vector) (ycor-vect vector))) (draw-line (fixup-vector start) (fixup-vector end))
Canvas manipulation
[parameter] (canvas-path)Obtain or set the path the canvas should be rendered to.
[parameter] (canvas-width)[parameter] (canvas-height)
Obtain or set the width and height of the canvas measured in pixels.
[procedure] (canvas-frame)Obtain a frame corresponding to the canvas width and height.
[procedure] (canvas-reset)Reset the canvas to its initial state.
[procedure] (canvas-refresh)Commit all pending drawing operations and return a file:// URL to the file backing the canvas. This will call canvas-reset if needed.
[procedure] (canvas-cleanup)Delete the current canvas, including its backing file.
Painters
[procedure] (draw-line start end)Draws a line from start to end on the canvas. This should be used in combination with a procedure that adjusts the coordinates of start and end to fit the canvas.
[procedure] (rogers frame)A built-in painter that paints an image of William Rogers into frame.
[procedure] (image-file->painter file-name)Returns a painter that will paint the image at file-name.
Note that file-name is interpreted relative to the path returned by canvas-refresh. Therefore only absolute paths are guaranteed to work.
[procedure] (jpeg-file->painter file-name)Alias for image-file->painter.
Example
(import scheme) (import (srfi 203)) (define (flip-vert painter) ...) (define (beside painter1 painter2) ...) (define (below painter1 painter2) ...) (define rogers2 (beside rogers (flip-vert rogers))) (define rogers4 (below rogers2 rogers2)) (rogers4 (canvas-frame)) (print (canvas-refresh))
Licenses
Version history
0.1
- Initial release