private PointF[] ReflectTriangle(PointF[] input, Collage cl, bool rfX, bool rfY) { int clW = cl.Width; int clH = cl.Height; int offW = _dist.col * cl.TileW; int offH = _dist.row * cl.TileH; var output = new PointF[3]; for (int i = 0; i < 3; i++) { if (rfX) { output[i].X = offW + clW - input[i].X; } else { output[i].X = offW + input[i].X; } if (rfY) { output[i].Y = offH + clH - input[i].Y; } else { output[i].Y = offH + input[i].Y; } } return(output); }
public override void ReceiveTile(Tile obj, Position loc) { if (_cl == null) { _cl = new Collage(_fmt, 1, false); _cl.AddBlankTiles(1); Activate(_main.toolBox); } EdgeKind kind = EdgeOf(loc); if (kind != EdgeKind.None) { int x, y; Edge.GetCoords(kind, out x, out y); Edge e = _edges[(int)kind]; e.Distance = new Position(x, y); ResizeCollage(e); if (x == -1) { loc.col = 0; } if (y == -1) { loc.row = 0; } } _selPos = loc; _cl.SetTile(_selPos, obj as Tile); Render(); }
public void Render(Collage cl) { if (_kind == EdgeKind.None) { return; } float clWidth = cl.Width; float clHeight = cl.Height; float taperW = (float)cl.TileW / 2f; float taperH = (float)cl.TileH / 2f; float gapW = taperW / 2f; float gapH = taperH / 2f; float fitW = gapW / 2f; float fitH = gapH / 2f; int x, y; GetCoords(_kind, out x, out y); // Corner Edge if (x != 0 && y != 0) { _shape = new[] { new PointF(-taperW, fitH), new PointF(fitW, -taperH), new PointF(-taperW, -taperH) }; } // Vertical Edge else if (x != 0) { _shape = new[] { new PointF(-gapW, taperH), new PointF(-gapW, clHeight - taperH), new PointF(-gapW - taperW, clHeight / 2f) }; } // Horizontal Edge else { _shape = new[] { new PointF(taperW, -gapH), new PointF(clWidth - taperW, -gapH), new PointF(clWidth / 2f, -taperH - gapH) }; } _shape = ReflectTriangle(_shape, cl, x == 1, y == 1); }
public void Load(MainForm main, FileFormat fmt, byte[] file, int offset = 0) { _selPos = new Position(0, 0); Selected = false; _contents = file; _cl = new Collage(fmt); _cl.LoadTiles(_contents, offset); Render(); Activate(main.toolBox); ControlsTab.SizeText = file.Length; TileSample = null; ResetScroll(); }