本文整理汇总了C#中System.Numerics.Vector2类的典型用法代码示例。如果您正苦于以下问题:C# Vector2类的具体用法?C# Vector2怎么用?C# Vector2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Vector2类属于System.Numerics命名空间,在下文中一共展示了Vector2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PolygonShape
public PolygonShape()
{
ShapeType = ShapeType.Polygon;
_radius = Settings.b2_polygonRadius;
_vertexCount = 0;
_centroid = Vector2.Zero;
}
示例2: Scale
public void Scale(RenderTarget2D source, RenderTarget2D destination)
{
_effect.CurrentTechnique = source.Format.IsFloatingPoint() ? _effect.Techniques["Software"] : _effect.Techniques["Hardware"];
Vector2 resolution = new Vector2(source.Width, source.Height);
float scaleFactor = (destination.Width > source.Width) ? 2 : 0.5f;
RenderTarget2D input = source;
while (IntermediateNeeded(resolution, destination, scaleFactor))
{
resolution *= scaleFactor;
RenderTarget2D output = RenderTargetManager.GetTarget(_device, (int)resolution.X, (int)resolution.Y, source.Format, name:"scaled", usage: RenderTargetUsage.DiscardContents);
Draw(input, output);
if (input != source)
RenderTargetManager.RecycleTarget(input);
input = output;
}
Draw(input, destination);
if (input != source)
RenderTargetManager.RecycleTarget(input);
}
示例3: Canvas_Draw
private void Canvas_Draw(CanvasControl sender, CanvasDrawEventArgs args)
{
var a = new Vector2(10, 10);
var b = new Vector2(100, 100);
args.DrawingSession.DrawLine(a, b, Colors.Yellow);
}
示例4: Vector4
/// <summary>
/// Constructs a Vector4 from the given Vector2 and a Z and W component.
/// </summary>
/// <param name="value">The vector to use as the X and Y components.</param>
/// <param name="z">The Z component.</param>
/// <param name="w">The W component.</param>
public Vector4(Vector2 value, Single z, Single w)
{
X = value.X;
Y = value.Y;
Z = z;
W = w;
}
示例5: IntermediateNeeded
private bool IntermediateNeeded(Vector2 currentResolution, RenderTarget2D target, float scale)
{
// ReSharper disable CompareOfFloatsByEqualityOperator
return (scale == 2) ? (currentResolution.X * 2 < target.Width && currentResolution.Y * 2 < target.Height)
// ReSharper restore CompareOfFloatsByEqualityOperator
: (currentResolution.X / 2 > target.Width && currentResolution.Y / 2 > target.Height);
}
示例6: VertexPositionTextureNormalBinormalTangent
// ReSharper restore NotAccessedField.Global
// ReSharper restore MemberCanBePrivate.Global
public VertexPositionTextureNormalBinormalTangent(Vector3 position, Vector2 textureCoordinate, Vector3 normal, Vector3 binormal, Vector3 tangent)
{
Position = position.ToXNA();
TextureCoordinate = textureCoordinate.ToXNA();
Normal = normal.ToXNA();
Binormal = binormal.ToXNA();
Tangent = tangent.ToXNA();
}
示例7: OrientedBox2D
public OrientedBox2D(float centerX, float centerY, float sizeX, float sizeY, float angle)
{
center.X = centerX;
center.Y = centerY;
Angle = angle;
Radii = new Vector2(sizeX / 2.0f, sizeY / 2.0f);
CalcHelpers();
}
示例8: Line
public SvgBuilder Line(Vector2 start, Vector2 end, float width, string stroke)
{
_parts.Add($"<line x1=\"{start.X * Scale}\" y1=\"{start.Y * Scale}\" x2=\"{end.X * Scale}\" y2=\"{end.Y * Scale}\" stroke=\"{stroke}\" stroke-width=\"{width}\" />");
UpdateMinMax(start, end);
return this;
}
示例9: VertexMetadata
public VertexMetadata(float x, float y, float z, float u, float v, Color color, uint faceIndex, uint triangleIndex)
{
Position = new Vector4(x, y, z, 1f);
TextureCoordinate = new Vector2(u, v);
Color = color;
FaceIndex = faceIndex;
TriangleIndex = triangleIndex;
}
示例10: Circle
public SvgBuilder Circle(Vector2 center, float radius, string fill = "blue")
{
_parts.Add($"<circle cx=\"{center.X * Scale}\" cy=\"{center.Y * Scale}\" r=\"{radius * Scale}\" fill=\"{fill}\"></circle>");
UpdateMinMax(center - new Vector2(radius));
UpdateMinMax(center + new Vector2(radius));
return this;
}
示例11: Operation
public void Operation(Operations operation)
{
Random rand = new Random(84329);
Vector2 v1 = new Vector2(Convert.ToSingle(rand.NextDouble()), Convert.ToSingle(rand.NextDouble()));
Vector2 v2 = new Vector2(Convert.ToSingle(rand.NextDouble()), Convert.ToSingle(rand.NextDouble()));
foreach (var iteration in Benchmark.Iterations)
using (iteration.StartMeasurement())
ExecuteTest(operation, 1000000, v1, v2);
}
示例12: RadialGradientStyle
/// <summary>
/// Initializes a new instance of the <see cref="RadialGradientStyle" /> class.
/// </summary>
/// <param name="unitOriginOffset">The unit origin offset.</param>
/// <param name="transform">The transform.</param>
/// <param name="gradientStops">The gradient stops.</param>
public RadialGradientStyle(
Vector2 unitOriginOffset,
Matrix3x2 transform,
[NotNull] IReadOnlyList<GradientStop> gradientStops)
: base(gradientStops)
{
UnitOriginOffset = unitOriginOffset;
GradientTransform = transform;
}
示例13: DrawLine
public void DrawLine(Vector2 p1, Vector2 p2, Color color, float strokeWidth, CanvasStrokeStyle strokeStyle)
{
if (m_renderingType == TestSceneRenderingType.Default)
{
m_drawingSession.DrawLine(p1, p2, color, strokeWidth, strokeStyle);
}
else
{
m_drawingSession.DrawLine(p1, p2, Colors.Black);
}
}
示例14: FillEllipse
public void FillEllipse(Vector2 center, float radiusX, float radiusY, Color color)
{
if (m_renderingType == TestSceneRenderingType.Default)
{
m_drawingSession.FillEllipse(center, radiusX, radiusY, color);
}
else
{
m_drawingSession.DrawEllipse(center, radiusX, radiusY, Colors.Black);
}
}
示例15: TextSprite
public TextSprite(
string text,
FontId font = default(FontId),
float fontSize = 12,
Vector2 position = default(Vector2),
Color? color = null)
{
this.Text = text;
this.Font = font;
this.FontSize = fontSize;
this.Position = position;
this.Color = color ?? Color.White;
}