public PlacedTetraStick(TetraStick tetraStick, Coords location, Orientation orientation, ReflectionMode reflectionMode) { TetraStick = tetraStick; Location = location; Orientation = orientation; ReflectionMode = reflectionMode; _lazyWidth = new Lazy<int>(CalculateWidth); _lazyHeight = new Lazy<int>(CalculateHeight); _lazyInteriorJunctionPoints = new Lazy<IImmutableList<Coords>>(CalculateInteriorJunctionPoints); _lazyLines = new Lazy<IEnumerable<IImmutableList<Coords>>>(CalculateLines); }
private Coords ApplyOrientation(Coords coords) { switch (Orientation) { case Orientation.North: return coords; case Orientation.South: return new Coords(Width - coords.X, Height - coords.Y); case Orientation.East: return new Coords(coords.Y, Height - coords.X); case Orientation.West: return new Coords(Width - coords.Y, coords.X); default: throw new InvalidOperationException($"Unknown orientation, \"{Orientation}\"."); } }
private Coords ApplyReflectionMode(Coords coords) { switch (ReflectionMode) { case ReflectionMode.Normal: return coords; case ReflectionMode.MirrorY: return new Coords(Width - coords.X, coords.Y); default: throw new InvalidOperationException($"Unknown reflection mode, \"{ReflectionMode}\"."); } }
private Coords ApplyLocation(Coords coords) { return new Coords(Location.X + coords.X, Location.Y + coords.Y); }
private Point CoordsToInsetUpperRightVertical(Coords coords) { return new Point( coords.X * _sw + GridLineHalfThickness + TetraStickHalfThickness, (5 - coords.Y) * _sh + GridLineHalfThickness + TetraStickInset); }
private Coords ApplyTransform(Coords coords) { return ApplyLocation( ApplyReflectionMode( ApplyOrientation(coords))); }
private Point CoordsToInsetLowerLeftVertical(Coords coords) { return new Point( coords.X * _sw + GridLineHalfThickness - TetraStickHalfThickness, (5 - coords.Y) * _sh + GridLineHalfThickness - TetraStickInset); }
private Point CoordsToInsetUpperRightHorizontal(Coords coords) { return new Point( coords.X * _sw + GridLineHalfThickness - TetraStickInset, (5 - coords.Y) * _sh + GridLineHalfThickness - TetraStickHalfThickness); }
private void AddLineUpVertical(PathSegmentCollection segments, Coords coords1, Coords coords2) { segments.Add(new LineSegment { Point = CoordsToInsetUpperRightVertical(coords2) }); segments.Add(new LineSegment { Point = CoordsToInsetLowerLeftVertical(coords1) }); }
private void AddEndCapTop(PathSegmentCollection segments, Coords coords) { segments.Add(new ArcSegment { Point = CoordsToInsetUpperLeftVertical(coords), Size = new Size(TetraStickHalfThickness, TetraStickHalfThickness) }); }
private void AddEndCapRight(PathSegmentCollection segments, Coords coords) { segments.Add(new ArcSegment { Point = CoordsToInsetUpperRightHorizontal(coords), Size = new Size(TetraStickHalfThickness, TetraStickHalfThickness) }); }
private void AddEndCapBottom(PathSegmentCollection segments, Coords coords) { segments.Add(new ArcSegment { Point = CoordsToInsetLowerRightVertical(coords), Size = new Size(TetraStickHalfThickness, TetraStickHalfThickness) }); }
private void AddCornerUpThenRight(PathSegmentCollection segments, Coords coords) { segments.Add(new ArcSegment { Point = CoordsToInsetLowerLeftHorizontal(coords), Size = new Size(TetraStickSmallCornerRadius, TetraStickSmallCornerRadius), SweepDirection = SweepDirection.Clockwise }); segments.Add(new ArcSegment { Point = CoordsToInsetUpperLeftVertical(coords), Size = new Size(TetraStickLargeCornerRadius, TetraStickLargeCornerRadius) }); }