projects/wms-framework/src/lib/models/controls/CornerRadiusModel.ts
Represents the corner radius structure properties.
Properties |
|
Methods |
constructor(p1?: number, p2?: number, p3?: number, p4?: number)
|
Public BottomLeft |
Type : number
|
Default value : 0
|
Public BottomRight |
Type : number
|
Default value : 0
|
Public TopLeft |
Type : number
|
Default value : 0
|
Public TopRight |
Type : number
|
Default value : 0
|
Static parse | ||||||||
parse(input: string)
|
||||||||
Returns a CornerRadius from a string, or null if the string format is incorrect.
Parameters :
Returns :
CornerRadiusModel
|
toString |
toString()
|
Returns a string representation of the CornerRadius.
Returns :
string
{string} |
export class CornerRadiusModel {
public BottomLeft: number = 0;
public TopLeft: number = 0;
public TopRight: number = 0;
public BottomRight: number = 0;
/**
* Returns a CornerRadius from a string, or null if the string format is incorrect.
*
* @static
* @param {string} input A string with format "TopLeft, TopRight, BottomRight, BottomLeft" or "uniformRadius".
* @memberof CornerRadiusModel
*/
static parse(input: string): CornerRadiusModel {
let result: CornerRadiusModel = null;
const parts = input?.split(',');
if (parts?.length === 1) {
result = new CornerRadiusModel(parseFloat(parts[0]));
} else if (parts?.length >= 4) {
const margins = parts.map((v) => parseFloat(v));
result = new CornerRadiusModel(
margins[0],
margins[1],
margins[2],
margins[3]
);
}
return result;
}
constructor(p1?: number, p2?: number, p3?: number, p4?: number) {
if (
typeof p1 === 'number' &&
typeof p2 === 'number' &&
typeof p3 === 'number' &&
typeof p4 === 'number'
) {
this.TopLeft = p1;
this.TopRight = p2;
this.BottomRight = p3;
this.BottomLeft = p4;
} else if (typeof p1 === 'number') {
this.TopLeft = p1;
this.TopRight = p1;
this.BottomRight = p1;
this.BottomLeft = p1;
} else {
this.TopLeft = 0;
this.TopRight = 0;
this.BottomRight = 0;
this.BottomLeft = 0;
}
}
/**
* Returns a string representation of the CornerRadius.
*
* @return {*} {string}
* @memberof CornerRadiusModel
* @wMethod ToString
*/
toString(): string {
let str: string = null;
if (
this.TopLeft === this.TopRight &&
this.TopLeft === this.BottomLeft &&
this.TopLeft === this.BottomRight
) {
str = `${this.TopLeft}`;
} else {
str = `${this.TopLeft},${this.TopRight},${this.BottomRight},${this.BottomLeft}`;
}
return str;
}
}