本文整理汇总了C#中DPoint.Offset方法的典型用法代码示例。如果您正苦于以下问题:C# DPoint.Offset方法的具体用法?C# DPoint.Offset怎么用?C# DPoint.Offset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DPoint
的用法示例。
在下文中一共展示了DPoint.Offset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CalcSizeDelta
DPoint CalcSizeDelta(DPoint pt, Figure f, bool lockAspectRatio)
{
if (lockAspectRatio && f.Width > 0)
{
pt = pt.Offset(-dragPt.X, -dragPt.Y);
double m = f.Height / f.Width;
DPoint intersectionPt = DGeom.IntersectionOfTwoLines(m, f.BottomRight, -1, pt);
// using soh/cah/toa
double h = DGeom.DistBetweenTwoPts(f.BottomRight, intersectionPt);
double A = Math.Atan(m);
// cos(A) = a/h
double dX = Math.Cos(A) * h;
// sin(A) = o/h
double dY = Math.Sin(A) * h;
// find out the angle of the line between the mouse pt and the botton left of the figure
double angle = -(Math.Atan2(pt.Y - f.BottomRight.Y, pt.X - f.BottomRight.X) - Math.PI);
// if the angle is on the topleft side (225 deg to 45 deg) then we are resizing smaller
if (angle < Math.PI / 4 || angle > Math.PI + Math.PI / 4)
return new DPoint(-dX, -dY);
else
return new DPoint(dX, dY);
}
else
return new DPoint((pt.X - f.X) - f.Width - dragPt.X, (pt.Y - f.Y) - f.Height - dragPt.Y);
}
示例2: EngineToClient
public DPoint EngineToClient(DPoint pt)
{
pt = new DPoint(pt.X * scale, pt.Y * scale);
return pt.Offset(-HortScroll + OffsetX, -VertScroll + OffsetY);
}
示例3: RotatePoint
public static DPoint RotatePoint(DPoint pt, DPoint origin, double angle)
{
if (angle == 0 || (pt.X == origin.X && pt.Y == origin.Y))
return new DPoint(pt.X, pt.Y);
// set to origin
pt = pt.Offset(-origin.X, -origin.Y);
// rotate point
DPoint rotatedPt = new DPoint(pt.X * Math.Cos(angle) - pt.Y * Math.Sin(angle),
pt.X * Math.Sin(angle) + pt.Y * Math.Cos(angle));
// unset from origin
rotatedPt = rotatedPt.Offset(origin.X, origin.Y);
return rotatedPt;
}