本文整理汇总了C#中System.Drawing.PointF.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# PointF.ToArray方法的具体用法?C# PointF.ToArray怎么用?C# PointF.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.PointF
的用法示例。
在下文中一共展示了PointF.ToArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Points
/// <summary>
/// Calculates an array of points along the curve spaces so that each pair
/// of adjacent points are the same distance apart.
/// </summary>
/// <param name="distPerDivision">The required distance per pair of points
/// </param>
/// <returns></returns>
public PointF[] Points(float distPerDivision)
{
int numDivisions = Math.Max((int) (Length() / distPerDivision), 2);
PointF[] oldPoints = PointsUneven(numDivisions / 2);
PointF[] points = new PointF[numDivisions];
points[0] = oldPoints[0];
int lastPassedPointIndex = 0;
float distFromLastPassedPoint = 0.0f;
float distToLastPassedPoint = 0.0f;
for (int ii = 1; ii < numDivisions; ii++)
{
PointF prevPoint = oldPoints[lastPassedPointIndex];
for (int jj = lastPassedPointIndex + 1; jj < oldPoints.Length; jj++)
{
PointF nextPoint = oldPoints[jj];
float distBetweenOldPoints = GeometryUtils.DistBetweenPoints(prevPoint, nextPoint);
if (distBetweenOldPoints - distFromLastPassedPoint > distPerDivision)
{
float ratio = (distPerDivision + distFromLastPassedPoint) /
distBetweenOldPoints;
distFromLastPassedPoint += distPerDivision;
points[ii] = GeometryUtils.PointOnLine(prevPoint,
nextPoint,
ratio);
break;
}
else
{
distToLastPassedPoint = distBetweenOldPoints - distFromLastPassedPoint;
distFromLastPassedPoint = -1 * distToLastPassedPoint;
lastPassedPointIndex = jj;
prevPoint = oldPoints[lastPassedPointIndex];
}
}
}
return points.ToArray();
}
示例2: transformRandom
static Bitmap transformRandom(Bitmap bmp, PointF[] points)
{
const float maxTranslation = 0;
const float maxRotation = 0;
const float maxScale = 0.30f;
var ps = points.ToArray();
Bitmap result = new Bitmap(origImgSize, origImgSize);
using (Graphics g = Graphics.FromImage(result))
{
var scl = 1.0f +(float)(Tools.rnd.Uniform() * maxScale);
var imh = origImgSize / 2.0f;
g.TranslateTransform(-origImgSize / 2.0f, -origImgSize / 2.0f, System.Drawing.Drawing2D.MatrixOrder.Append);
g.ScaleTransform(scl, scl, System.Drawing.Drawing2D.MatrixOrder.Append);
var rot = ((float)Tools.rnd.Uniform() - 0.5f) * 2 * maxRotation;
g.RotateTransform(rot, System.Drawing.Drawing2D.MatrixOrder.Append);
g.TranslateTransform(+imh, +imh, System.Drawing.Drawing2D.MatrixOrder.Append);
var tx = ((float)Tools.rnd.Uniform() - 0.5f) * 2 * maxTranslation;
var ty = ((float)Tools.rnd.Uniform() - 0.5f) * 2 * maxTranslation;
//tx = 10;
//ty = 20;
g.TranslateTransform(tx, ty);
g.DrawImage(bmp, 0, 0, result.Width, result.Height);
g.Transform.TransformPoints(ps);
}
for (int i = 0; i < ps.Length; ++i)
{
if (points[i].X != -1)
points[i].X = ps[i].X;
if (points[i].Y != -1)
points[i].Y = ps[i].Y;
}
for (int i = 0; i < ps.Length; ++i)
{
if (points[i].X < 0 || points[i].X > origImgSize ||
points[i].Y < 0 || points[i].Y > origImgSize)
{
points[i].X = -1;
points[i].Y = -1;
}
}
return result;
}
示例3: ToWorld
public PointF[] ToWorld(PointF[] captureCameraPoints)
{
var worldPoints = captureCameraPoints.ToArray();
CameraToWorld.ProjectPoints(worldPoints);
return worldPoints;
}