cell

package
v0.0.0-...-0f375d1 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: Unlicense Imports: 0 Imported by: 0

Documentation

Overview

cell provides basic cell geometries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pt

type Pt struct {
	L int // line
	O int // offset
}

Pt is a line oriented cell position.

func (Pt) Add

func (p Pt) Add(q Pt) Pt

Add moves a point to direction of q.

func (Pt) Compare

func (a Pt) Compare(b Pt) int

Compare compares two Pt a and b. If a < b, it will return -1. If a > b, it will return 1. If a == b, it will return 0

func (Pt) Sub

func (p Pt) Sub(q Pt) Pt

Add moves a point to opposite direction of q.

type Range

type Range struct {
	Start Pt
	End   Pt
}

Range is a range between two points which excludes max.

Start is not necessarily before than End. For that purpose, use MinMax.

func (Range) Contains

func (r Range) Contains(p Pt) bool

Contains checks whether it contain's p.

func (Range) Lines

func (r Range) Lines() []int

Lines returns line numbers the Range includes, as int slice. Note it will not return last line number if Max's offset is 0.

func (Range) Max

func (r Range) Max() Pt

Max returns the Ranges's maximum position.

func (Range) Min

func (r Range) Min() Pt

Min returns the Range's minimum position.

func (*Range) MinMax

func (r *Range) MinMax() (Pt, Pt)

MinMax return the Range's caculated Min and Max points.

type Rect

type Rect struct {
	Start Pt
	End   Pt
}

Rect is a rectangle area which exculdes Max.

Start is not necessarily before than End. For that purpose, use MinMax.

func (Rect) Max

func (r Rect) Max() Pt

Max returns the Rect's bottom right position.

func (Rect) Min

func (r Rect) Min() Pt

Min returns the Rect's top left position.

func (Rect) MinMax

func (r Rect) MinMax() (Pt, Pt)

MinMax returns the Rect's caculated Min and Max positions.

func (Rect) Size

func (a Rect) Size() Pt

Size returns size of the Rect as a point.

Jump to

Keyboard shortcuts

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