Documentation ¶
Overview ¶
Package box deals with typesetting boxes.
Typesetting may be understood as the process of placing boxes within larger boxes. The smallest type of box is a glyph, i.e. a printable letter. The largest type of box is a page—or even a book, where page-boxes are placed into.
The box model is very versatile. Nevertheless we will generalize the notion of a box to mean the bounding box of a polygon. Typesetting in irregular shapes is a feature available in most modern systems, e.g. when letting text flow around a non-rectangular illustration.
This module deals with rectangular boxes, starting at the glyph level. Boxes follow the CSS box model. Nevertheless, the notation oftentimes follows the one introduced by the TeX typesetting system.
BSD License ¶
Copyright (c) 2017–2020, Norbert Pillmayer ¶
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of this software nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Index ¶
Constants ¶
const ( Top int = iota Right Bottom Left )
For padding, margins
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BorderStyle ¶
type BorderStyle struct { LineColor color.Color LineThickness dimen.Dimen LineStyle int8 CornerRadius dimen.Dimen }
BorderStyle is a type for simple borders.
type Box ¶
type Box struct { dimen.Rect Min dimen.Point Max dimen.Point Padding [4]dimen.Dimen // inside of border Margins [4]dimen.Dimen // outside of border }
Box type, following the CSS box model.
type ColorStyle ¶
type ColorStyle struct { Foreground color.Color Background color.Color // may be (semi-)transparent }
ColorStyle is a type for styling with color.
type Glyph ¶
type Glyph struct { TextStyle *TextStyle Colors *ColorStyle CharPos rune }
Glyph is a box for glyphs. Glyphs currently are content-stylable only (no borders).
Wikipedia: In typography, a glyph [...] is an elemental symbol within an agreed set of symbols, intended to represent a readable character for the purposes of writing. [ Copyright (c) Wikipedia.com, 2017 ]
type Styling ¶
type Styling struct { TextStyle TextStyle Colors ColorStyle Border BorderStyle }
Styling rolls all styling options into one type.