[Pharo-dev] New User and the Rectangle class.

Trey Tomes trey.tomes at gmail.com
Wed Jun 21 10:17:30 EDT 2017


Chris/Peter: Thank you for taking the time to respond.  It's good to know
that I'm not the only one to encounter this problem.

Chris: Thank you for the reference to the topLeftOffset:bottomRightOffset:
API, that resolved my problem really well.  I'm glad to have a solution
that doesn't have me modifying base classes every time I open a fresh image.

Thanks,
Trey


On Wed, Jun 21, 2017 at 6:00 AM, Peter Uhnak <i.uhnak at gmail.com> wrote:

> iirc there was proposal to rename Rectangle to DisplayRectangle (or
> something like that), because you are certainly not the first one to run
> into such trouble.
>
> P
>
>
> On Tue, Jun 20, 2017 at 04:03:48PM -0700, Chris Cunningham wrote:
> > Hi Trey,
> > I can't find the rational written down why Rectangle was changed
> (although
> > it WAS written down).  If I remember right, the rational was roughly
> > "Rectangles represent areas of the screen.  As such, they should be 'well
> > formed'- positive width and height only".
> > In any case, going back through the archives, I found this bit of advice:
> >
> > "
> > You need to use a different API: for example:
> >
> > frame := (0 @ 0 corner: 1.0 @ 1.0) asLayoutFrame topLeftOffset: 0 @ 50;
> > bottomRightOffset: 0 at 50 negated.
> > "
> >
> > Thanks,
> > -cbc
> >
> > On Tue, Jun 20, 2017 at 3:10 PM, Trey Tomes <trey.tomes at gmail.com>
> wrote:
> >
> > > Hello!
> > >
> > > I'm new to this list, so I apologize if this topic has already been
> > > considered.
> > >
> > > I have been re-creating the Laser Game tutorial in Pharo 6, and have
> > > encountered something that may be an error within Pharo.
> > >
> > > The LayoutFrame has the ability to use negative values for the bottom
> and
> > > right sides of the rectangle assigned to the offsets, e.g.
> > >
> > > LayoutFrame fraction: ((0 at 0 corner: (1 at 1)) offsets: ((4 at 4 corner: (-4@
> > > -4)).
> > >
> > > This is useful, as it allows the system to automatically calculate the
> > > margins inset from the bottom and right sides of the container.
> > >
> > > In Pharo 6, this does not work.  The setLeft:right:top:bottom: and
> > > setPoint:point: messages both use the min: and max: messages to
> rearrange
> > > the Rectangle so that the smallest numbers get pushed to the top and
> left.
> > >
> > > In order to get things to render correctly in my system, I had to
> change
> > > these messages to look like this:
> > >
> > > setLeft: left right: right top: top bottom: bottom
> > >     self setPoint: (left at top) point: (right at bottom).
> > > setPoint: pt1 point: pt2
> > >     origin := pt1.
> > >     corner := pt2.
> > >
> > >
> > > In place of this:
> > >
> > > setLeft: left right: right top: top bottom: bottom
> > >     origin := (left min: right) @ (top min: bottom).
> > >     corner := (left max: right) @ (top max: bottom).
> > > setPoint: pt1 point: pt2
> > >     origin := (pt1 x min: pt2 x) @ (pt1 y min: pt2 y).
> > >     corner := (pt1 x max: pt2 x) @ (pt1 y max: pt2 y).
> > >
> > >
> > > I haven't found any bad side-effects to changing this yet, but is
> there a
> > > reason the Rectangle class was changed?
> > >
> > > Thanks,
> > > Trey
> > >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20170621/3ddb651a/attachment-0002.html>


More information about the Pharo-dev mailing list