[squeak-dev] The Inbox: Graphics-cbc.372.mcz

Eliot Miranda eliot.miranda at gmail.com
Wed Mar 29 19:58:48 UTC 2017


Hi Hannes,

On Wed, Mar 29, 2017 at 8:45 AM, H. Hirzel <hannes.hirzel at gmail.com> wrote:

> Hi Chris,
>
> On 3/29/17, Chris Cunningham <cunningham.cb at gmail.com> wrote:
> > Hi,
> >
> > yes, / vs // is definitely worth the effort.  For this use case, I am
> > utilizing Rectangle to represent rectangles that I want to place in a
> Visio
> > drawing, and that representation uses fractional measurements (inches,
> say)
> > instead of pixels.
>
> In the context of pixel based Rectangles it makes no sense.
>
> If we talk about measurements in inches and centimeters than it is
> fine. But the class Rectangle is not about that.
>

How do you know?  Just because Rectangle and Point are used in the graphics
subsystem does not mean that their use is limited only to that domain.
There is nothing that prevents one from creating, for example,

    0.25 asPoint extent: 1    =>    0.25 at 0.25 corner: 1.25 at 1.25

I think Chris' method makes perfect sense.  This is a polymorphic system;
the abstractions within it are broadly applicable.  The kind of thinking
which restricts the system, such as adding methods that logically belong to
SequenceableCollection to, say, String, simply because the programmer
wanted a String method and didn't think about generality, is at best
regrettable.

> A better question is should I be using Rectangle for this.  Maybe we
> should
> > create a 'TrueRectangle' class or something similar so that we can
> actually
> > talk about and share what can really be done with rectangles, instead of
> > the 'ScreenRectangle' that we have today called Rectangle.
>

Why not the other way around? Add IntegralRectangle and have it specialize
Rectangle.


>
> I prefer this. Actually I need such a class as well. At the moment I
> work with RectangleMorph.
>
>
> > That said, this change does let me work with rectangle for this purpose,
> > but it does move the class away from our pixel based rectangle.
>
> I do not understand how this change helps you with that ....
>
> --Hannes
>
> > -cbc
> >
> > On Wed, Mar 29, 2017 at 6:21 AM, H. Hirzel <hannes.hirzel at gmail.com>
> wrote:
> >
> >> What is the difference to the existing method ?
> >>
> >> center: centerPoint extent: extentPoint
> >>         "Answer an instance of me whose center is centerPoint and width
> >>         by height is extentPoint.  "
> >>
> >>         ^self origin: centerPoint - (extentPoint//2) extent: extentPoint
> >>
> >> Is / vs // worth the effort?
> >>
> >> On Wed, 29 Mar 2017 00:18:24 0000, commits at source.squeak.org
> >> <commits at source.squeak.org> wrote:
> >> > A new version of Graphics was added to project The Inbox:
> >> > http://source.squeak.org/inbox/Graphics-cbc.372.mcz
> >> >
> >> > ==================== Summary ====================
> >> >
> >> > Name: Graphics-cbc.372
> >> > Author: cbc
> >> > Time: 28 March 2017, 5:18:09.019402 pm
> >> > UUID: 7b9783b1-87c5-3549-ac32-42acd6abcb12
> >> > Ancestors: Graphics-eem.371
> >> >
> >> > Added method to allow creating a rectangle based on teh center of the
> >> > rectangle.
> >> >
> >> > =============== Diff against Graphics-eem.371 ===============
> >> >
> >> > Item was added:
> >> > + ----- Method: Rectangle class>>exactCenter:extent: (in category
> >> 'instance
> >> > creation') -----
> >> > + exactCenter: centerPoint extent: extentPoint
> >> > +     "Answer an instance of me whose center is centerPoint and width
> >> > +     by height is extentPoint. "
> >> > +     ^ self origin: centerPoint - (extentPoint / 2) extent:
> >> > extentPoint
> >> > + !
> >> >
> >> >
> >> >
> >>
> >>
> >
>
>


-- 
_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20170329/9b82f656/attachment.html>


More information about the Squeak-dev mailing list