ruuda / pris

A language for designing slides
https://docs.ruuda.nl/pris/
GNU General Public License v3.0
116 stars 5 forks source link

Expose access to bounding box edges #2

Closed ruuda closed 6 years ago

ruuda commented 7 years ago

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:

ruuda commented 7 years ago

offset for the top-left corner has been implemented in f16b36f2cb9b961495002603028999429a1be68e.

ruuda commented 6 years ago

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.