[Grace-core] Simple graphics and GUI interface
Andrew P. Black
black at cs.pdx.edu
Mon Jul 21 08:57:27 PDT 2014
>
> But here you're suggesting using a "point" to represent something that
> is just a pair of numbers. Width and height are not a point. Opposite
> corner is a point.
The width and height of a rectangle — it’s extent — can be described by a 2D Vector — which is what we are calling Point2D. It’s convenient to use a vector rather than a pair of numbers because you can then do arithmetic on them, such as
def corner = origin + extent
def center = origin + (extent / 2)
These formulae are simpler to both write and to read than
def cornerX = origin.x + width
def cornerY = origin.y + height
def corner = cornerX at cornerY
Andrew
More information about the Grace-core
mailing list