srfi-203
TOC »
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
- canvas-pathparameter
Obtain or set the path the canvas should be rendered to.
- canvas-widthparameter
- canvas-heightparameter
Obtain or set the width and height of the canvas measured in pixels.
- canvas-frameprocedure
Obtain a frame corresponding to the canvas width and height.
- canvas-resetprocedure
Reset the canvas to its initial state.
- canvas-refreshprocedure
Commit all pending drawing operations and return a file:// URL to the file backing the canvas. This will call canvas-reset if needed.
- canvas-cleanupprocedure
Delete the current canvas, including its backing file.
Painters
- draw-line start endprocedure
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.
- rogers frameprocedure
A built-in painter that paints an image of William Rogers into frame.
- image-file->painter file-nameprocedure
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.
- jpeg-file->painter file-nameprocedure
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