@osbjs/osbjs
Version:
a minimalist osu! storyboarding framework
33 lines (32 loc) • 1.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Texture = void 0;
const image_size_1 = require("image-size");
const Core_1 = require("../Core");
class Texture {
constructor(text, path, osbPath, color, offset) {
this.text = text;
this.path = path;
this.osbPath = osbPath;
this.width = this._getWidth();
this.height = this._getHeight();
this.offset = offset;
this.color = color;
}
_getWidth() {
return (0, image_size_1.imageSize)(this.path).width ?? 0;
}
_getHeight() {
return (0, image_size_1.imageSize)(this.path).height ?? 0;
}
/**
* Returns a `Sprite` instance of this texture.
* @param layer Layer to place the sprite on.
* @param origin Origin of the sprite.
* @param initialPosition Initial position of the sprite.
*/
toSprite(layer = Core_1.Layer.Background, origin = Core_1.Origin.Center, initialPosition = new Core_1.OsbVector2(320, 240)) {
return new Core_1.Sprite(this.osbPath, layer, origin, initialPosition);
}
}
exports.Texture = Texture;