types

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UnitMetre      = &LengthUnit{Rat: *big.NewRat(1, 1)}
	UnitCentimetre = &LengthUnit{Rat: metersIn1Centimeter}
	UnitInch       = &LengthUnit{Rat: metersIn1Inch}

	UnitPixelsPerMetre      = &PixelDensityUnit{Rat: *big.NewRat(1, 1)}
	UnitPixelsPerCentimetre = &PixelDensityUnit{Rat: metersIn1Centimeter}
	UnitPixelsPerInch       = &PixelDensityUnit{Rat: metersIn1Inch}
)

Functions

This section is empty.

Types

type Date

type Date string

func (Date) Components

func (d Date) Components() (year int, month int, day int, err error)

func (Date) Valid

func (d Date) Valid() bool

type Flip

type Flip string
const (
	FlipBook      Flip = "book"
	FlipLeftHand  Flip = "left-hand"
	FlipCalendar  Flip = "calendar"
	FlipRightHand Flip = "right-hand"
)

func (Flip) Heteroriented

func (flip Flip) Heteroriented() bool

Heteroriented will be true if the card need to pivot about a diagonal axis for the front and back to remain upright. the negation of this method is always whether the card is homoriented or not.

func (Flip) String

func (flip Flip) String() string

type LatLong

type LatLong struct {
	Latitude  float64 `json:"lat"`
	Longitude float64 `json:"long"`
}

func (LatLong) MarshalJSON

func (ll LatLong) MarshalJSON() ([]byte, error)

func (LatLong) MarshalYAML

func (ll LatLong) MarshalYAML() (interface{}, error)

func (LatLong) String

func (ll LatLong) String() string

func (*LatLong) UnmarshalJSON

func (ll *LatLong) UnmarshalJSON(b []byte) error

func (*LatLong) UnmarshalYAML

func (ll *LatLong) UnmarshalYAML(y *yaml.Node) error

type Length

type Length struct {
	Count *big.Rat
	Unit  *LengthUnit
}

func (Length) Convert

func (l Length) Convert(u *LengthUnit) Length

func (Length) In

func (l Length) In(u *LengthUnit) float64

func (Length) MarshalJSON

func (l Length) MarshalJSON() ([]byte, error)

func (Length) String

func (l Length) String() string

func (*Length) UnmarshalJSON

func (l *Length) UnmarshalJSON(b []byte) error

type LengthUnit

type LengthUnit Unit

func (*LengthUnit) String

func (l *LengthUnit) String() string

type LocalizedText

type LocalizedText map[string]string

type Metadata

type Metadata struct {
	Location        LatLong `json:"location,omitempty"`
	Flip            Flip    `json:"flip" yaml:"flip"`
	SentOn          Date    `json:"sentOn,omitempty" yaml:"sent_on"`
	Sender          string  `json:"sender,omitempty"`
	Recipient       string  `json:"recipient,omitempty"`
	Front           Side    `json:"front,omitempty"`
	Back            Side    `json:"back,omitempty"`
	FrontDimensions Size    `json:"frontSize" yaml:",omitempty"`
}

type PixelDensity

type PixelDensity struct {
	Count *big.Rat
	Unit  *PixelDensityUnit
}

func (PixelDensity) Convert

Convert returns a new pixel density struct in the given units, converting without loss of fidelity. Will panic if the unit is of the wrong type.

func (PixelDensity) String

func (pd PixelDensity) String() string

type PixelDensityUnit

type PixelDensityUnit Unit

func (*PixelDensityUnit) String

func (pd *PixelDensityUnit) String() string

type Point

type Point struct {
	X float64
	Y float64
}

Point represents a point on a postcard, stored as a percentage of the width (X) or height (Y) where 1.0 is the right, or bottom, of the postcard, and 0 is the left, or top.

func (Point) ToPixels

func (p Point) ToPixels(w, h int) (float64, float64)

type Polygon

type Polygon []Point

func (Polygon) MarshalJSON

func (pts Polygon) MarshalJSON() ([]byte, error)

func (Polygon) MarshalYAML

func (pts Polygon) MarshalYAML() (interface{}, error)

func (*Polygon) UnmarshalJSON

func (pts *Polygon) UnmarshalJSON(b []byte) error

func (*Polygon) UnmarshalYAML

func (pts *Polygon) UnmarshalYAML(y *yaml.Node) error

type Postcard

type Postcard struct {
	Meta  Metadata
	Front []byte
	Back  []byte
}

type Resolution

type Resolution struct {
	XResolution PixelDensity
	YResolution PixelDensity
}

func (Resolution) Convert

func (r Resolution) Convert(u *PixelDensityUnit) Resolution

func (Resolution) Size

func (r Resolution) Size(w, h int) Size

func (Resolution) String

func (r Resolution) String() string

type SecretBox

type SecretBox struct {
	Type   string  `yaml:"type"`
	Width  float64 `yaml:"width"`
	Height float64 `yaml:"height"`
	Left   float64 `yaml:"left"`
	Top    float64 `yaml:"top"`
}

type SecretPolygon

type SecretPolygon struct {
	Type   string      `yaml:"type"`
	Points [][]float64 `yaml:"points"`
}

type SecretType

type SecretType struct {
	Type string `yaml:"type"`
}

type Side

type Side struct {
	Description   LocalizedText `json:"description,omitempty"`
	Transcription LocalizedText `json:"transcription,omitempty"`
	Secrets       []Polygon     `json:"secrets,omitempty"`
}

type Size

type Size struct {
	Width  Length `json:"w"`
	Height Length `json:"h"`
}

func (Size) Convert

func (s Size) Convert(u *LengthUnit) Size

func (Size) Resolution

func (s Size) Resolution(w, h int) Resolution

func (Size) String

func (s Size) String() string

type Unit

type Unit struct{ big.Rat }

Unit holds conversion factor to SI units

type Version

type Version struct {
	Major uint8
	Minor uint8
	Patch uint8
}

func MustParseVersion

func MustParseVersion(str string) Version

func (Version) LessThan

func (v Version) LessThan(o Version) bool

func (Version) String

func (v Version) String() string

Jump to

Keyboard shortcuts

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