Re: Why can't I perfectly align an Inset LocatorPane with its
- To: mathgroup at smc.vnet.net
- Subject: [mg99936] Re: Why can't I perfectly align an Inset LocatorPane with its
- From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
- Date: Tue, 19 May 2009 06:49:10 -0400 (EDT)
- References: <guqvbd$a7r$1@smc.vnet.net>
Hi Michael, I can't solve the alignment problem, but I spotted another problem in your code: you assume your image is 800x600, but if you watch the rectangle commands closely you'll see it's 3 pixels wider and taller than that. I can't put locators in the upper part of the pane nor in the left part. Do you have the same? Cheers -- Sjoerd On May 18, 8:31 am, Michael <michael2... at gmail.com> wrote: > Here's the code: > > Module[{w, h, pts, img}, > w = 800; h = 600; > pts = {{60, 380}}; > img = Graphics[{ > RGBColor[0, 0, 1], > Table[Rectangle[{x - 1, 0}, {x + 1, 600}], {x, 0, 800, 20}], > Table[Rectangle[{0, y - 1}, {800, y + 1}], {y, 0, 600, 20}], > Rectangle[{100, 100}, {200, 200}] > }, ImageSize -> {w, h}, PlotRange -> {{0, w}, {0, h}}, > PlotRangeClipping -> True]; > Pane[Graphics[{ > RGBColor[0, 0, 0], > RGBColor[1, 0, 0], > Table[Rectangle[{x - 1, 0}, {x + 1, 600}], {x, 0, 800, 20}], > Table[Rectangle[{0, y - 1}, {800, y + 1}], {y, 0, 600, 20}], > Rectangle[{150, 150}, {250, 250}], > Opacity[0.5], > Inset[ > LocatorPane[Dynamic[pts], img, ImageSize -> {w, h}, > LocatorAutoCreate -> True] (*,{397,302} *)] > }, ImageSize -> {w, h}, PlotRange -> {{0, w}, {0, h}}, > PlotRangeClipping -> True], > ImageSize -> {800, 600}, ImageSizeAction -> "Scrollable", > Scrollbars -> Automatic] > ] > > Both the inset and the containing Graphics[] are supposed to be the > same size, yet for some reason the default alignment ("Center") shows > a noticable offset. If I uncomment the coordinates {392,302} (why I > pretty much had to determine by visual inspection of the > misalignment!) then everything aligns properly, but I'm still missing > one pixel of the inset at the bottom edge, and two at the right edge. > > If I use a Pane instead of a LocatorPane, then the centered alignment > is much closer, but it still appears to be off by one. > > Unrelated question, why doesn't LocatorPane have all the Options that > Pane does? Specifically ImageSizeAction and ScrollPosition are > missing. > > Thanks, > > Michael