ptypes

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2021 License: Apache-2.0 Imports: 3 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QuarkToString

func QuarkToString(id QuarkID) string

Gets the string associated with the given GQuark.

Parameters:

quark    a GQuark.

Returns:

the string associated with the GQuark

Types

type CQuark

type CQuark struct {
	// contains filtered or unexported fields
}

Quarks are associations between strings and integer identifiers. Given either the string or the QuarkID identifier it is possible to retrieve the other.

Quarks are used for both datasets and keyed data lists.

To create a new quark from a string, use QuarkFromString().

To find the string corresponding to a given QuarkID, use QuarkID.ToString().

To find the QuarkID corresponding to a given string, use QuarkID.TryString().

func (CQuark) ID

func (q CQuark) ID() QuarkID

func (CQuark) String

func (q CQuark) String() string

type Point2I

type Point2I struct {
	X, Y int
}

Point2I is a 2-aspect vector represented by x and y coordinates.

func MakePoint2I

func MakePoint2I(x, y int) Point2I

Construct a new Point2I structure (non-pointer)

func NewPoint2I

func NewPoint2I(x, y int) *Point2I

Construct a new instance of a Point2I structure

func ParsePoint2I

func ParsePoint2I(value string) (point Point2I, ok bool)

Parse a Point2I structure from a string representation. There are two valid formats supported by this parser function:

formal    "{x:0,y:0}"
plain     "0 0"

func (*Point2I) Add

func (p *Point2I) Add(x, y int)

add the given x and y values to this Point2I

func (*Point2I) AddPoint

func (p *Point2I) AddPoint(point Point2I)

add the given Point2I to this Point2I

func (*Point2I) ClampToRegion

func (p *Point2I) ClampToRegion(region Region) (clamped bool)

restrict this Point2I instance to be within the boundaries defined by the given region

func (Point2I) Clone

func (p Point2I) Clone() (clone Point2I)

returns a new Point2I structure with the same values as this structure

func (Point2I) Equals

func (p Point2I) Equals(x, y int) bool

returns true if both the given x and y coordinates and this Point2I are equivalent, returns false otherwise

func (Point2I) EqualsTo

func (p Point2I) EqualsTo(o Point2I) bool

returns true if both the given Point2I and this Point2I are equivalent and false otherwise

func (Point2I) NewClone

func (p Point2I) NewClone() (clone *Point2I)

returns a new Point2I instance with the same values as this structure

func (*Point2I) Set

func (p *Point2I) Set(x, y int)

set this Point2I instance to the given x and y values

func (*Point2I) SetPoint

func (p *Point2I) SetPoint(point Point2I)

set this Point2I instance to be equivalent to the given Point2I

func (Point2I) String

func (p Point2I) String() string

returns a formal string representation of the Point2I structure, ie: "{x:0,y:0}"

func (*Point2I) Sub

func (p *Point2I) Sub(x, y int)

subtract the given x and y values from this Point2I instance

func (*Point2I) SubPoint

func (p *Point2I) SubPoint(point Point2I)

subtract the given Point2I's values from this Point2I instance

type QuarkID

type QuarkID uint64

A QuarkID is a non-zero integer which uniquely identifies a particular string. A QuarkID value of zero is associated to nil.

func QuarkFromString

func QuarkFromString(text string) (qid QuarkID)

Gets the QuarkID identifying the given string. If the string does not currently have an associated QuarkID, a new QuarkID is created, using a copy of the string.

This function must not be used before library constructors have finished running.

Parameters string a string.

Returns

the QuarkID identifying the string, or 0 if string is nil

func QuarkTryString

func QuarkTryString(text string) QuarkID

Gets the GQuark associated with the given string, or 0 if string is nil or it has no associated QuarkID.

If you want the GQuark to be created if it doesn't already exist, use QuarkFromString().

This function must not be used before library constructors have finished running.

Parameters

string     a string.

Returns

the GQuark associated with the string, or 0 if string is nil or there is
no GQuark associated with it

type Range

type Range struct {
	Start, End int
}

func MakeRange

func MakeRange(start, end int) Range

func NewRange

func NewRange(start, end int) *Range

func (Range) String

func (r Range) String() string

type Rectangle

type Rectangle struct {
	W, H int
}

Rectangle is a 2-aspect vector represented by width and height values

func MakeRectangle

func MakeRectangle(w, h int) Rectangle

Construct a new Point2I structure (non-pointer)

func NewRectangle

func NewRectangle(w, h int) *Rectangle

Construct a new instance of a Point2I structure

func ParseRectangle

func ParseRectangle(value string) (point Rectangle, ok bool)

Parse a Point2I structure from a string representation. There are two valid formats supported by this parser function:

formal    "{w:0,h:0}"
plain     "0 0"

func (*Rectangle) Add

func (r *Rectangle) Add(w, h int)

add the given w and h values to this Point2I

func (*Rectangle) AddRectangle

func (r *Rectangle) AddRectangle(size Rectangle)

add the given Point2I to this Point2I

func (*Rectangle) Clamp

func (r *Rectangle) Clamp(minWidth, minHeight, maxWidth, maxHeight int)

constrain the width and height values to be within the given ranges of min and max values

func (*Rectangle) ClampToRegion

func (r *Rectangle) ClampToRegion(region Region) (clamped bool)

func (Rectangle) Clone

func (r Rectangle) Clone() (clone Rectangle)

returns a new Point2I structure with the same values as this structure

func (Rectangle) Equals

func (r Rectangle) Equals(w, h int) bool

returns true if both the given x and y coordinates and this Point2I are equivalent, returns false otherwise

func (Rectangle) EqualsTo

func (r Rectangle) EqualsTo(o Rectangle) bool

returns true if both the given Point2I and this Point2I are equivalent and false otherwise

func (*Rectangle) Floor

func (r *Rectangle) Floor(minWidth, minHeight int)

constrain the width and height values to be at least the given values or greater

func (Rectangle) NewClone

func (r Rectangle) NewClone() (clone *Rectangle)

returns a new Point2I instance with the same values as this structure

func (*Rectangle) Set

func (r *Rectangle) Set(w, h int)

set this Point2I instance to the given x and y values

func (*Rectangle) SetRectangle

func (r *Rectangle) SetRectangle(size Rectangle)

set this Point2I instance to be equivalent to the given Point2I

func (Rectangle) String

func (r Rectangle) String() string

returns a formal string representation of the Point2I structure, ie: "{w:0,h:0}"

func (*Rectangle) Sub

func (r *Rectangle) Sub(w, h int)

subtract the given x and y values from this Point2I instance

func (*Rectangle) SubRectangle

func (r *Rectangle) SubRectangle(size Rectangle)

subtract the given Point2I's values from this Point2I instance

func (Rectangle) Volume

func (r Rectangle) Volume() int

returns the volume of the Rectangle (w * h)

type Region

type Region struct {
	Point2I
	Rectangle
}

func MakeRegion

func MakeRegion(x, y, w, h int) Region

func NewRegion

func NewRegion(x, y, w, h int) *Region

func ParseRegion

func ParseRegion(value string) (point Region, ok bool)

func (Region) Clone

func (r Region) Clone() (clone Region)

func (Region) FarPoint

func (r Region) FarPoint() Point2I

func (Region) HasPoint

func (r Region) HasPoint(pos Point2I) bool

func (Region) NewClone

func (r Region) NewClone() (clone *Region)

func (Region) Origin

func (r Region) Origin() Point2I

func (*Region) Set

func (r *Region) Set(x, y, w, h int)

func (*Region) SetRegion

func (r *Region) SetRegion(region Region)

func (Region) Size

func (r Region) Size() Rectangle

func (Region) String

func (r Region) String() string

Jump to

Keyboard shortcuts

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