[cl-gd-devel] fill shapes with transformation?
Hi; I'm probably doing something wrong, but I can't figure out how to draw rectangles with a fill color using a transformation. The code below illustrates the problem I'm having. The first draw-rectangle should be filled in red. It isn't drawn at all. The second rectangle is outlined in blue as it should be. Both these two use a transformation to place the rectangle. The third does not and it fills just fine. Is this expected behavior? Or am I doing something wrong? Thanks. --Jeff (with-image* (200 200) (allocate-color 68 70 85) (let ((fn "test.png") (red (allocate-color 255 0 0)) (white (allocate-color 255 255 255)) (blue (allocate-color 0 0 100))) (with-transformation (:x1 -100 :x2 100 :y1 -100 :y2 100) (draw-rectangle* -30 -30 30 30 :color red :filled t) (draw-rectangle* -20 -20 20 20 :color blue :filled nil)) (without-transformations (draw-rectangle* 95 95 105 105 :color white :filled t)) (write-image-to-file fn :if-exists :supersede) (sb-ext:run-program "/usr/bin/xv" (list fn))))
On Fri, 19 Oct 2007 18:51:43 -0700, Jeff Cunningham <jeffrey@cunningham.net> wrote:
(with-image* (200 200) (allocate-color 68 70 85) (let ((fn "test.png") (red (allocate-color 255 0 0)) (white (allocate-color 255 255 255)) (blue (allocate-color 0 0 100))) (with-transformation (:x1 -100 :x2 100 :y1 -100 :y2 100) (draw-rectangle* -30 -30 30 30 :color red :filled t) (draw-rectangle* -20 -20 20 20 :color blue :filled nil)) (without-transformations (draw-rectangle* 95 95 105 105 :color white :filled t)) (write-image-to-file fn :if-exists :supersede) (sb-ext:run-program "/usr/bin/xv" (list fn))))
This works for me: (with-image* (200 200) (allocate-color 68 70 85) (let ((fn "test.png") (red (allocate-color 255 0 0)) (white (allocate-color 255 255 255)) (blue (allocate-color 0 0 100))) (with-transformation (:x1 -100 :x2 100 :y1 -100 :y2 100) (draw-rectangle* -30 30 30 -30 :color red :filled t) (draw-rectangle* -20 20 20 -20 :color blue :filled nil)) (without-transformations (draw-rectangle* 95 95 105 105 :color white :filled t)) (write-image-to-file fn :if-exists :supersede) (sb-ext:run-program "/usr/bin/display" (list fn)))) Note that the docstring for DRAW-RECTANGLE* explicitely talks about the "upper left" corner and the "lower right" corner. Cheers, Edi.
Edi Weitz wrote:
On Fri, 19 Oct 2007 18:51:43 -0700, Jeff Cunningham <jeffrey@cunningham.net> wrote:
(with-image* (200 200) (allocate-color 68 70 85) (let ((fn "test.png") (red (allocate-color 255 0 0)) (white (allocate-color 255 255 255)) (blue (allocate-color 0 0 100))) (with-transformation (:x1 -100 :x2 100 :y1 -100 :y2 100) (draw-rectangle* -30 -30 30 30 :color red :filled t) (draw-rectangle* -20 -20 20 20 :color blue :filled nil)) (without-transformations (draw-rectangle* 95 95 105 105 :color white :filled t)) (write-image-to-file fn :if-exists :supersede) (sb-ext:run-program "/usr/bin/xv" (list fn))))
This works for me:
(with-image* (200 200) (allocate-color 68 70 85) (let ((fn "test.png") (red (allocate-color 255 0 0)) (white (allocate-color 255 255 255)) (blue (allocate-color 0 0 100))) (with-transformation (:x1 -100 :x2 100 :y1 -100 :y2 100) (draw-rectangle* -30 30 30 -30 :color red :filled t) (draw-rectangle* -20 20 20 -20 :color blue :filled nil)) (without-transformations (draw-rectangle* 95 95 105 105 :color white :filled t)) (write-image-to-file fn :if-exists :supersede) (sb-ext:run-program "/usr/bin/display" (list fn))))
Note that the docstring for DRAW-RECTANGLE* explicitely talks about the "upper left" corner and the "lower right" corner.
Cheers, Edi.
Ah-ha! - I see it now on closer reading. I was blinded by the usual graphing convention y1 < y2. It is curious that it would draw the unfilled rectangle at all. Thank you. --Jeff
participants (2)
-
Edi Weitz -
Jeff Cunningham