[racket] question about dc% and scale
By the way, the same sort of bug affects draw-ellipse and canvas%.
-- Garrett Mitchener
On Thu, May 10, 2012 at 11:10 AM, Garrett Mitchener <
garrett.mitchener at gmail.com> wrote:
> Okay, yes, using a dc-path% seems to work as intended.
>
> Thanks!
>
> -- Garrett Mitchener
>
> On Thu, May 10, 2012 at 11:04 AM, Matthew Flatt <mflatt at cs.utah.edu>wrote:
>
>> Although pixel alignment can be confusing, I think this one is just a
>> bug.
>>
>> The `draw-rectangle' method tries to adjust the width of an outline so
>> that in the simple case --- a width 0 or 1 pen in unsmoothed or aligned
>> mode with a bitmap target --- the rectangle outline is the given width
>> and height, instead of extending an extra pixel. That adjustment isn't
>> implemented correctly, and the problem is particularly clear with a
>> large scaling factor.
>>
>> You can work around the problem by creating a rectangle `dc-path%' and
>> drawing it with `draw-path'. Meanwhile, I'll fix `draw-rectangle'.
>>
>> At Thu, 10 May 2012 09:57:26 -0500, Robby Findler wrote:
>> > The problem is that the coordinates are "between" the pixels. There is
>> an
>> > explanation of this in the context of another library, but the issues
>> are
>> > the same:
>> >
>> >
>> >
>> http://docs.racket-lang.org/teachpack/2htdpimage.html?q=2htdp/image#%28part._nitty-g
>> > ritty%29
>> >
>> > hth,
>> > Robby
>> >
>> > On Thu, May 10, 2012 at 8:29 AM, Garrett Mitchener <
>> > garrett.mitchener at gmail.com> wrote:
>> >
>> > > Hi, I'm learning the racket GUI package, and I ran into something that
>> > > doesn't make sense to me:
>> > >
>> > > #lang racket/gui
>> > >
>> > > (define black-pen
>> > > (new pen%
>> > > [width 1]
>> > > [color "black"]))
>> > >
>> > > (define blue-brush
>> > > (new brush%
>> > > [color "blue"]))
>> > >
>> > > (define (draw-test-2 dc)
>> > > (send dc scale 10 10)
>> > > (send dc set-pen black-pen)
>> > > (send dc set-brush blue-brush)
>> > > (send dc draw-rectangle 7 2 4 4))
>> > >
>> > > (define pic (make-bitmap 200 100))
>> > >
>> > > (define dc (new bitmap-dc% [bitmap pic]))
>> > >
>> > > (draw-test-2 dc)
>> > >
>> > > And at the end, pic looks like this:
>> > >
>> > > [image: Inline image 1]
>> > > The outline and the filling don't line up. What am I doing wrong?
>> This
>> > > is with DrRacket 5.2.1 on linux.
>> > >
>> > > Thanks,
>> > > -- Garrett Mitchener
>> > >
>> > > ____________________
>> > > Racket Users list:
>> > > http://lists.racket-lang.org/users
>> > >
>> > >
>> > ____________________
>> > Racket Users list:
>> > http://lists.racket-lang.org/users
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120511/5c3632c8/attachment-0001.html>