element-web-synapse01pim.gr.jp

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

9544.js.map (5762B)


      1 {"version":3,"file":"bundles/12c8185ea2689492c07b/9544.js","mappings":"g3BA6BO,MAAMA,EAAuC,CAChDC,SAAU,GACVC,QAAS,MAME,MAAMC,EAGVC,WAAAA,CAAYC,IAAwCC,EAAAA,EAAAA,GAAAC,KAAA,mBAAAD,EAAAA,EAAAA,GAAAC,KAAA,UAIR,OAAID,EAAAA,EAAAA,GAAAC,KAAA,YACnB,KAAED,EAAAA,EAAAA,GAAAC,KAAA,oBACV,IAACD,EAAAA,EAAAA,GAAAC,KAAA,aAEV,IAAKD,EAAAA,EAAAA,GAAAC,KAAA,QAETC,MAAOC,EAA2BC,EAAU,OACvD,IAAKD,EACD,OAEJF,KAAKI,QAAUF,EAAOG,WAAW,MACjCL,KAAKM,UAAY,GACjB,MAAMC,EAAQP,KAAKF,QAAQJ,SAC3B,KAAOM,KAAKM,UAAUE,OAASD,GAC3BP,KAAKM,UAAUG,KAAKT,KAAKU,cAAc,CAAC,EAAcR,EAAOS,MAAOT,EAAOU,SAE/EZ,KAAKa,WAAY,EACjBC,sBAAsBd,KAAKe,YACvBZ,GACAa,OAAOC,WAAWjB,KAAKkB,KAAMf,MAEpCJ,EAAAA,EAAAA,GAAAC,KAAA,OAEaC,UACVD,KAAKa,WAAY,KACpBd,EAAAA,EAAAA,GAAAC,KAAA,gBAEuB,CAACmB,EAAmBR,EAAeC,KACvDO,EAASC,EAAIC,KAAKC,SAAWX,EAC7BQ,EAASI,EAAIF,KAAKC,UAAYV,EAC9BO,EAASK,KAAOL,EAASC,EACzBD,EAASxB,QAAUK,KAAKF,QAAQH,QAA0B,EAAhB0B,KAAKC,SAAe,EACvDH,KACVpB,EAAAA,EAAAA,GAAAC,KAAA,aAEoB,KACjB,GAAKA,KAAKI,SAAYJ,KAAKI,QAAQF,OAGnC,GAA8B,IAA1BF,KAAKM,UAAUE,OACfR,KAAKI,QAAQqB,UAAU,EAAG,EAAGzB,KAAKI,QAAQF,OAAOS,MAAOX,KAAKI,QAAQF,OAAOU,YACzE,EACec,KAAKC,MAAQ3B,KAAK4B,mBApDrB,KAqDyB5B,KAAK4B,qBAEzC5B,KAAKI,QAAQqB,UAAU,EAAG,EAAGzB,KAAKI,QAAQF,OAAOS,MAAOX,KAAKI,QAAQF,OAAOU,QAE5EZ,KAAK4B,kBAAoBF,KAAKC,MAC9B3B,KAAK6B,4BAETf,sBAAsBd,KAAKe,WAC/B,IAtDAf,KAAKF,QAAOgC,EAAAA,EAAA,GAAQrC,GAAmBK,EAC3C,CAwDQ+B,wBAAAA,GACJ,GAAK7B,KAAKI,SAAYJ,KAAKI,QAAQF,OAAnC,CAGAF,KAAKI,QAAQ2B,KAAO,eACpB,IAAK,MAAMZ,KAAYa,EAAAA,EAAAA,IAAehC,KAAKM,WACvCa,EAASI,GAAKJ,EAASxB,QAEvBK,KAAKI,QAAQ6B,OACbjC,KAAKI,QAAQ8B,SAxEX,KAwE2Bf,EAASC,EAAGD,EAASI,GAClDvB,KAAKI,QAAQ+B,SAPjB,CASJ","sources":["webpack://element-web/./src/effects/spaceinvaders/index.ts"],"sourcesContent":["/*\nCopyright 2024 New Vector Ltd.\nCopyright 2021-2023 The Matrix.org Foundation C.I.C.\n\nSPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial\nPlease see LICENSE files in the repository root for full details.\n*/\n\nimport type ICanvasEffect from \"../ICanvasEffect\";\nimport { arrayFastClone } from \"../../utils/arrays\";\n\ntype SpaceInvadersOptions = {\n    /**\n     * The maximum number of invaders to render at a given time\n     */\n    maxCount: number;\n    /**\n     * The amount of gravity to apply to the invaders\n     */\n    gravity: number;\n};\n\ntype Invader = {\n    x: number;\n    y: number;\n    xCol: number;\n    gravity: number;\n};\n\nexport const DefaultOptions: SpaceInvadersOptions = {\n    maxCount: 50,\n    gravity: 0.005,\n};\n\nconst KEY_FRAME_INTERVAL = 15; // 15ms, roughly\nconst GLYPH = \"👾\";\n\nexport default class SpaceInvaders implements ICanvasEffect {\n    private readonly options: SpaceInvadersOptions;\n\n    public constructor(options: Partial<SpaceInvadersOptions>) {\n        this.options = { ...DefaultOptions, ...options };\n    }\n\n    private context: CanvasRenderingContext2D | null = null;\n    private particles: Array<Invader> = [];\n    private lastAnimationTime = 0;\n\n    public isRunning = false;\n\n    public start = async (canvas: HTMLCanvasElement, timeout = 3000): Promise<void> => {\n        if (!canvas) {\n            return;\n        }\n        this.context = canvas.getContext(\"2d\");\n        this.particles = [];\n        const count = this.options.maxCount;\n        while (this.particles.length < count) {\n            this.particles.push(this.resetParticle({} as Invader, canvas.width, canvas.height));\n        }\n        this.isRunning = true;\n        requestAnimationFrame(this.renderLoop);\n        if (timeout) {\n            window.setTimeout(this.stop, timeout);\n        }\n    };\n\n    public stop = async (): Promise<void> => {\n        this.isRunning = false;\n    };\n\n    private resetParticle = (particle: Invader, width: number, height: number): Invader => {\n        particle.x = Math.random() * width;\n        particle.y = Math.random() * -height;\n        particle.xCol = particle.x;\n        particle.gravity = this.options.gravity + Math.random() * 6 + 4;\n        return particle;\n    };\n\n    private renderLoop = (): void => {\n        if (!this.context || !this.context.canvas) {\n            return;\n        }\n        if (this.particles.length === 0) {\n            this.context.clearRect(0, 0, this.context.canvas.width, this.context.canvas.height);\n        } else {\n            const timeDelta = Date.now() - this.lastAnimationTime;\n            if (timeDelta >= KEY_FRAME_INTERVAL || !this.lastAnimationTime) {\n                // Clear the screen first\n                this.context.clearRect(0, 0, this.context.canvas.width, this.context.canvas.height);\n\n                this.lastAnimationTime = Date.now();\n                this.animateAndRenderInvaders();\n            }\n            requestAnimationFrame(this.renderLoop);\n        }\n    };\n\n    private animateAndRenderInvaders(): void {\n        if (!this.context || !this.context.canvas) {\n            return;\n        }\n        this.context.font = \"50px Twemoji\";\n        for (const particle of arrayFastClone(this.particles)) {\n            particle.y += particle.gravity;\n\n            this.context.save();\n            this.context.fillText(GLYPH, particle.x, particle.y);\n            this.context.restore();\n        }\n    }\n}\n"],"names":["DefaultOptions","maxCount","gravity","SpaceInvaders","constructor","options","_defineProperty","this","async","canvas","timeout","context","getContext","particles","count","length","push","resetParticle","width","height","isRunning","requestAnimationFrame","renderLoop","window","setTimeout","stop","particle","x","Math","random","y","xCol","clearRect","Date","now","lastAnimationTime","animateAndRenderInvaders","_objectSpread","font","arrayFastClone","save","fillText","restore"],"sourceRoot":""}