示例#1
0
 public PaddedBrushModel(TilesetModel tileset, int tileOffsetX, int tileOffsetY)
     : base(tileset.Columns.Value, tileset.Rows.Value, tileset.TileWidth.Value, tileset.TileHeight.Value)
 {
     this.Tiles             = new ObservableCollection <Tile>();
     this.TileOffsetX.Value = tileOffsetX;
     this.TileOffsetY.Value = tileOffsetY;
 }
示例#2
0
        public void TileImage(Mat tilesImage, Point pixelPoint, TilesetModel tilesetModel)
        {
            this.Tiles.Clear();
            int colCount = tilesImage.Cols / this.TileWidth.Value;
            int rowCount = tilesImage.Rows / this.TileHeight.Value;

            for (int rowIndex = 0; rowIndex < rowCount; ++rowIndex)
            {
                for (int colIndex = 0; colIndex < colCount; ++colIndex)
                {
                    Size         tileSize     = this.GetTileSize();
                    Point        topLeftPoint = new Point(colIndex * this.TileWidth.Value, rowIndex * this.TileHeight.Value);
                    Mat          tileImage    = BrushUtils.CropImage(tilesImage, topLeftPoint, tileSize);
                    Rect         drawingRect  = new Rect(topLeftPoint, tileSize);
                    ImageDrawing drawing      = ImageUtils.MatToImageDrawing(tileImage, drawingRect);

                    Point offsetPoint = Point.Add(pixelPoint, (Vector)topLeftPoint);
                    int   tileID      = tilesetModel.GetID(offsetPoint);
                    int   tilesetID   = tilesetModel.ID;
                    Tile  tile        = new Tile(drawing, tilesetID, tileID);
                    this.Tiles.Add(tile);
                }
            }
        }
示例#3
0
 public PaddedBrushModel(TilesetModel tileset)
     : base(tileset.Columns.Value, tileset.Rows.Value, tileset.TileWidth.Value, tileset.TileHeight.Value)
 {
     this.Tiles = new ObservableCollection <Tile>();
 }