If you want to avoid redrawing, you can draw the background (the two filled rectangles) first,
then draw the lines on top. See below.
But why is redrawing a problem in the first place - do you have an example of what it looks like?
[I get the best results, when I save as svg.]
The obvious (apply curve left) ... of course doesn't work.
I think (curve* left) is what you are looking for.
#lang racket
(require metapict)
;; A B C
;; x------------x------------x
;; | | |
;; x------------x------------x
;; D E F
(def A (pt 0 2))
(def B (pt 2 2))
(def C (pt 4 2))
(def D (pt 0 0))
(def E (pt 2 0))
(def F (pt 4 0))
(def ACFD (curve A -- C -- F -- D -- cycle))
(def LEFT (curve A -- B -- E -- D -- cycle))
(def RIGHT (curve B -- C -- F -- E -- cycle))
(def BE (curve B -- E))
(define win (window -1 5 -1 5))
(set-curve-pict-size 401 401)
(with-window win
(draw (color "red" (fill LEFT))
(color "blue" (fill RIGHT))
ACFD
BE))
Thanks for all the explanation. Somehow I missed curve*, and I noticed now that it's because it's undocumented.
The rectangle stuff is cool but unneeded since this was just a simple example. What I am currently doing needs no rectangles. Once I get this right, I will post here what I came up with.
I did an experiment with redrawing the middle vertical line.
Both look fine when svg is used.
If you save the images as "png" you can see the difference.
(set-curve-pict-size 150 150)
(with-window win
(draw (filldraw LEFT "red")
(filldraw RIGHT "blue")))
(set-curve-pict-size 151 151)
(with-window win
(draw (filldraw LEFT "red")
(filldraw RIGHT "blue")))
The effect is explained in the documentation of racket/draw.
Basically the first version where the width is 150 draws between the pixels
and the second one draws perfectly in the middle of the pixels.