Extending Rectangle
nishirken opened this issue · comments
SkurihinDmitriy commented
Hello, some functionality can be added to the Rectangle class:
/**
Restricts the rectangle within another larger rectangle.
{x: -50, y: -50, w: 100, y: 100} restrictWithin {x: 0: y: 0, w: 500, h: 500} -> {x: 0, y: 0, w: 100, y: 100}
*/
restrictWithin(rect: Rectangle): Rectangle;
This also can be added to Circle and Ellipse classes. The method can be overloaded:
restrictWithin(rect: Rectangle): Rectangle;
restrictWithin(rect: Circle): Rectangle;
restrictWithin(rect: Ellipse): Rectangle;