Hello. I found very interesting method. Should it really be like that? Or maybe we need to rename this method as #roundedCenter and add the normal #center with usual division? Best regards, Natalia
Natalia Tymchuk wrote
Should it really be like that?
The problem is that you can't have half-a-pixel if a dimension is odd ----- Cheers, Sean -- View this message in context: http://forum.world.st/Rectangle-Center-tp4822883p4822891.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
On 29 Apr 2015, at 15:18, Sean P. DeNigris <sean@clipperadams.com> wrote:
Natalia Tymchuk wrote
Should it really be like that?
The problem is that you can't have half-a-pixel if a dimension is odd
Well, the methods is not called #centerPixel, nor is the class called PixelatedRectangle. Both #origin and #corner return not rounded values. And any way, I invite everyone to read the bug report by Tommaso, he described in a really nice way: https://pharo.fogbugz.com/f/cases/15445/Rectangle-center-not-really-a-center... <https://pharo.fogbugz.com/f/cases/15445/Rectangle-center-not-really-a-center...> Uko
----- Cheers, Sean -- View this message in context: http://forum.world.st/Rectangle-Center-tp4822883p4822891.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
On Wed, Apr 29, 2015 at 3:51 PM, Yuriy Tymchuk <yuriy.tymchuk@me.com> wrote:
On 29 Apr 2015, at 15:18, Sean P. DeNigris <sean@clipperadams.com> wrote:
Natalia Tymchuk wrote
Should it really be like that?
The problem is that you can't have half-a-pixel if a dimension is odd
Well, the methods is not called #centerPixel, nor is the class called PixelatedRectangle. Both #origin and #corner return not rounded values. And any way, I invite everyone to read the bug report by Tommaso, he described in a really nice way: https://pharo.fogbugz.com/f/cases/15445/Rectangle-center-not-really-a-center...
I thought so too, but if you read the class comment: "I represent a rectangular area of the screen." So it seems designed for screen, and screen operates on whole pixels. Thus there is no reason to round #origin or #corner because it will be always integer (for screen). So maybe split into Rectangle (=An actual rectangle) without rounding and ScreenRectangle? Peter
On Wed, Apr 29, 2015 at 10:12 PM, Peter Uhnák <i.uhnak@gmail.com> wrote:
On Wed, Apr 29, 2015 at 3:51 PM, Yuriy Tymchuk <yuriy.tymchuk@me.com> wrote:
On 29 Apr 2015, at 15:18, Sean P. DeNigris <sean@clipperadams.com> wrote:
Natalia Tymchuk wrote
Should it really be like that?
The problem is that you can't have half-a-pixel if a dimension is odd
Well, the methods is not called #centerPixel, nor is the class called PixelatedRectangle. Both #origin and #corner return not rounded values. And any way, I invite everyone to read the bug report by Tommaso, he described in a really nice way: https://pharo.fogbugz.com/f/cases/15445/Rectangle-center-not-really-a-center...
I thought so too, but if you read the class comment: "I represent a rectangular area of the screen."
So it seems designed for screen, and screen operates on whole pixels. Thus there is no reason to round #origin or #corner because it will be always integer (for screen).
So maybe split into Rectangle (=An actual rectangle) without rounding and ScreenRectangle?
Peter
Yeah. But how old is that class comment? :) Rectangle>>aboveCenter is dated 2000. Rectangle>>center has no date. The world moves on.... so we can make it what we will. Simple naive fix... change the class comment (if indeed usage has moved on from assumption of a pixelated screen) So apart from working around class comments, what do we gain by having two types or Rectangles? cheers -ben
It seems that the problem is not with the Rectangle per se, but the type of measure it uses. Maybe the responsibility of being always an Integer measure should be delegated to the measure itself. Like, instead of using numbers, you could use Measures (from Aconcagua) that are 100 pixels instead of 100 (Integer) I don't know if Aconcagua has implemented units that are always a certain type, yet. â
On Wed, Apr 29, 2015 at 9:18 PM, Sean P. DeNigris <sean@clipperadams.com> wrote:
Natalia Tymchuk wrote
Should it really be like that?
The problem is that you can't have half-a-pixel if a dimension is odd
Will it be more applicable with the move to vector basis of Athens? cheers -ben
2015-04-29 16:09 GMT+02:00 Ben Coman <btc@openinworld.com>:
On Wed, Apr 29, 2015 at 9:18 PM, Sean P. DeNigris <sean@clipperadams.com> wrote:
Natalia Tymchuk wrote
Should it really be like that?
The problem is that you can't have half-a-pixel if a dimension is odd
Will it be more applicable with the move to vector basis of Athens? cheers -ben
For athens, you'll have to make sure it is indeed a Float, and not a Fraction. (Some athens methods explicitly call #asFloat for their arguments - but not all).
On 29/04/15 15:18, Sean P. DeNigris wrote:
Natalia Tymchuk wrote
Should it really be like that?
The problem is that you can't have half-a-pixel if a dimension is odd
For these situations, I would use the method #floor or #rounded of the class Point, or create the method #roundedCenter, as Natalia suggested. Currently, the name of the class and the method communicate the wrong behavior. Tommaso
----- Cheers, Sean -- View this message in context: http://forum.world.st/Rectangle-Center-tp4822883p4822891.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
2015-04-29 18:50 GMT+02:00 Tommaso Dal Sasso <tommaso.dalsasso@gmail.com>:
On 29/04/15 15:18, Sean P. DeNigris wrote:
Natalia Tymchuk wrote
Should it really be like that?
The problem is that you can't have half-a-pixel if a dimension is odd
For these situations, I would use the method #floor or #rounded of the class Point, or create the method #roundedCenter, as Natalia suggested.
Currently, the name of the class and the method communicate the wrong behavior.
Tommaso
Rectangle was and still is a primitive type known to low level graphics operations. It's just that it pre-empts a word that is more generic than the implementation ;) You can't even rotate a rectangle... It's just a clipping or viewport rectangle having same orientation as a rectangular target canvas (image, bitmap, screen or other device). Depending on what you are after, it's maybe not the right abstraction... That does not mean that Rectangle can't be changed. That means that it must be carefully changed as long as it is used for the low level stuff... ...or it must be split. Maybe it's where namespaces might help. Nicolas
----- Cheers, Sean -- View this message in context:
http://forum.world.st/Rectangle-Center-tp4822883p4822891.html
Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
Ok, can we start form the test? Is it ok, that the test passes for rectangle with 10 @ 20 extent and fails for 15 @ 20 extent? Uko
On 29 Apr 2015, at 19:11, Nicolas Cellier <nicolas.cellier.aka.nice@gmail.com> wrote:
2015-04-29 18:50 GMT+02:00 Tommaso Dal Sasso <tommaso.dalsasso@gmail.com <mailto:tommaso.dalsasso@gmail.com>>:
On 29/04/15 15:18, Sean P. DeNigris wrote:
Natalia Tymchuk wrote
Should it really be like that?
The problem is that you can't have half-a-pixel if a dimension is odd
For these situations, I would use the method #floor or #rounded of the class Point, or create the method #roundedCenter, as Natalia suggested.
Currently, the name of the class and the method communicate the wrong behavior.
Tommaso
Rectangle was and still is a primitive type known to low level graphics operations. It's just that it pre-empts a word that is more generic than the implementation ;)
You can't even rotate a rectangle... It's just a clipping or viewport rectangle having same orientation as a rectangular target canvas (image, bitmap, screen or other device).
Depending on what you are after, it's maybe not the right abstraction...
That does not mean that Rectangle can't be changed. That means that it must be carefully changed as long as it is used for the low level stuff...
...or it must be split. Maybe it's where namespaces might help.
Nicolas
----- Cheers, Sean -- View this message in context: http://forum.world.st/Rectangle-Center-tp4822883p4822891.html <http://forum.world.st/Rectangle-Center-tp4822883p4822891.html> Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com <http://nabble.com/>.
On Thu, Apr 30, 2015 at 4:53 AM, Sergio Fedi <sergio.fedi@gmail.com> wrote:
On Wed, Apr 29, 2015 at 5:42 PM, Yuriy Tymchuk <yuriy.tymchuk@me.com> wrote:
Ok, can we start form the test?
Is it ok, that the test passes for rectangle with 10 @ 20 extent and fails for 15 @ 20 extent?
I would make it test both coordinates.
i.e. test for 15 @ 15 extent
That would be 15@20 and 20@15. :) cheers -ben
The best would be to have ScaledRectangle but with all vector graphics operations. and independent from Rectangle just reimplementing the right part of the rectangle API. Le 29/4/15 19:11, Nicolas Cellier a écrit :
2015-04-29 18:50 GMT+02:00 Tommaso Dal Sasso <tommaso.dalsasso@gmail.com <mailto:tommaso.dalsasso@gmail.com>>:
On 29/04/15 15:18, Sean P. DeNigris wrote: > Natalia Tymchuk wrote >> Should it really be like that? > > The problem is that you can't have half-a-pixel if a dimension is odd >
For these situations, I would use the method #floor or #rounded of the class Point, or create the method #roundedCenter, as Natalia suggested.
Currently, the name of the class and the method communicate the wrong behavior.
Tommaso
Rectangle was and still is a primitive type known to low level graphics operations. It's just that it pre-empts a word that is more generic than the implementation ;)
You can't even rotate a rectangle... It's just a clipping or viewport rectangle having same orientation as a rectangular target canvas (image, bitmap, screen or other device).
Depending on what you are after, it's maybe not the right abstraction...
That does not mean that Rectangle can't be changed. That means that it must be carefully changed as long as it is used for the low level stuff...
...or it must be split. Maybe it's where namespaces might help.
Nicolas
> > > ----- > Cheers, > Sean > -- > View this message in context: http://forum.world.st/Rectangle-Center-tp4822883p4822891.html > Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com. >
Le 29/04/2015 15:20, Natalia Tymchuk a écrit :
Hello. I found very interesting method.
Should it really be like that? Or maybe we need to rename this method as #roundedCenter and add the normal #center with usual division? Best regards, Natalia
I believe I had to correct a bug with Roassal scaling and centering because of the rounding done in that method. Had to reimplement a proper center computation for rectangles in Roassal or Trachel. Thierry
participants (11)
-
Ben Coman -
Natalia Tymchuk -
Nicolai Hess -
Nicolas Cellier -
Peter Uhnák -
Sean P. DeNigris -
Sergio Fedi -
stepharo -
Thierry Goubier -
Tommaso Dal Sasso -
Yuriy Tymchuk