public void SelectTiles(Point pixelPoint1, Point pixelPoint2) { pixelPoint1 = this.TilesetModel.Value.GetPoint(pixelPoint1); pixelPoint2 = this.TilesetModel.Value.GetPoint(pixelPoint2); GeneralTransform pixelToTile = GeometryUtils.CreateTransform(this.itemTransform.pixelToTile); Point tile1 = GeometryUtils.TransformInt(pixelToTile, pixelPoint1); Point tile2 = GeometryUtils.TransformInt(pixelToTile, pixelPoint2); Point topLeftTile = GeometryUtils.TopLeftPoint(tile1, tile2); Point topLeftPixel = GeometryUtils.TransformInt(pixelToTile.Inverse, topLeftTile); Size tileSize = GeometryUtils.ComputeSize(tile1, tile2); Size pixelSize = GeometryUtils.TransformInt(pixelToTile.Inverse, tileSize); DrawSelectLinesFromPixels(topLeftPixel, pixelSize); PaddedBrushModel brushModel = new PaddedBrushModel(this.TilesetModel.Value, (int)topLeftTile.X, (int)topLeftTile.Y); brushModel.SetSize(tileSize); Mat croppedImage = BrushUtils.CropImage(this.ItemImage.Value, topLeftPixel, pixelSize); if (this.TilesetModel.Value.IsTransparent.Value) { croppedImage = ImageUtils.ColorToTransparent(croppedImage, this.TilesetModel.Value.TransparentColor.Value); } brushModel.TileImage(croppedImage, topLeftPixel, this.TilesetModel.Value); this.eventAggregator.GetEvent <NewPaddedBrushEvent>().Publish(brushModel); }
public void UpdatePaddedBrushModel(PaddedBrushModel model) { int pixelOffsetX = model.TileOffsetX.Value * model.TileWidth.Value; int pixelOffsetY = model.TileOffsetY.Value * model.TileHeight.Value; this.TilesetModel.Value.SetTileSize(model.GetTileSize()); Point pixelOffset = new Point(pixelOffsetX, pixelOffsetY); Point pixelEnd = new Point(pixelOffsetX + model.PixelWidth.Value - 1, pixelOffsetY + model.PixelHeight.Value - 1); SelectTiles(pixelOffset, pixelEnd); }
private void UpdateBrushProperties(PaddedBrushModel brushModel) { PaddedBrushModel brush = this.BrushModel.Value; this.BrushColumns.Value = brush.Columns.Value; this.BrushRows.Value = brush.Rows.Value; this.BrushTileHeight.Value = brush.TileHeight.Value; this.BrushTileWidth.Value = brush.TileWidth.Value; this.BrushTileOffsetX.Value = brush.TileOffsetX.Value; this.BrushTileOffsetY.Value = brush.TileOffsetY.Value; UpdateStampLimits(); }
private void UpdateBrushImage(PaddedBrushModel brushModel) { using (DrawingContext context = this.selectedBrushImage.Open()) { foreach (Tile tile in brushModel.Tiles) { context.DrawDrawing(tile.Image.Value); } } this.gridModel.Columns = brushModel.Columns; this.gridModel.Rows = brushModel.Rows; this.gridModel.TileWidth = brushModel.TileWidth; this.gridModel.TileHeight = brushModel.TileHeight; this.imageTransform.SetPixelToTile(this.gridModel.TileWidth.Value, this.gridModel.TileHeight.Value); this.imageTransform.SetSelectionToPixel(this.gridModel.TileWidth.Value / 2, this.gridModel.TileHeight.Value / 2); redrawExtendedBackground(); RedrawGrid(); }
public void UpdateBrushImage(PaddedBrushModel brushModel) { this.brush = brushModel; this.DrawingTool.Brush = this.brush; this.DrawingTool.Transform = this.imageTransform; }