如果发现别人的函数库缺少了某个功能,希望自己添加,那么可以这么做:
在src/lib目录下新建一个RecUtils.ts文件
内容如下:
import {
Rectangle} from "pixi.js";
declare module "pixi.js"{
class Rectangle{
containsRect(other: Rectangle): boolean;
}
}
Rectangle.prototype.containsRect = function(other: Rectangle){
return (
other.x >= this.x && other.y >= this.y && other.right <= this