box

package
v0.0.0-...-ae32867 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2020 License: BSD-3-Clause Imports: 3 Imported by: 0

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

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

View Source
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.

func (*Box) Enlarge

func (box *Box) Enlarge(scales dimen.Point) *Box

Enlarge a box in x- and y-direction. For shrinking, use negative argument(s).

func (*Box) Normalize

func (box *Box) Normalize() *Box

Normalize sorts the corner coordinates into correct order.

func (*Box) Shift

func (box *Box) Shift(vector dimen.Point) *Box

Shift a box along a vector. The size of the box is unchanged.

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 LineStyle

type LineStyle int8

LineStyle is a type for border line styles.

const (
	LSSolid  LineStyle = 0
	LSDashed LineStyle = 1
	LSDotted LineStyle = 2
)

We support these line styles only

type StyledBox

type StyledBox struct {
	Box
	Styling *Styling
}

StyledBox is a type for a fully stylable box.

type Styling

type Styling struct {
	TextStyle TextStyle
	Colors    ColorStyle
	Border    BorderStyle
}

Styling rolls all styling options into one type.

type TextStyle

type TextStyle struct {
	Typecase *font.TypeCase
}

TextStyle is a type for styling text.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL