[cl-gd-devel] with-transformation off-by-one bug?

Edi Weitz edi at agharta.de
Thu Sep 13 09:14:46 UTC 2007


On Tue, 11 Sep 2007 11:13:24 -0500, "Michael J. Forster" <mike at sharedlogic.ca> wrote:

> I'm using WITH-TRANSFORMATION to simplify the graph plotting, and
> it's not behaving the way I would expect.  As I read it in the
> documentation, this...
>
> (with-transformation (:x1 0
>                        :width width
>                        :y1 0
>                        :height height)
>    ...)
>
>
> ... should transform the coordinate system from this...
>
> 0,0 -----> width - 1
> |
> |
> |
> V
> height - 1
>
> ... to this...
>
> height - 1
> ^
> |
> |
> |
> 0,0 -----> width - 1

Hmm, why do you think that?  I would expect a transformation from

 0,0 -----> image-width
 |
 |
 |
 V
 image-height

to

 height
 ^
 |
 |
 |
 0,0 -----> width

Why do you want to subtract 1?  What do you expect to happen if WIDTH
or HEIGHT /are/ 1?

> Below is the snippet I was running to grok WITH-TRANSFORMATION.  I
> can mail you the images I got, if you like.

An easy way to experiment with CL-GD's transformations would probably
be something like this:

  (in-package :cl-gd)

  (defun foo (x1 y1 x2 y2 &optional (image *default-image*))
    (with-transformed-alternative
        ((x1 x-transformer)
         (y1 y-transformer)
         (x2 x-transformer)
         (y2 y-transformer))
      (print (list x1 y1 x2 y2))))

  (with-image* (... ...)
    (with-transformation (:x1 ... :width ... :y1 ... :height ...)
      (foo ... ... ... ...)))

Cheers,
Edi.



More information about the Cl-gd-devel mailing list