parser

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExpressionParser

type ExpressionParser struct {
	PPI   float64
	Debug bool
	// contains filtered or unexported fields
}

ExpressionParser represents the parser and interpreter for unit expressions

func (*ExpressionParser) Parse

func (p *ExpressionParser) Parse(input string) (Value, error)

Parse parses and evaluates the input expression

func (*ExpressionParser) ValueWithOriginal

func (p *ExpressionParser) ValueWithOriginal(v Value) string

ValueWithOriginal returns a string representation of the Value including its original input

type UnitConverter

type UnitConverter struct {
	PPI float64
}

func (*UnitConverter) FromCentimeter

func (uc *UnitConverter) FromCentimeter(cm float64) float64

func (*UnitConverter) FromEm

func (uc *UnitConverter) FromEm(em float64) float64

func (*UnitConverter) FromInch

func (uc *UnitConverter) FromInch(inches float64) float64

func (*UnitConverter) FromMillimeter

func (uc *UnitConverter) FromMillimeter(mm float64) float64

func (*UnitConverter) FromPica

func (uc *UnitConverter) FromPica(picas float64) float64

func (*UnitConverter) FromPixel

func (uc *UnitConverter) FromPixel(px float64) float64

func (*UnitConverter) FromPixels

func (uc *UnitConverter) FromPixels(pixels float64, unit string) (float64, error)

FromPixels converts a pixel value to the specified unit

func (*UnitConverter) FromPoint

func (uc *UnitConverter) FromPoint(points float64) float64

func (*UnitConverter) ToCentimeter

func (uc *UnitConverter) ToCentimeter(pixels float64) float64

func (*UnitConverter) ToEm

func (uc *UnitConverter) ToEm(pixels float64) float64

func (*UnitConverter) ToInch

func (uc *UnitConverter) ToInch(pixels float64) float64

func (*UnitConverter) ToMillimeter

func (uc *UnitConverter) ToMillimeter(pixels float64) float64

func (*UnitConverter) ToPica

func (uc *UnitConverter) ToPica(pixels float64) float64

func (*UnitConverter) ToPixel

func (uc *UnitConverter) ToPixel(pixels float64) float64

func (*UnitConverter) ToPixels

func (uc *UnitConverter) ToPixels(value float64, unit string) (float64, error)

ToPixels converts a value from a given unit to pixels

func (*UnitConverter) ToPoint

func (uc *UnitConverter) ToPoint(pixels float64) float64

type Value

type Value struct {
	Val      float64
	Unit     string
	StartPos int
	EndPos   int
}

Value represents a numeric value with its associated unit and position in the input string

func (Value) String

func (v Value) String() string

String returns a string representation of the Value

Jump to

Keyboard shortcuts

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