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AAO,IAAI,CAAX;AACH,KAVO;AAYA,QAAA,SAAA,CAAA,cAAA,GAAR,UAAwB,CAAxB,EAAmC,CAAnC,EAA4C;AACxC,YAAM,WAAW,KAAK,QAAL,CAAc,KAAK,QAAL,CAAc,MAAd,GAAuB,CAArC,CAAjB;AACA,YAAM,WAAW,KAAK,IAAL,CAAU,KAAK,GAAL,CAAS,IAAI,SAAS,CAAtB,EAAyB,CAAzB,IAA8B,KAAK,GAAL,CAAS,IAAI,SAAS,CAAtB,EAAyB,CAAzB,CAAxC,CAAjB;AACA,YAAM,IAAI,SAAS,cAAT,CAAwB,QAAxB,CAAV;AAEA,YAAM,MAAgC,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,CAAtC;AACA,YAAI,CAAJ,KAAU,KAAK,KAAL,CAAW,IAAI,CAAC,GAAhB,CAAV;AACA,YAAI,CAAJ,KAAU,KAAK,KAAL,CAAW,IAAI,CAAC,EAAhB,CAAV;AACA,YAAI,CAAJ,KAAU,KAAK,KAAL,CAAW,IAAI,CAAC,EAAhB,CAAV;AAEA,eAAO,IAAI,IAAJ,CAAS,GAAT,CAAP;AACH,KAXO;AAYZ,WAAA,GAAA;AAjHA,CAAA,EAAA;AAAa,QAAA,GAAA,GAAA,GAAA","file":"generative.af77ce68.map","sourceRoot":"..","sourcesContent":["export class Point {\r\n    public x: number;\r\n    public y: number;\r\n\r\n    public ax: number;\r\n    public ay: number;\r\n\r\n    constructor (private w: number, private h: number) {\r\n        this.x = Math.random() * w;\r\n        this.y = Math.random() * h;\r\n\r\n        this.ax = 1 - Math.random() * 2;\r\n        this.ay = 0.5 - Math.random() * 1;\r\n    }\r\n\r\n    public update () {\r\n        this.x += this.ax;\r\n        this.y += this.ay;\r\n\r\n        if (this.x > this.w) { this.x -= this.w; }\r\n        if (this.x < 0) { this.x += this.w; }\r\n        if (this.y > this.h) { this.y -= this.h; }\r\n        if (this.y < 0) { this.y += this.h; }\r\n    }\r\n}\r\n","import { Point } from './Point';\r\n\r\ndeclare global {\r\n    // tslint:disable-next-line:interface-name\r\n    interface Window { raf: number; }\r\n}\r\n\r\nconst PI2 = Math.PI * 2;\r\n\r\nexport class App {\r\n    private canvas: HTMLCanvasElement;\r\n    private ctx: CanvasRenderingContext2D;\r\n\r\n    private emitters = [];\r\n    private filledPoints: Point[] = [];\r\n    private strokedPoints: Point[] = [];\r\n\r\n    constructor() {\r\n        window.cancelAnimationFrame(window.raf);\r\n        console.clear();\r\n\r\n        this.canvas = document.getElementById('image') as HTMLCanvasElement;\r\n        this.ctx = this.canvas.getContext('2d', { alpha: false });\r\n        // this.ctx = this.canvas.getContext('2d');\r\n\r\n        this.canvas.width = window.innerWidth;\r\n        this.canvas.height = window.innerHeight;\r\n\r\n        this.emitters = [\r\n            {\r\n                getCoefficient: (distance: number) => 0 + (Math.sin(0.02 * distance) + 1) / 2,\r\n                x: this.canvas.width - 200,\r\n                y: 200\r\n            },\r\n            {\r\n                getCoefficient: (distance: number) => 0 + (Math.sin(0.02 * distance) + 1) / 2,\r\n                x: 200,\r\n                y: 200\r\n            },\r\n            {\r\n                getCoefficient: (distance: number) => 0 + (Math.sin(0.02 * distance) + 1) / 2,\r\n                x: this.canvas.width / 2,\r\n                y: this.canvas.height - 200\r\n            }\r\n        ];\r\n\r\n        const w = this.canvas.width;\r\n        const h = this.canvas.height;\r\n        const n = w * h;\r\n\r\n        for (let i = 0; i < n / 500; i++) {\r\n            this.filledPoints.push(new Point(w, h));\r\n        }\r\n\r\n        for (let i = 0; i < n / 5000; i++) {\r\n            this.strokedPoints.push(new Point(w, h));\r\n        }\r\n        console.log('points:', this.strokedPoints.length + this.filledPoints.length);\r\n\r\n        this.run();\r\n    }\r\n\r\n    public run(): void {\r\n        this.ctx.fillStyle = '#fff';\r\n        this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);\r\n\r\n        for (const point of this.filledPoints) {\r\n            this.renderCircle(point, true, false);\r\n            point.update();\r\n        }\r\n\r\n        for (const point of this.strokedPoints) {\r\n            this.renderCircle(point, false, true);\r\n            point.update();\r\n        }\r\n\r\n        window.raf = window.requestAnimationFrame(() => this.run());\r\n    }\r\n\r\n    private renderCircle(point, fill, stroke): void {\r\n        const c = this.getCoefficient(point.x, point.y);\r\n        const colorValues = this.getColorValues(point.x, point.y);\r\n\r\n        this.ctx.beginPath();\r\n        this.ctx.arc(point.x, point.y, c * 20, 0, PI2, false);\r\n\r\n        if (fill) {\r\n            this.ctx.fillStyle = `rgba(${colorValues},0.5)`;\r\n            this.ctx.fill();\r\n        }\r\n\r\n        if (stroke) {\r\n            this.ctx.strokeStyle = `rgba(0,0,0,${0.1 + c * 0.3})`;\r\n            this.ctx.lineWidth = 1 + c * 3;\r\n            this.ctx.stroke();\r\n        }\r\n    }\r\n\r\n    private getCoefficient (x: number, y: number): number {\r\n        let c = 0;\r\n        let n = 0;\r\n\r\n        for (const emmitter of this.emitters) {\r\n            c += emmitter.getCoefficient(Math.sqrt(Math.pow(x - emmitter.x, 2) + Math.pow(y - emmitter.y, 2)));\r\n            n++;\r\n        }\r\n\r\n        return c / n;\r\n    }\r\n\r\n    private getColorValues (x: number, y: number): string {\r\n        const emmitter = this.emitters[this.emitters.length - 1];\r\n        const distance = Math.sqrt(Math.pow(x - emmitter.x, 2) + Math.pow(y - emmitter.y, 2));\r\n        const c = emmitter.getCoefficient(distance);\r\n\r\n        const rgb: [number, number, number] = [102, 232, 255];\r\n        rgb[0] += Math.round(c * -102);\r\n        rgb[1] += Math.round(c * -72);\r\n        rgb[2] += Math.round(c * -29);\r\n\r\n        return rgb.join(',');\r\n    }\r\n}\r\n","import { App } from './App';\r\n\r\nconst app = new App();\r\n"]}