2015-11-09 35 views
0

我正在使用mit-scheme及其圖形庫。 你製作一個圖形設備​​,它打開一個圖形創建窗口。 (graphics-operation device 'set-foreground-color "black")使線條變黑。函數(graphics-operation device 'fill-polygon #(0 1 0 0 1 0 1 1))形成一個黑色正方形,參數#()中的每兩個數字都是該形狀上的一個點。 如果我使用以下命令:計劃圖形

(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-))) 

我得到的錯誤The object x+ passed to integer->flownum is not the correct type

我不明白這一點,因爲我可以在功能#()部分使用flonums爲ARGS。

我想print-cell採取一組座標,然後畫一個小正方形的點爲中心,使得(print-cell device .5 .5)變成(graphics-operation device 'fill-polygon #(.51 .51 .51 .49 .49 .49 .49 .51))

回答

1

#()符號讀取vector constants:你正在閱讀的文字符號,這解釋了爲什麼對象傳遞給integer->flownum的是x+,而不是綁定到x+的值。您應該認爲#(x+)等同於'(x+),但對於矢量。 想要做的事情可以用vector功能:

(vector x+ y+ x+ y- y+ x- y-)