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Q,GACrC,IAAI,EAAA,SAAS,EAAQ,EAAQ,EAAQ,GACrC,IAAI,EAAA,SAAS,EAAQ,EAAQ,EAAQ,KAIrC,EAAA,UAAA,aAAR,SAAqB,GACV,OAAC,IAAI,EAAA,SAAS,EAAO,EAAO,EAAO,KAElD,EA9FA,GAAa,QAAA,IAAA;;ACDb,aAAA,QAAA,YAAA,EAHA,IAAA,EAAA,QAAA,SAEM,EAAM,IAAI,EAAA","file":"generative.64750597.map","sourceRoot":"..","sourcesContent":["export const UNDEFINED = '#fff';\r\nexport const RED = '#a00';\r\nexport const GREEN = '#0a0';\r\nexport const BLUE = '#00a';\r\n\r\nexport const GRASS = '#ADF7B6';\r\nexport const FOREST = '#85E290';\r\nexport const SAND = '#FCF5C7';\r\nexport const DESERT = '#FFEE93  ';\r\nexport const WATER = '#A0CED9';\r\n","export class TilePosition {\r\n    constructor (public x: number, public y: number) { }\r\n}\r\n","export class TileType {\r\n    constructor (public north: string = null, public east: string = null, public south: string = null, public west: string = null) { }\r\n\r\n    public getColor(position: string) {\r\n        if (typeof this[position] !== 'string') { return null; }\r\n\r\n        return this[position];\r\n    }\r\n}\r\n","import * as colors from './colors';\r\nimport { TilePosition } from './TilePosition';\r\nimport { TileType } from './TileType';\r\n\r\nexport class Tile {\r\n    public type: TileType = null;\r\n    public position: TilePosition = null;\r\n\r\n    constructor (x: number, y: number, type: TileType = new TileType()) {\r\n        this.position = new TilePosition(x, y);\r\n        this.type = type;\r\n    }\r\n\r\n    public render (ctx: CanvasRenderingContext2D, size: number) {\r\n        const top = this.position.y * size;\r\n        const left = this.position.x * size;\r\n\r\n        // north\r\n        ctx.beginPath();\r\n        ctx.fillStyle = this.getColor('north');\r\n        ctx.moveTo(left, top);\r\n        ctx.lineTo(left + size, top);\r\n        ctx.lineTo(left + size / 2, top + size / 2);\r\n        ctx.closePath();\r\n        ctx.fill();\r\n\r\n        // east\r\n        ctx.beginPath();\r\n        ctx.fillStyle = this.getColor('east');\r\n        ctx.moveTo(left + size, top);\r\n        ctx.lineTo(left + size / 2, top + size / 2);\r\n        ctx.lineTo(left + size, top + size);\r\n        ctx.closePath();\r\n        ctx.fill();\r\n\r\n        // south\r\n        ctx.beginPath();\r\n        ctx.fillStyle = this.getColor('south');\r\n        ctx.moveTo(left, top + size);\r\n        ctx.lineTo(left + size, top + size);\r\n        ctx.lineTo(left + size / 2, top + size / 2);\r\n        ctx.closePath();\r\n        ctx.fill();\r\n\r\n        // west\r\n        ctx.beginPath();\r\n        ctx.fillStyle = this.getColor('west');\r\n        ctx.moveTo(left, top);\r\n        ctx.lineTo(left + size / 2, top + size / 2);\r\n        ctx.lineTo(left, top + size);\r\n        ctx.closePath();\r\n        ctx.fill();\r\n\r\n        // ctx.beginPath();\r\n        // ctx.strokeStyle = '#000';\r\n        // ctx.strokeRect(left + 0.5, top + 0.5, size - 1, size - 1);\r\n    }\r\n\r\n    private getColor(position: string) {\r\n        const missingCollor = colors.UNDEFINED;\r\n\r\n        if (!this.type) { return missingCollor; }\r\n        return this.type.getColor(position) || missingCollor;\r\n    }\r\n}\r\n","import * as colors from './colors';\r\nimport { Tile } from './Tile';\r\nimport { TileType } from './TileType';\r\n\r\nexport class App {\r\n    private canvas: HTMLCanvasElement;\r\n    private ctx: CanvasRenderingContext2D;\r\n\r\n    private tileSize: number = 20;\r\n    private tiles: Tile[] = [];\r\n    private types: TileType[] = [];\r\n\r\n    constructor() {\r\n        console.clear();\r\n        this.canvas = document.getElementById('image') as HTMLCanvasElement;\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.run();\r\n    }\r\n\r\n    public run(): void {\r\n        this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);\r\n\r\n        for (let i = 0; i < 2; i++) { this.types = this.types.concat(this.get0to4Types(colors.WATER)); }\r\n        for (let i = 0; i < 100; i++) { this.types = this.types.concat(this.get0to4Types(colors.GRASS)); }\r\n\r\n        this.types = this.types.concat(this.get1to3Types(colors.WATER, colors.GRASS));\r\n\r\n        this.types = this.types.concat(this.get1to3Types(colors.WATER, colors.SAND));\r\n        this.types = this.types.concat(this.get2to2Types(colors.WATER, colors.SAND));\r\n\r\n        this.types = this.types.concat(this.get1to3Types(colors.GRASS, colors.SAND));\r\n        this.types = this.types.concat(this.get2to2Types(colors.GRASS, colors.SAND));\r\n\r\n        const xMax = Math.ceil(this.canvas.width / this.tileSize);\r\n        const yMax = Math.ceil(this.canvas.height / this.tileSize);\r\n\r\n        for (let y = 0; y < yMax; y ++) {\r\n            for (let x = 0; x < xMax; x ++) {\r\n                const west = x > 0 ? this.tiles.length - 1 : -1;\r\n                const north = this.tiles.length - xMax;\r\n\r\n                const type = y === 0 && x === 0 ? this.types[Math.floor(Math.random() * this.types.length)] : this.getType(this.tiles[west], this.tiles[north]);\r\n                const tile = new Tile(x, y, type);\r\n\r\n                this.tiles.push(tile);\r\n\r\n            }\r\n        }\r\n\r\n        this.render();\r\n    }\r\n\r\n    private render (): void {\r\n        for (const tile of this.tiles) {\r\n            tile.render(this.ctx, this.tileSize);\r\n        }\r\n    }\r\n\r\n    private getType(westTile: Tile, northTile: Tile): TileType {\r\n        const west = westTile && westTile.type ? westTile.type.east : null;\r\n        const north = northTile && northTile.type ? northTile.type.south : null;\r\n\r\n        const tiles = this.types.filter((x) => (x.west === west || !west) && (x.north === north || !north));\r\n\r\n        return tiles[Math.floor(Math.random() * tiles.length)];\r\n    }\r\n\r\n    private get1to3Types(color1: string, color2: string): TileType[] {\r\n        return [\r\n            new TileType(color1, color2, color2, color2),\r\n            new TileType(color2, color1, color2, color2),\r\n            new TileType(color2, color2, color1, color2),\r\n            new TileType(color2, color2, color2, color1),\r\n            new TileType(color2, color1, color1, color1),\r\n            new TileType(color1, color2, color1, color1),\r\n            new TileType(color1, color1, color2, color1),\r\n            new TileType(color1, color1, color1, color2)\r\n        ];\r\n    }\r\n\r\n    private get2to2Types(color1: string, color2: string): TileType[] {\r\n        return [\r\n            new TileType(color2, color2, color1, color1),\r\n            new TileType(color1, color2, color2, color1),\r\n            new TileType(color1, color1, color2, color2),\r\n            new TileType(color2, color1, color1, color2),\r\n            new TileType(color2, color1, color2, color1),\r\n            new TileType(color1, color2, color1, color2)\r\n        ];\r\n    }\r\n\r\n    private get0to4Types(color: string): TileType[] {\r\n        return [new TileType(color, color, color, color)];\r\n    }\r\n}\r\n","import { App } from './App';\r\n\r\nconst app = new App();\r\n// app.run();\r\n"]}