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
 | 
					// Deg creates AngleUnit with Degree type
 | 
				
			||||||
func Deg(value float64) AngleUnit {
 | 
					func Deg[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) AngleUnit {
 | 
				
			||||||
	return AngleUnit{Type: Degree, Value: value}
 | 
						return AngleUnit{Type: Degree, Value: float64(value)}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Rad create AngleUnit with Radian type
 | 
					// Rad create AngleUnit with Radian type
 | 
				
			||||||
func Rad(value float64) AngleUnit {
 | 
					func Rad[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) AngleUnit {
 | 
				
			||||||
	return AngleUnit{Type: Radian, Value: value}
 | 
						return AngleUnit{Type: Radian, Value: float64(value)}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// PiRad create AngleUnit with PiRadian type
 | 
					// PiRad create AngleUnit with PiRadian type
 | 
				
			||||||
func PiRad(value float64) AngleUnit {
 | 
					func PiRad[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) AngleUnit {
 | 
				
			||||||
	return AngleUnit{Type: PiRadian, Value: value}
 | 
						return AngleUnit{Type: PiRadian, Value: float64(value)}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Grad create AngleUnit with Gradian type
 | 
					// Grad create AngleUnit with Gradian type
 | 
				
			||||||
func Grad(value float64) AngleUnit {
 | 
					func Grad[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) AngleUnit {
 | 
				
			||||||
	return AngleUnit{Type: Gradian, Value: value}
 | 
						return AngleUnit{Type: Gradian, Value: float64(value)}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Equal compare two AngleUnit. Return true if AngleUnit are equal
 | 
					// 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
 | 
					// Px creates SizeUnit with SizeInPixel type
 | 
				
			||||||
func Px(value float64) SizeUnit {
 | 
					func Px[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
 | 
				
			||||||
	return SizeUnit{SizeInPixel, value, nil}
 | 
						return SizeUnit{Type: SizeInPixel, Value: float64(value), Function: nil}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Em creates SizeUnit with SizeInEM type
 | 
					// Em creates SizeUnit with SizeInEM type
 | 
				
			||||||
func Em(value float64) SizeUnit {
 | 
					func Em[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
 | 
				
			||||||
	return SizeUnit{SizeInEM, value, nil}
 | 
						return SizeUnit{Type: SizeInEM, Value: float64(value), Function: nil}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Ex creates SizeUnit with SizeInEX type
 | 
					// Ex creates SizeUnit with SizeInEX type
 | 
				
			||||||
func Ex(value float64) SizeUnit {
 | 
					func Ex[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
 | 
				
			||||||
	return SizeUnit{SizeInEX, value, nil}
 | 
						return SizeUnit{Type: SizeInEX, Value: float64(value), Function: nil}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Percent creates SizeUnit with SizeInDIP type
 | 
					// Percent creates SizeUnit with SizeInDIP type
 | 
				
			||||||
func Percent(value float64) SizeUnit {
 | 
					func Percent[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
 | 
				
			||||||
	return SizeUnit{SizeInPercent, value, nil}
 | 
						return SizeUnit{Type: SizeInPercent, Value: float64(value), Function: nil}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Pt creates SizeUnit with SizeInPt type
 | 
					// Pt creates SizeUnit with SizeInPt type
 | 
				
			||||||
func Pt(value float64) SizeUnit {
 | 
					func Pt[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
 | 
				
			||||||
	return SizeUnit{SizeInPt, value, nil}
 | 
						return SizeUnit{Type: SizeInPt, Value: float64(value), Function: nil}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Pc creates SizeUnit with SizeInPc type
 | 
					// Pc creates SizeUnit with SizeInPc type
 | 
				
			||||||
func Pc(value float64) SizeUnit {
 | 
					func Pc[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
 | 
				
			||||||
	return SizeUnit{SizeInPc, value, nil}
 | 
						return SizeUnit{Type: SizeInPc, Value: float64(value), Function: nil}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Mm creates SizeUnit with SizeInMM type
 | 
					// Mm creates SizeUnit with SizeInMM type
 | 
				
			||||||
func Mm(value float64) SizeUnit {
 | 
					func Mm[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
 | 
				
			||||||
	return SizeUnit{SizeInMM, value, nil}
 | 
						return SizeUnit{Type: SizeInMM, Value: float64(value), Function: nil}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Cm creates SizeUnit with SizeInCM type
 | 
					// Cm creates SizeUnit with SizeInCM type
 | 
				
			||||||
func Cm(value float64) SizeUnit {
 | 
					func Cm[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
 | 
				
			||||||
	return SizeUnit{SizeInCM, value, nil}
 | 
						return SizeUnit{Type: SizeInCM, Value: float64(value), Function: nil}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Inch creates SizeUnit with SizeInInch type
 | 
					// Inch creates SizeUnit with SizeInInch type
 | 
				
			||||||
func Inch(value float64) SizeUnit {
 | 
					func Inch[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
 | 
				
			||||||
	return SizeUnit{SizeInInch, value, nil}
 | 
						return SizeUnit{Type: SizeInInch, Value: float64(value), Function: nil}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Fr creates SizeUnit with SizeInFraction type
 | 
					// Fr creates SizeUnit with SizeInFraction type
 | 
				
			||||||
func Fr(value float64) SizeUnit {
 | 
					func Fr[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
 | 
				
			||||||
	return SizeUnit{SizeInFraction, value, nil}
 | 
						return SizeUnit{SizeInFraction, float64(value), nil}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Equal compare two SizeUnit. Return true if SizeUnit are equal
 | 
					// Equal compare two SizeUnit. Return true if SizeUnit are equal
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue