예제 #1
0
        public void CalculateSteps()
        {
            // Force the color chip to not replace empty colors with background value
            colorChip.debugMode = true;

            var colors = colorChip.colors;
            var total  = colors.Length;

            var width  = 8;
            var height = (int)Math.Ceiling(total / (float)width);

            var totalPixels = width * height;

            var pixels = new int[totalPixels];

            for (int i = 0; i < totalPixels; i++)
            {
                if (i < total)
                {
                    pixels[i] = i;
                }
                else
                {
                    pixels[i] = -1;
                }
            }

            exporter = new PixelDataExporter(fullFileName, pixels, width, height, colors, textureFactory);

            // Reset color chip value
            colorChip.debugMode = false;

            exporter.CalculateSteps();
        }
예제 #2
0
        // TODO this should be a step in the exporter
        public virtual void ConfigurePixelData()
        {
            var width     = spriteChip.textureWidth;
            var height    = spriteChip.textureHeight;
            var pixelData = new int[width * height];

            spriteChip.texture.CopyPixels(ref pixelData, 0, 0, width, height);

            exporter = new PixelDataExporter(fullFileName, pixelData, width, height, colors, imageExporter);
        }
예제 #3
0
        // TODO this should be a step in the exporter
        public void ConfigurePixelData()
        {
            var spriteChip = engine.spriteChip;

            var totalSprite = spriteChip.totalSprites - 1;

            var width   = spriteChip.textureWidth;
            var height  = spriteChip.textureHeight;
            var sWidth  = spriteChip.width;
            var sHeight = spriteChip.height;

            var emptyCount = 0;
            var tmpData    = new int[sWidth * sHeight];
            var cols       = (int)Math.Floor((float)width / sWidth);

            for (int i = totalSprite; i > -1; i--)
            {
                spriteChip.ReadSpriteAt(i, tmpData);

                if (spriteChip.IsEmpty(tmpData))
                {
                    emptyCount++;
                }

                if (i % cols == 0)
                {
                    if (emptyCount == cols)
                    {
                        height -= sHeight;
                    }

                    emptyCount = 0;
                }
            }

            var pixelData = new int[width * height];

            spriteChip.texture.CopyPixels(ref pixelData, 0, 0, width, height);

            SpriteChipUtil.FlipSpriteData(ref pixelData, width, height, false, true);

            var colorMapChip = engine.chipManager.GetChip(ColorMapParser.chipName, false) as ColorChip;

            var colors = colorMapChip == null ? engine.colorChip.colors : colorMapChip.colors;

            exporter = new PixelDataExporter(fullFileName, pixelData, width, height, colors, textureFactory);
        }
예제 #4
0
        public void CalculateSteps()
        {
            // Force the color chip to not replace empty colors with background value
            colorChip.debugMode = true;

            ConfigureColors();

            // Reset color chip value
            colorChip.debugMode = false;

            BuildPixelData();

            // Create Pixel Data Exporter
            exporter = new PixelDataExporter(fullFileName, pixels, width, height, colors, imageExporter);

            // calculate steps for exporter
            exporter.CalculateSteps();
        }
예제 #5
0
        public void CalculateSteps()
        {
            var cols = 16;
            var rows = MathUtil.CeilToInt(totalFlags / (float)cols);

            var w = cols * tileSize.x;
            var h = rows * tileSize.y;

            var canvas = new Pattern(w, h);

            canvas.Clear();

            var totalPixels = tileSize.x * tileSize.y;

            var brush = new int[totalPixels];

            IColor[] colors = new IColor[totalFlags];

            var flagColors = flagColorChip.colors;

            for (int i = 0; i < totalFlags; i++)
            {
                colors[i] = flagColors[i];

                var pos = gameChip.CalculatePosition(i, w);

                pos.x *= tileSize.x;
                pos.y *= tileSize.y;
                // Update the brush
                for (int j = 0; j < totalPixels; j++)
                {
                    brush[j] = i;
                }

                canvas.SetPixels(pos.x, pos.y, tileSize.x, tileSize.y, brush);
            }
            var imageExporter = new PNGWriter();

            exporter = new PixelDataExporter(fullFileName, canvas.pixels, w, h, colors, imageExporter);

            exporter.CalculateSteps();
        }
예제 #6
0
        // TODO this should be a step in the exporter
        public override void ConfigurePixelData()
        {
            var spriteChip = engine.spriteChip;

            var width  = 96; //spriteChip.textureWidth;
            var height = 64; //spriteChip.textureHeight;


            var textureData = new TextureData(width, height);

//            var pixelData = new int[width * height];

            // Go through all of the sprites in the font

            // TODO get font sprites

            var total = 96;

            var maxCol = width / spriteChip.width;

            var tmpPixelData = new int[spriteChip.width * spriteChip.height];

            for (int i = 0; i < total; i++)
            {
                var pos = engine.gameChip.CalculatePosition(i, maxCol);

                spriteChip.ReadSpriteAt(i, tmpPixelData);

                textureData.SetPixels(pos.x * spriteChip.width, pos.y * spriteChip.height, spriteChip.width, spriteChip.height, tmpPixelData);
            }

            var colorMapChip = engine.chipManager.GetChip(ColorMapParser.chipName, false) as ColorChip;

            var colors = colorMapChip == null ? engine.colorChip.colors : colorMapChip.colors;

            var imageExporter = new PNGWriter();

            exporter = new PixelDataExporter(fullFileName, textureData.pixels, width, height, colors, imageExporter);
        }