mirror of https://github.com/anoshenko/rui.git
Improved SizeUnit and AngleUnit functions
This commit is contained in:
parent
f81ffe6bed
commit
8a353f765e
16
angleUnit.go
16
angleUnit.go
|
@ -35,23 +35,23 @@ type AngleUnit struct {
|
|||
}
|
||||
|
||||
// Deg creates AngleUnit with Degree type
|
||||
func Deg(value float64) AngleUnit {
|
||||
return AngleUnit{Type: Degree, Value: value}
|
||||
func Deg[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) AngleUnit {
|
||||
return AngleUnit{Type: Degree, Value: float64(value)}
|
||||
}
|
||||
|
||||
// Rad create AngleUnit with Radian type
|
||||
func Rad(value float64) AngleUnit {
|
||||
return AngleUnit{Type: Radian, Value: value}
|
||||
func Rad[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) AngleUnit {
|
||||
return AngleUnit{Type: Radian, Value: float64(value)}
|
||||
}
|
||||
|
||||
// PiRad create AngleUnit with PiRadian type
|
||||
func PiRad(value float64) AngleUnit {
|
||||
return AngleUnit{Type: PiRadian, Value: value}
|
||||
func PiRad[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) AngleUnit {
|
||||
return AngleUnit{Type: PiRadian, Value: float64(value)}
|
||||
}
|
||||
|
||||
// Grad create AngleUnit with Gradian type
|
||||
func Grad(value float64) AngleUnit {
|
||||
return AngleUnit{Type: Gradian, Value: value}
|
||||
func Grad[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) AngleUnit {
|
||||
return AngleUnit{Type: Gradian, Value: float64(value)}
|
||||
}
|
||||
|
||||
// Equal compare two AngleUnit. Return true if AngleUnit are equal
|
||||
|
|
40
sizeUnit.go
40
sizeUnit.go
|
@ -62,53 +62,53 @@ func AutoSize() SizeUnit {
|
|||
}
|
||||
|
||||
// Px creates SizeUnit with SizeInPixel type
|
||||
func Px(value float64) SizeUnit {
|
||||
return SizeUnit{SizeInPixel, value, nil}
|
||||
func Px[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
|
||||
return SizeUnit{Type: SizeInPixel, Value: float64(value), Function: nil}
|
||||
}
|
||||
|
||||
// Em creates SizeUnit with SizeInEM type
|
||||
func Em(value float64) SizeUnit {
|
||||
return SizeUnit{SizeInEM, value, nil}
|
||||
func Em[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
|
||||
return SizeUnit{Type: SizeInEM, Value: float64(value), Function: nil}
|
||||
}
|
||||
|
||||
// Ex creates SizeUnit with SizeInEX type
|
||||
func Ex(value float64) SizeUnit {
|
||||
return SizeUnit{SizeInEX, value, nil}
|
||||
func Ex[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
|
||||
return SizeUnit{Type: SizeInEX, Value: float64(value), Function: nil}
|
||||
}
|
||||
|
||||
// Percent creates SizeUnit with SizeInDIP type
|
||||
func Percent(value float64) SizeUnit {
|
||||
return SizeUnit{SizeInPercent, value, nil}
|
||||
func Percent[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
|
||||
return SizeUnit{Type: SizeInPercent, Value: float64(value), Function: nil}
|
||||
}
|
||||
|
||||
// Pt creates SizeUnit with SizeInPt type
|
||||
func Pt(value float64) SizeUnit {
|
||||
return SizeUnit{SizeInPt, value, nil}
|
||||
func Pt[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
|
||||
return SizeUnit{Type: SizeInPt, Value: float64(value), Function: nil}
|
||||
}
|
||||
|
||||
// Pc creates SizeUnit with SizeInPc type
|
||||
func Pc(value float64) SizeUnit {
|
||||
return SizeUnit{SizeInPc, value, nil}
|
||||
func Pc[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
|
||||
return SizeUnit{Type: SizeInPc, Value: float64(value), Function: nil}
|
||||
}
|
||||
|
||||
// Mm creates SizeUnit with SizeInMM type
|
||||
func Mm(value float64) SizeUnit {
|
||||
return SizeUnit{SizeInMM, value, nil}
|
||||
func Mm[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
|
||||
return SizeUnit{Type: SizeInMM, Value: float64(value), Function: nil}
|
||||
}
|
||||
|
||||
// Cm creates SizeUnit with SizeInCM type
|
||||
func Cm(value float64) SizeUnit {
|
||||
return SizeUnit{SizeInCM, value, nil}
|
||||
func Cm[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
|
||||
return SizeUnit{Type: SizeInCM, Value: float64(value), Function: nil}
|
||||
}
|
||||
|
||||
// Inch creates SizeUnit with SizeInInch type
|
||||
func Inch(value float64) SizeUnit {
|
||||
return SizeUnit{SizeInInch, value, nil}
|
||||
func Inch[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
|
||||
return SizeUnit{Type: SizeInInch, Value: float64(value), Function: nil}
|
||||
}
|
||||
|
||||
// Fr creates SizeUnit with SizeInFraction type
|
||||
func Fr(value float64) SizeUnit {
|
||||
return SizeUnit{SizeInFraction, value, nil}
|
||||
func Fr[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
|
||||
return SizeUnit{SizeInFraction, float64(value), nil}
|
||||
}
|
||||
|
||||
// Equal compare two SizeUnit. Return true if SizeUnit are equal
|
||||
|
|
Loading…
Reference in New Issue