Разбери это:
<<<<<<< HEAD
class Example extends Phaser.Scene {
    constructor() {
        super();
    }

    create() {
        // Set the background color to black
        this.cameras.main.setBackgroundColor('#000000');
    }
}
=======
class Example extends Phaser.Scene {
    constructor() {
        super();
        this.fileInput = null;
        this.statsText = null;
        this.imageSprite = null;
        this.counts = { mountains: 0, land: 0, water: 0, total: 0 };
    }

    preload() {
        // Create file input element
        this.fileInput = document.createElement('input');
        this.fileInput.type = 'file';
        this.fileInput.accept = 'image/*';
        this.fileInput.style.position = 'absolute';
        this.fileInput.style.top = '10px';
        this.fileInput.style.left = '10px';
        this.fileInput.style.zIndex = '100';
        document.body.appendChild(this.fileInput);
        
        // Add event listener for file selection
        this.fileInput.addEventListener('change', (event) => {
            const file = event.target.files[0];
            if (file) {
                this.loadImage(file);
            }
        });
    }

    create() {
        // Set the background color to black
        this.cameras.main.setBackgroundColor('#000000');
        
        // Create text for displaying stats
        this.statsText = this.add.text(10, 60, 'Upload an image to analyze colors', {
            font: '16px Arial',
            fill: '#ffffff'
        });
        
        // Upload button prompt
        this.add.text(10, 30, 'Click button to upload image', {
            font: '16px Arial',
            fill: '#ffffff'
        });
    }

    loadImage(file) {
        const reader = new FileReader();
        
        reader.onload = (event) => {
            // Create a temporary HTML Image element
            const img = new Image();
            img.onload = () => {
                // Create a canvas to read pixel data
                const canvas = document.createElement('canvas');
                canvas.width = img.width;
                canvas.height = img.height;
                const ctx = canvas.getContext('2d');
                ctx.drawImage(img, 0, 0);
                
                // If we already have an image sprite, destroy it
                if (this.imageSprite) {
                    this.imageSprite.destroy();
                }
                
                // Add the image to the game cache
                const textureName = 'uploaded-image';
                this.textures.addCanvas(textureName, canvas);
                
                // Create sprite and center it
                const gameWidth = this.cameras.main.width;
                const gameHeight = this.cameras.main.height;
                this.imageSprite = this.add.sprite(gameWidth / 2, gameHeight / 2, textureName);
                
                // Scale down if larger than the game area
                if (this.imageSprite.width > gameWidth || this.imageSprite.height > gameHeight) {
                    const scaleX = gameWidth / this.imageSprite.width;
                    const scaleY = gameHeight / this.imageSprite.height;
                    const scale = Math.min(scaleX, scaleY) * 0.8; // 80% of available space
                    this.imageSprite.setScale(scale);
                }
                
                // Analyze the image
                this.analyzeImage(ctx, img.width, img.height);
            };
            
            img.src = event.target.result;
        };
        
        reader.readAsDataURL(file);
    }
    
    analyzeImage(ctx, width, height) {
        // Reset counts
        this.counts = { mountains: 0, land: 0, water: 0, total: 0 };
        
        // Get pixel data
        const imageData = ctx.getImageData(0, 0, width, height);
        const data = imageData.data;
        
        // Analyze each pixel
        for (let i = 0; i < data.length; i += 4) {
            const r = data[i];
            const g = data[i + 1];
            const b = data[i + 2];
            const a = data[i + 3];
            
            // Skip transparent pixels
            if (a < 128) continue;
            
            this.counts.total++;
            
            // Check for black (mountains): RGB values close to 0,0,0
            if (r < 30 && g < 30 && b < 30) {
                this.counts.mountains++;
            }
            // Check for white (dry land): RGB values close to 255,255,255
            else if (r > 225 && g > 225 && b > 225) {
                this.counts.land++;
            }
            // Check for blue (water): B value higher than R and G
            else if (b > r + 50 && b > g + 50) {
                this.counts.water++;
            }
        }
        
        // Update text with results
        const percentMountains = ((this.counts.mountains / this.counts.total) * 100).toFixed(2);
        const percentLand = ((this.counts.land / this.counts.total) * 100).toFixed(2);
        const percentWater = ((this.counts.water / this.counts.total) * 100).toFixed(2);
        const otherPercent = (100 - percentMountains - percentLand - percentWater).toFixed(2);
        
        this.statsText.setText(
            `Analysis Results:\n` +
            `Mountains (Black): ${this.counts.mountains} pixels (${percentMountains}%)\n` +
            `Dry Land (White): ${this.counts.land} pixels (${percentLand}%)\n` +
            `Water (Blue): ${this.counts.water} pixels (${percentWater}%)\n` +
            `Other Colors: ${otherPercent}%\n` +
            `Total Pixels: ${this.counts.total}`
        );
    }
}
>>>>>>> updated