本文整理汇总了C#中Xwt.TransformPoints方法的典型用法代码示例。如果您正苦于以下问题:C# Xwt.TransformPoints方法的具体用法?C# Xwt.TransformPoints怎么用?C# Xwt.TransformPoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xwt
的用法示例。
在下文中一共展示了Xwt.TransformPoints方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Rotate
public virtual void Rotate(Xwt.Drawing.Context ctx, double x, double y)
{
// draws a line along the x-axis from (0,0) to (r,0) with a constant translation and an increasing
// rotational component. This composite transform is then applied to a vertical line, with inverse
// color, and an additional x-offset, to form a mirror image figure for easy visual comparison.
// These transformed points must be drawn with the identity CTM, hence the Restore() each time.
ctx.Save (); // save caller's context (assumed to be the Identity CTM)
ctx.SetLineWidth (3); // should align exactly if drawn with half-pixel coordinates
// Vector length (pixels) and rotation limit (degrees)
double r = 30;
double end = 270;
for (double n = 0; n<=end; n += 5) {
ctx.Save (); // save context and identity CTM for each line
// Set up translation to centre point of first figure, ensuring pixel alignment
ctx.Translate (x + 30.5, y + 30.5);
ctx.Rotate (n);
ctx.MoveTo (0, 0);
ctx.RelLineTo (r, 0);
double c = n / end;
ctx.SetColor (new Color (c, c, c));
ctx.Stroke (); // stroke first figure with composite Translation and Rotation CTM
// Generate mirror image figure as a visual test of TransformPoints
Point p0 = new Point (0,0);
Point p1 = new Point (0, -r);
Point[] p = new Point[] {p0, p1};
ctx.TransformPoints (p); // using composite transformation
ctx.Restore (); // restore identity CTM
ctx.Save (); // save again (to restore after additional Translation)
ctx.Translate (2 * r + 1, 0); // extra x-offset to clear first figure
ctx.MoveTo (p[0]);
ctx.LineTo (p[1]);
c = 1-c;
ctx.SetColor (new Color (c, c, c));
ctx.Stroke(); // stroke transformed points with offset in CTM
ctx.Restore (); // restore identity CTM for next line
}
ctx.Restore (); // restore caller's context
}
示例2: Rotate
public virtual void Rotate(Xwt.Drawing.Context ctx, double x, double y)
{
ctx.Save ();
ctx.Translate (x + 30, y + 30);
ctx.SetLineWidth (3);
// Rotation
double end = 270;
double r = 30;
for (double n = 0; n<=end; n += 5) {
ctx.Save ();
ctx.Rotate (n);
ctx.MoveTo (0, 0);
ctx.RelLineTo (r, 0);
double c = n / end;
ctx.SetColor (new Color (c, c, c));
ctx.Stroke ();
// Visual test for TransformPoints
Point p0 = new Point (0,0);
Point p1 = new Point (0, -r);
Point[] p = new Point[] {p0, p1};
ctx.TransformPoints (p);
ctx.ResetTransform ();
ctx.Translate (2 * r + 1, 0);
ctx.MoveTo (p[0]);
ctx.LineTo (p[1]);
c = 1-c;
ctx.SetColor (new Color (c, c, c));
ctx.Stroke();
ctx.Restore ();
}
ctx.Restore ();
}