[squeak-dev] The Inbox: Graphics-ct.437.mcz

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Mon Aug 24 11:39:10 UTC 2020


In particular, when it comes to LayoutFrames, I have to say that I find the automatic rounding behaviors of Point/Rectangle quite confusing.


For instance, why does #scaleBy: allow producing float points/rectangles whereas #scaleFrom:to: applies rounding?

In my opinion, the integer/float arithmetic of Point and Rectangle is not really clear. If these classes are intended containing integers only, the "truncation and round off" protocol would be redundant. If they are intended to contain floats as well, it is confusing that methods such as #center and #aboveCenter apply rounding. Would it be possible and wise to eliminate that automatic rounding behavior, or is too old and popular for such a breaking change?


See also this related discussion: http://forum.world.st/The-Inbox-Graphics-cbc-372-mcz-td4940274.html

Best,
Christoph
________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von commits at source.squeak.org <commits at source.squeak.org>
Gesendet: Montag, 24. August 2020 13:26:55
An: squeak-dev at lists.squeakfoundation.org
Betreff: [squeak-dev] The Inbox: Graphics-ct.437.mcz

Christoph Thiede uploaded a new version of Graphics to project The Inbox:
http://source.squeak.org/inbox/Graphics-ct.437.mcz

==================== Summary ====================

Name: Graphics-ct.437
Author: ct
Time: 24 August 2020, 1:26:40.516818 pm
UUID: 66c6c2fd-6978-6d43-8eda-c22f0a5defca
Ancestors: Graphics-kfr.436

Proposal: Add Point >> #exactCenter:, complementing Graphics-cbc.372. Refine relevant method comments in Point and Rectangle.

Usage example:

        m := Morph new.
        m changeProportionalLayout.

        n := Morph new.
        n color: Color red.
        m addMorph: n fullFrame: (LayoutFrame fractions: (
                0.5 @ 0.25 exactCenter: 0.5 @ 0.5)).

        m openInHand.

=============== Diff against Graphics-kfr.436 ===============

Item was changed:
  ----- Method: Point>>center: (in category 'converting to rectangle') -----
  center: aPoint
+        "Answer a Rectangle whose extent is the receiver and whose center is approximately aPoint (after rounding to integers). This is one of the infix ways of expressing the creation of a rectangle."
-        "Answer a Rectangle whose extent is the receiver and whose center is
-        aPoint. This is one of the infix ways of expressing the creation of a
-        rectangle."

+        ^ Rectangle center: aPoint extent: self!
-        ^Rectangle center: aPoint extent: self!

Item was added:
+ ----- Method: Point>>exactCenter: (in category 'converting to rectangle') -----
+ exactCenter: aPoint
+        "Answer a Rectangle whose extent is the receiver and whose center is exactly aPoint. This is one of the infix ways of expressing the creation of a rectangle."
+
+        ^ Rectangle exactCenter: aPoint extent: self!

Item was changed:
  ----- Method: Rectangle class>>center:extent: (in category 'instance creation') -----
  center: centerPoint extent: extentPoint
+        "Answer an instance of me whose center is approximately centerPoint (after rounding to integers) and whose extent is extentPoint."
-        "Answer an instance of me whose center is centerPoint and width
-        by height is extentPoint.  "

+        ^ self origin: centerPoint - (extentPoint // 2) extent: extentPoint!
-        ^self origin: centerPoint - (extentPoint//2) extent: extentPoint!

Item was changed:
  ----- Method: Rectangle class>>exactCenter:extent: (in category 'instance creation') -----
  exactCenter: centerPoint extent: extentPoint
+        "Answer an instance of me whose center is exactly centerPoint and whose extent is extentPoint."
+
-        "Answer an instance of me whose center is centerPoint and width
-        by height is extentPoint. "
         ^ self origin: centerPoint - (extentPoint / 2) extent: extentPoint
  !


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200824/66d0997a/attachment-0001.html>


More information about the Squeak-dev mailing list