Skip to content

Commit 19a03e9

Browse files
committed
Add static drawBorder method to OSRSCanvas
1 parent 4b3cb7d commit 19a03e9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/lib/canvas/OSRSCanvas.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,13 @@ export class OSRSCanvas {
237237
this.ctx.restore();
238238
}
239239

240-
drawBorder(_sprite?: IBgSprite, titleLine = true) {
241-
const sprite = _sprite ?? this.sprite;
240+
drawBorder(_sprite: IBgSprite, titleLine = true) {
241+
if (!this.sprite) throw new Error('No sprite provided for drawing border');
242+
OSRSCanvas.drawBorder(this.ctx, _sprite ?? this.sprite, titleLine);
243+
}
244+
245+
static drawBorder(ctx: CanvasContext, sprite: IBgSprite, titleLine = true) {
242246
if (!sprite) throw new Error('No sprite provided for drawing border');
243-
const ctx = this.ctx;
244247
// Top border
245248
ctx.save();
246249
ctx.fillStyle = ctx.createPattern(sprite.border, 'repeat-x')!;

0 commit comments

Comments
 (0)