|
HikoGUI
A low latency retained GUI
|
The vec class is a 4D homogeneous coordinate.
Internally this is a __m128 on x64 CPUs, where the bits are:
The vec() constructor will default with w=0.0. There are also the vec::point() and vec::color() factories which default w=1.0.
The mat class is a 4x4 homogeneous transformation matrix in column-major order. Internally this a vec for each column.
Vector * matrix multiplications are performed as if the vector is a column.
The aarect class is a 2D axis-aligned rectangle.
Internally this is a vec where:
All origins (0, 0, 0) are at the bottom-left-far corner. With the x-axis pointing right, y-axis pointing up, z-axis pointing near.
This is true for:
The local coordinates in a window and widgets are in points. With the origin in the corner of the left bottom most point.
The local x,y-coordinates are multiplied by the DPI-scale of the window. The DPI-scale is always an integer, which allows much easier alignment of lines to actual pixels.
The alignment of borders to pixels is the responsibility of the widget that draws itself. The widget has access to the draw_context::drawBoxIncludingBorder() function to position the border's edge to the edge of the given rectangle, if the rectangle is rounded to integer coordinates; the rectangle, border and pixel will share the same edge.
At DPI-scale of 1, it is assumed that the display has a 84 DPI. This is the middle ground between Window's default 96 DPI and macOS's default 72 DPI. The ShapedText class will scale to 84 DPI automatically, further DPI scaling will be handled by the draw_context.
Z-coordinate for a window is between 0.0 (far) to 100.0 (near). For better precision we use a reverse-z method, to combine 1/z together with float with linear precision.
The coordinates in a image are in pixels. With the center of the left bottom pixel having the coordinates (0.5, 0.5).
The coordinates in a path are free from scale and origin, when rendering a path to an image, the path should be first be transformed to image coordinates.
Glyph coordinates are in the number of Em units. X-axis pointing right, Y-axis pointing up. The origin (0,0) is on the crossing of the base line and left side bearing. Vertices of front faces are specified in counter clockwise order.
Corners are enumerated as follows:
When corners are passing as 4D vectors:
A front facing triangle has the vertex ordered in counter-clockwise direction.
Quads are defined as two front facing triangles. The vertex index order is: 0, 1, 2, 2, 1, 3
As illustrated below: