-
Notifications
You must be signed in to change notification settings - Fork 689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #2983. View need a alternative DrawFrame for the v2. #2984
Conversation
@tig the obsolete |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comments and questions.
I'm looking at Add a method which returns just the lines for the rect: public IEnumerable<StraightLine> GetFrame (Rect rect, LineStyle lineStyle, Attribute? attribute = null)
{
var vts = ViewToScreen (rect);
yield return new StraightLine(new Point (vts.X, vts.Y), vts.Width,
Orientation.Horizontal, lineStyle, attribute);
yield return new StraightLine (new Point (vts.Right - 1, vts.Y), vts.Height,
Orientation.Vertical, lineStyle, attribute);
yield return new StraightLine (new Point (vts.Right - 1, vts.Bottom - 1), -vts.Width,
Orientation.Horizontal, lineStyle, attribute);
yield return new StraightLine (new Point (vts.X, vts.Bottom - 1), -vts.Height,
Orientation.Vertical, lineStyle, attribute);
} Add an extension method that operates on a collection of lines that lets you create an exclusion area: public static class StraightLineExtensions
{
/// <summary>
/// Splits or removes all lines in the <paramref name="collection"/> such that none cover the given
/// exclusion area.
/// </summary>
/// <param name="collection">Lines to adjust</param>
/// <param name="start">First point to remove from collection</param>
/// <param name="length">The number of sequential points to exclude</param>
/// <param name="orientation">Orientation of the exclusion line</param>
/// <returns></returns>
public static IEnumerable<StraightLine> Exclude (this IEnumerable<StraightLine> collection, Point start, int length, Orientation orientation)
{
foreach(var l in collection) {
// if line intersects the exclusion
// if it is wholly inclusive of the line
// remove it from returned collection
// else if it is longer on both ends
// split l into two lines
// else
// shorten right or left
}
return collection;
}
} What do you think? this would let you create rectangles with gaps in any sides needed and many other cool things besides? I can probably work out the code for this method if its a go? |
Any help is welcome. The |
I like it very much. More elegant and with less code. Thanks. In this PR I'm using a non 0 location with a value of 3 to avoid be divisible by 2 and so avoiding bugs on the unit tests. I never more will be using the 0 location for unit tests with frame. |
Closing this because was supersede per the #3004. |
Fixes #2983 - Use
LineCanvas
to draw the frame and supersede the obsolete method.Pull Request checklist:
CTRL-K-D
to automatically reformat your files before committing.dotnet test
before commit///
style comments)