[squeak-dev] Fractional co-ordinates

David T. Lewis lewis at mail.msen.com
Fri May 20 12:40:56 UTC 2011


On Fri, May 20, 2011 at 12:30:19PM +1000, Rodney Polkinghorne wrote:
> Hi again
> 
> I've noticed that Morphic handes floating-point co-ordinates such as
> 0.5, but raises a error with rational ones such as (1/2).  See change
> set below.  I think this behaviour is inherited from the drawing
> primitives.
> 
> To my mind, this is clearly wrong - if I can reduce things by 2.0, I
> should be able to reduce them by 2.  As a workaround, I'm inclined to
> add an "asFloat" to PolygonMorph>>vertexAt:Put:.  Being new to
> Smalltalk, I don't know what's right in general.
> 
> I tried to make this a test case, which asserted that a 0.5 morph lit
> up the same pixels as a 1/2 one.  I couldn't think of a way to do
> that.  Is it possible?

For a unit test, it would probably be better to think in terms of
the coordinate system for the morph itself, as opposed to the pixels.
So if you are testing something that affects the size of the morph,
you might write a test that verifies the new bounds (Morph>>bounds)
resulting from the test conditions, but don't worry about the pixels
that would result from this.

In this case, the test might simply verify that the input conditions
result in a morph with bounds that are a rectangle, and that the
rectangle does not contain any fractions in its vertices, which does
bad things, as you have noticed ;)

Dave




More information about the Squeak-dev mailing list