LunarBrushManager/PointToRect.cs
(开头部分) 10KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
namespace SHomeWorkshop.LunarTools
{
public static class PointToRect
{
/// <summary>
/// 求一个点与矩形中心点的连线与矩形的边缘的交点。
/// </summary>
/// <param name="rect">矩形</param>
/// <param name="point">矩形内部或外部一点。</param>
/// <returns></returns>
public static ArrowPoints GetCrossPointToRect(Rect rect, Point point)
{
Point center = new Point(rect.Left + rect.Width / 2, rect.Top + rect.Height / 2);
ArrowPoints arrowPt = new ArrowPoints();
double arrowHeight = 10;
if (point.X == center.X)
{
if (point.Y < center.Y)//y轴正向。
{
arrowPt.Top = new Point(center.X, rect.Top);
arrowPt.Start = new Point(center.X + arrowHeight / Math.Sqrt(3), rect.Top - arrowHeight);
arrowPt.End = new Point(center.X - arrowHeight / Math.Sqrt(3), rect.Top - arrowHeight);
return arrowPt;
}
else if (point.Y == center.Y)//正好是Rect中心。这几乎不可能出现。
{
//为防止出现这一情况。
point.X += 1; point.Y += 1;
//arrowPt.Top = center;
//arrowPt.Start = center;
//arrowPt.End = center;
//return arrowPt;
}
else if (point.Y > center.Y)//y轴负向。
{
arrowPt.Top = new Point(center.X, rect.Bottom);
arrowPt.Start = new Point(center.X - arrowHeight / Math.Sqrt(3), rect.Bottom + arrowHeight);
arrowPt.End = new Point(center.X + arrowHeight / Math.Sqrt(3), rect.Bottom + arrowHeight);
return arrowPt;
}
}
if (point.Y == center.Y)
{
if (point.X > center.X)
{
arrowPt.Top = new Point(rect.Right, center.Y);//X轴正向。
后面还有 175 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。