[racket] display problem
Op 13-4-2012 19:31, Stephen Bloch schreef:
> On Apr 12, 2012, at 8:18 AM, Roelof Wobben wrote:
>
>>> Why do you need "overlay"? I would think you could do this just with "beside" (unless you wanted to fine-tune the formatting).
>>>
>> Only beside. But how can I then take care that the text are displayed into the empty-scene. I think you need overlay or something for that.
> Oh, right: if you want to put the text in a particular place in the empty scene, you need overlay or place-image or something.
>
> If you don't care WHERE the text appears in the animation window, you can just return the image of the text, and not worry about overlay or place-image.
>
>
> Stephen Bloch
> sbloch at adelphi.edu
>
>
oke,
I found I think the answer.
I still have to write testcases but it's looking good.
Here is what I have :
(define cursor (rectangle 2 20 "solid" "red"))
(define textcolor "black")
(define textfont 11)
(define-struct editor (pre post))
; Editor = (make-editor String String)
; interp. (make-editor s t) means the text in the editor is
; (string-append s t) with the cursor displayed between s and t
; make-editor String String -> Editor
; editor-pre Editor -> String
; editor-post Editor -> String
; editor? Editor Any -> Boolean
; make-struct
(define verwerker (make-editor "aaa" "bbbb"))
; Editor -> Image
; Function which displays the struct on the screen into a image.
(define (render verwerker)
;; verwerker editor
;; (editor-pre verwerker) string
;; (editor-post verwerker) string
;; cursor fixed image
;; workspace fixed image
(place-image (beside (text(editor-pre verwerker) textfont textcolor)
cursor (text(editor-post verwerker) textfont textcolor ))25 10 workspace ))