本文整理汇总了C#中SharpDX.Matrix3x2类的典型用法代码示例。如果您正苦于以下问题:C# Matrix3x2类的具体用法?C# Matrix3x2怎么用?C# Matrix3x2使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Matrix3x2类属于SharpDX命名空间,在下文中一共展示了Matrix3x2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Rotate
public void Rotate(float angle)
{
Control =
s.Matrix3x2.Multiply(
s.Matrix3x2.Rotation(angle), // premultiply
Control);
}
示例2: RotateAt
public void RotateAt(float angle, float centerX, float centerY)
{
angle = Conversions.DegreesToRadians(angle);
var sina = (float)Math.Sin(angle);
var cosa = (float)Math.Cos(angle);
var matrix = new s.Matrix3x2(cosa, sina, -sina, cosa, centerX - centerX * cosa + centerY * sina, centerY - centerX * sina - centerY * cosa);
Control = s.Matrix3x2.Multiply(matrix, Control);
}
示例3: Matrix3x3
public Matrix3x3(Matrix3x2 Other)
{
M00 = Other.M11;
M01 = Other.M12;
M02 = 0;
M10 = Other.M21;
M11 = Other.M22;
M12 = 0;
M20 = Other.M31;
M21 = Other.M32;
M22 = 1;
}
示例4: Invert
public static void Invert(ref Matrix3x2 matrix, out Matrix3x2 result)
{
float determinant = matrix.Determinant();
if (MathUtil.WithinEpsilon(determinant, 0.0f)) {
result = Matrix3x2.Identity;
return;
}
float invdet = 1.0f / determinant;
float _offsetX = matrix.M31;
float _offsetY = matrix.M32;
result = new Matrix3x2(
matrix.M22 * invdet,
-matrix.M12 * invdet,
-matrix.M21 * invdet,
matrix.M11 * invdet,
(matrix.M21 * _offsetY - _offsetX * matrix.M22) * invdet,
(_offsetX * matrix.M12 - matrix.M11 * _offsetY) * invdet);
}
示例5: DrawGlyphRun
public Result DrawGlyphRun(object clientDrawingContext, float baselineOriginX, float baselineOriginY, MeasuringMode measuringMode, GlyphRun glyphRun, GlyphRunDescription glyphRunDescription, ComObject clientDrawingEffect)
{
var pathGeometry = new PathGeometry(_d2DFactory);
var geometrySink = pathGeometry.Open();
var fontFace = glyphRun.FontFace;
if (glyphRun.Indices.Length > 0)
fontFace.GetGlyphRunOutline(glyphRun.FontSize, glyphRun.Indices, glyphRun.Advances, glyphRun.Offsets, glyphRun.IsSideways, glyphRun.BidiLevel % 2 != 0, geometrySink);
geometrySink.Close();
geometrySink.Dispose();
fontFace.Dispose();
var matrix = new Matrix3x2()
{
M11 = 1,
M12 = 0,
M21 = 0,
M22 = 1,
M31 = baselineOriginX,
M32 = baselineOriginY
};
var transformedGeometry = new TransformedGeometry(_d2DFactory, pathGeometry, matrix);
var brushColor = (Color4)Color.Black;
if (clientDrawingEffect != null && clientDrawingEffect is ColorDrawingEffect)
brushColor = (clientDrawingEffect as ColorDrawingEffect).Color;
var brush = new SolidColorBrush(_renderTarget, brushColor);
_renderTarget.DrawGeometry(transformedGeometry, brush);
_renderTarget.FillGeometry(transformedGeometry, brush);
pathGeometry.Dispose();
transformedGeometry.Dispose();
brush.Dispose();
return SharpDX.Result.Ok;
}
示例6: CalculateMatrix
/// <summary>
/// 计算转换矩阵。
/// </summary>
private void CalculateMatrix()
{
matrix = new Matrix3x2(1, 0, 0, 1, -shape.Center.X, -shape.Center.Y);
if (rotate != 0)
{
matrix *= Matrix3x2.Rotation(this.rotateRadian);
}
if (this.scale != 1)
{
matrix *= Matrix3x2.Scaling(scale);
}
matrix *= Matrix3x2.Translation(offset.X + scale * shape.Center.X, offset.Y + scale * shape.Center.Y);
}
示例7: Append
public void Append(IMatrix matrix)
{
Control = s.Matrix3x2.Multiply(this.Control, matrix.ToDx());
}
示例8: ScaleAt
public void ScaleAt(float scaleX, float scaleY, float centerX, float centerY)
{
var matrix = new s.Matrix3x2(scaleX, 0f, 0f, scaleY, centerX - centerX * scaleX, centerY - centerY * scaleY);
Control = s.Matrix3x2.Multiply(matrix, Control);
}
示例9: Scale
public void Scale(float sx, float sy)
{
Control = s.Matrix3x2.Multiply(s.Matrix3x2.Scaling(sx, sy), Control); // premultiply
}
示例10: MatrixHandler
public MatrixHandler(ref s.Matrix3x2 m)
{
this.Control = m; // copied the value as Control is a struct
}
示例11: Translation
/// <summary>
/// Creates a translation matrix using the specified offsets.
/// </summary>
/// <param name="value">The offset for both coordinate planes.</param>
/// <param name="result">When the method completes, contains the created translation matrix.</param>
public static void Translation(ref Vector2 value, out Matrix3x2 result)
{
Translation(value.X, value.Y, out result);
}
示例12: Transformation
/// <summary>
/// Creates a transformation matrix.
/// </summary>
/// <param name="xScale">Scaling factor that is applied along the x-axis.</param>
/// <param name="yScale">Scaling factor that is applied along the y-axis.</param>
/// <param name="angle">Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis.</param>
/// <param name="xOffset">X-coordinate offset.</param>
/// <param name="yOffset">Y-coordinate offset.</param>
/// <param name="result">When the method completes, contains the created transformation matrix.</param>
public static void Transformation(float xScale, float yScale, float angle, float xOffset, float yOffset, out Matrix3x2 result)
{
result = Scaling(xScale, yScale) * Rotation(angle) * Translation(xOffset, yOffset);
}
示例13: Rotation
/// <summary>
/// Creates a matrix that rotates about a specified center.
/// </summary>
/// <param name="angle">Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis.</param>
/// <param name="center">The center of the rotation.</param>
/// <param name="result">When the method completes, contains the created rotation matrix.</param>
public static void Rotation(float angle, Vector2 center, out Matrix3x2 result)
{
result = Translation(-center) * Rotation(angle) * Translation(center);
}
示例14: Scaling
/// <summary>
/// Creates a matrix that is scaling from a specified center.
/// </summary>
/// <param name="x">Scaling factor that is applied along the x-axis.</param>
/// <param name="y">Scaling factor that is applied along the y-axis.</param>
/// <param name="center">The center of the scaling.</param>
/// <param name="result">The created scaling matrix.</param>
public static void Scaling( float x, float y, ref Vector2 center, out Matrix3x2 result)
{
Matrix3x2 localResult;
localResult.M11 = x; localResult.M12 = 0.0f;
localResult.M21 = 0.0f; localResult.M22 = y;
localResult.M31 = center.X - (x * center.X);
localResult.M32 = center.Y - (y * center.Y);
result = localResult;
}
示例15: Invert
public void Invert()
{
this.Control = s.Matrix3x2.Invert(this.Control);
}