Expose access to bounding box edges
ruuda opened this issue · comments
Currently it is impossible to write a correct center
function in Pris. The following has the wrong offset when the top-left corner of the bounding box does not coincide with the origin of a frame:
center = function(frame)
{
at frame.size * -0.5 put frame
}
The correct version would be:
center = function(frame)
{
at (frame.size * -0.5) - frame.top_left put frame
}
where top_left
is the offset of the top-left corner of the bounding box, to the origin. As the origin is always included in the bounding box (should it be?), this offset is either negative or zero.
Bikeshed: what is a good intuitive name for this? top_left
? offset
? The following fields also exist currently:
width
: width of the bounding box.height
: height of the bounding box.size
: (width, height) of the bounding box.anchor
: offset relative to the origin of the frame, where new frames can be adjoined. (Not yet implemented.)
offset
for the top-left corner has been implemented in f16b36f.
This has been implemented, although I am not entirely sure whether the current system with a size
, offset
, and anchor
is what I really want. But at least for now it works well enough.