element-web-synapse01pim.gr.jp

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

2792.js.map (7918B)


      1 {"version":3,"file":"bundles/9cacd6575f4c8ee1aedb/2792.js","mappings":"8zBAkCO,MAAMA,EAAkC,CAC3CC,SAAU,IACVC,QAAS,IACTC,SAAU,GAKC,MAAMC,EAGVC,WAAAA,CAAYC,IAAiCC,EAAAA,EAAAA,GAAA,wBAAAA,EAAAA,EAAAA,GAAA,eAID,OAAIA,EAAAA,EAAAA,GAAA,iBACjB,KAAEA,EAAAA,EAAAA,GAAA,yBACZ,IAACA,EAAAA,EAAAA,GAAA,kBAEV,IAAKA,EAAAA,EAAAA,GAAA,aAETC,MAAOC,EAA2BC,EAAU,OACvD,IAAKD,EACD,OAEJE,KAAKC,QAAUH,EAAOI,WAAW,MACjCF,KAAKG,UAAY,GACjB,MAAMC,EAAQJ,KAAKL,QAAQL,SAC3B,KAAOU,KAAKG,UAAUE,OAASD,GAC3BJ,KAAKG,UAAUG,KAAKN,KAAKO,cAAc,CAAC,EAAgBT,EAAOU,MAAOV,EAAOW,SAEjFT,KAAKU,WAAY,EACjBC,sBAAsBX,KAAKY,YACvBb,GACAc,OAAOC,WAAWd,KAAKe,KAAMhB,MAEpCH,EAAAA,EAAAA,GAAA,YAEaC,UACVG,KAAKU,WAAY,KACpBd,EAAAA,EAAAA,GAAA,qBAEuB,CAACoB,EAAqBR,EAAeC,KACzDO,EAASC,EAAIC,KAAKC,SAAWX,EAC7BQ,EAASI,EAAIF,KAAKC,UAAYV,EAC9BO,EAASK,KAAOL,EAASC,EACzBD,EAASM,SAA2B,EAAhBJ,KAAKC,SAAe,EACxCH,EAASO,aAAeL,KAAKC,SAAWnB,KAAKL,QAAQH,SAAW,IAChEwB,EAASzB,QAAUS,KAAKL,QAAQJ,QAA0B,EAAhB2B,KAAKC,SAAe,EACvDH,KACVpB,EAAAA,EAAAA,GAAA,kBAEoB,KACjB,GAAKI,KAAKC,SAAYD,KAAKC,QAAQH,OAG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J,E","sources":["webpack://element-web/./src/effects/snowfall/index.ts"],"sourcesContent":["/*\nCopyright 2024 New Vector Ltd.\nCopyright 2020-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 */\nimport type ICanvasEffect from \"../ICanvasEffect\";\nimport { arrayFastClone } from \"../../utils/arrays\";\n\nexport type SnowfallOptions = {\n    /**\n     * The maximum number of snowflakes to render at a given time\n     */\n    maxCount: number;\n    /**\n     * The amount of gravity to apply to the snowflakes\n     */\n    gravity: number;\n    /**\n     * The amount of drift (horizontal sway) to apply to the snowflakes. Each snowflake varies.\n     */\n    maxDrift: number;\n};\n\ntype Snowflake = {\n    x: number;\n    y: number;\n    xCol: number;\n    diameter: number;\n    maximumDrift: number;\n    gravity: number;\n};\n\nexport const DefaultOptions: SnowfallOptions = {\n    maxCount: 200,\n    gravity: 0.05,\n    maxDrift: 5,\n};\n\nconst KEY_FRAME_INTERVAL = 15; // 15ms, roughly\n\nexport default class Snowfall implements ICanvasEffect {\n    private readonly options: SnowfallOptions;\n\n    public constructor(options: { [key: string]: any }) {\n        this.options = { ...DefaultOptions, ...options };\n    }\n\n    private context: CanvasRenderingContext2D | null = null;\n    private particles: Array<Snowflake> = [];\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 Snowflake, 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: Snowflake, width: number, height: number): Snowflake => {\n        particle.x = Math.random() * width;\n        particle.y = Math.random() * -height;\n        particle.xCol = particle.x;\n        particle.diameter = Math.random() * 7 + 4;\n        particle.maximumDrift = Math.random() * this.options.maxDrift + 3.5;\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.animateAndRenderSnowflakes();\n            }\n            requestAnimationFrame(this.renderLoop);\n        }\n    };\n\n    private animateAndRenderSnowflakes(): void {\n        if (!this.context || !this.context.canvas) {\n            return;\n        }\n        const height = this.context.canvas.height;\n        for (const particle of arrayFastClone(this.particles)) {\n            particle.y += particle.gravity;\n\n            // We treat the drift as a sine function to have a more fluid-like movement instead\n            // of a pong-like movement off walls of the X column. This means that for\n            // $x=A\\sin(\\frac{2\\pi}{P}y)$ we use the `maximumDrift` as the amplitude (A) and a\n            // large multiplier to create a very long waveform through P.\n            const peakDistance = 75 * particle.maximumDrift;\n            const PI2 = Math.PI * 2;\n            particle.x = particle.maximumDrift * Math.sin((PI2 / peakDistance) * particle.y);\n            particle.x += particle.xCol; // bring the particle to the right place\n\n            const radius = particle.diameter / 2;\n            this.context.save();\n            this.context.beginPath();\n            this.context.ellipse(particle.x, particle.y, radius, radius, 0, 0, 360);\n            this.context.fillStyle = \"#eaeaea\"; // grey so it shows up on the light theme\n            this.context.fill();\n            this.context.closePath();\n            this.context.restore();\n\n            // Remove any dead snowflakes\n            const maxBounds = radius * 4; // make sure it's *really* off screen\n            if (particle.y > height + maxBounds) {\n                const idx = this.particles.indexOf(particle);\n                this.particles.splice(idx, 1);\n            }\n        }\n    }\n}\n"],"names":["DefaultOptions","maxCount","gravity","maxDrift","Snowfall","constructor","options","_defineProperty","async","canvas","timeout","this","context","getContext","particles","count","length","push","resetParticle","width","height","isRunning","requestAnimationFrame","renderLoop","window","setTimeout","stop","particle","x","Math","random","y","xCol","diameter","maximumDrift","clearRect","Date","now","lastAnimationTime","animateAndRenderSnowflakes","_objectSpread","arrayFastClone","peakDistance","PI2","PI","sin","radius","save","beginPath","ellipse","fillStyle","fill","closePath","restore","maxBounds","idx","indexOf","splice"],"sourceRoot":""}