Ratatouille v0.5.1 Ratatouille.Renderer.Box View Source

This defines the internal representation of a rectangular region---a box---for rendering, as well as logic for transforming these boxes.

Boxes live on a coordinate plane. The y-axis is inverted so that the y values increase as the box's height grows.

--------------> x
|
|    ________
|    |      |
|    |______|
v
y

A Box struct stores the coordinates for two corners of the box---the top-left and bottom-right corners--from which the remaining attributes (height, width, other corners) can be computed.

 _________________
|                 |
|  A              |
|                 |
|                 |
|                 |
|              B  |
|_________________|

A: top-left corner, e.g. (0, 0)
B: bottom-right corner, e.g. (10, 10)

For rendering purposes, the outermost box will typically have a top-left corner (0, 0) and a bottom-right corner (x, y) where x is the number of rows and y is the number of columns on the terminal.

This outermost box can then be subdivided as necessary to render different elements of the view.

Link to this section Summary

Link to this section Functions

Link to this function

contains?(box, position)

View Source
Link to this function

from_dimensions(width, height, origin \\ %Position{x: 0, y: 0})

View Source

Given a box, returns a slice of the y axis with n rows from the top.

Given a box, returns a slice of the y axis with n rows from the bottom.