parent
46e719f851
commit
229018ec9f
5 changed files with 274 additions and 268 deletions
modules/ags/config/lib
47
modules/ags/config/lib/cairo.ts
Normal file
47
modules/ags/config/lib/cairo.ts
Normal file
|
@ -0,0 +1,47 @@
|
|||
type PointProps = [number, number] | {
|
||||
x: number
|
||||
y: number
|
||||
} | number;
|
||||
|
||||
export class Point {
|
||||
public x = 0;
|
||||
public y = 0;
|
||||
|
||||
get values(): [number, number] {
|
||||
return [this.x, this.y];
|
||||
}
|
||||
|
||||
constructor(props?: PointProps, y?: number) {
|
||||
if (typeof props === 'number') {
|
||||
if (y) {
|
||||
this.x = props;
|
||||
this.y = y;
|
||||
}
|
||||
else {
|
||||
throw new Error('Wrong props');
|
||||
}
|
||||
}
|
||||
else if (Array.isArray(props)) {
|
||||
this.x = props[0];
|
||||
this.y = props[1];
|
||||
}
|
||||
else if (props) {
|
||||
this.x = props.x;
|
||||
this.y = props.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export type BezierPoints = [number, number, number, number];
|
||||
|
||||
export class Bezier {
|
||||
private _points: BezierPoints;
|
||||
|
||||
get points() {
|
||||
return [...this._points] as BezierPoints;
|
||||
}
|
||||
|
||||
constructor(x1: number, y1: number, x2: number, y2: number) {
|
||||
this._points = [x1, y1, x2, y2];
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue