import { Graphics } from '@pixi/graphics'; import { Grid } from ".."; import IMaskingMethod from './IMaskingMethod'; export class SimplifiedMask implements IMaskingMethod { private _mask: Graphics; createMask(staticGrid: Grid): Graphics { this._mask = new Graphics(); this._mask.beginFill(0x000000); const bounds = staticGrid.getBounds(); this._mask.drawRect(bounds.x, bounds.y, bounds.width, bounds.height); return this._mask; } getMask(): Graphics { return this._mask; } } export class UnifiedMask implements IMaskingMethod { private _mask: Graphics; createMask(staticGrid: Grid): Graphics { this._mask = new Graphics(); this._mask.beginFill(0x000000); const reelCount = staticGrid.reels.length; // Start at the top left corner (of the first reel) let x = staticGrid.reels[ 0 ].getBounds().left; let y = staticGrid.reels[ 0 ].getBounds().top; this._mask.moveTo(x, y); // Draw top line for (let i = 0; i < reelCount - 1; i++) { const currentReel = staticGrid.reels[ i ]; const nextReel = staticGrid.reels[ i + 1 ]; x = (currentReel.getBounds().right + nextReel.getBounds().left) / 2; this._mask.lineTo(x, y); y = nextReel.getBounds().top; this._mask.lineTo(x, y); } // Finish top line and move to bottom left corner y = staticGrid.reels[ reelCount - 1 ].getBounds().top; this._mask.lineTo(x, y); x = staticGrid.reels[ reelCount - 1 ].getBounds().right; this._mask.lineTo(x, y); y = staticGrid.reels[ reelCount - 1 ].getBounds().bottom; this._mask.lineTo(x, y); // Draw bottom line for (let i = reelCount - 1; i > 0; i--) { const currentReel = staticGrid.reels[ i ]; const nextReel = staticGrid.reels[ i - 1 ]; x = (currentReel.getBounds().right + nextReel.getBounds().left) / 2; this._mask.lineTo(x, y); y = nextReel.getBounds().bottom; this._mask.lineTo(x, y); } // Finish bottom line and close path y = staticGrid.reels[ 0 ].getBounds().bottom; this._mask.lineTo(x, y); x = staticGrid.reels[ 0 ].getBounds().left; this._mask.lineTo(x, y); this._mask.closePath(); return this._mask; } getMask(): Graphics { return this._mask; } } export class UniqueMask implements IMaskingMethod { private _mask: Graphics; createMask(staticGrid: Grid): Graphics { this._mask = new Graphics(); this._mask.beginFill(0x000000); const reelCount = staticGrid.reels.length; for (let i = 0; i < reelCount; i++) { const currentReel = staticGrid.reels[i]; const bounds = currentReel.getBounds(); this._mask.drawRect(bounds.x, bounds.y, bounds.width, bounds.height); } return this._mask; } getMask(): Graphics { return this._mask; } }