Reputation: 243
I am using mit-scheme and its graphics library.
You make a graphics device with (define device (make-graphics-device (car (enumerate-graphics-types))))
which opens up a window for graphics creation.(graphics-operation device 'set-foreground-color "black")
makes the lines black. The function (graphics-operation device 'fill-polygon #(0 1 0 0 1 0 1 1))
makes a black square, every two numbers in the argument #() is a point on the shape.
If I use the following:
(define (print-cell dev x y)
(define off .01)
(define x+ (+ x off))
(define x- (- x off))
(define y+ (+ y off))
(define y- (- y off))
(graphics-operation dev 'fill-polygon #(x+ y+ x+ y- x- y+ x- y-)))
I get the error The object x+ passed to integer->flownum is not the correct type
I don't understand this because I can use flonums as args in the #() part of the function.
I want print-cell
to take a set of coordinates and then draw a small square centered at the points such that (print-cell device .5 .5)
turns into (graphics-operation device 'fill-polygon #(.51 .51 .51 .49 .49 .49 .49 .51))
Upvotes: 0
Views: 318
Reputation: 38799
The #()
notation reads vector constants: you are reading literal symbols, which explains why the object passed to integer->flownum
is x+
and not a value bound to x+
. You should think about #(x+)
as being equivalent to '(x+)
, but for vectors.
What you want to do is possible with the vector
function:
(vector x+ y+ x+ y- y+ x- y-)
Upvotes: 1