本文整理汇总了C#中Canvas.DrawCircleSegment方法的典型用法代码示例。如果您正苦于以下问题:C# Canvas.DrawCircleSegment方法的具体用法?C# Canvas.DrawCircleSegment怎么用?C# Canvas.DrawCircleSegment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Canvas
的用法示例。
在下文中一共展示了Canvas.DrawCircleSegment方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawTestImageRow
private void DrawTestImageRow(Canvas c, int baseX, int baseY)
{
Vector2[] polygon = new Vector2[]
{
new Vector2(0.0f, 0.0f),
new Vector2(50.0f, 0.0f),
new Vector2(50.0f, 45.0f),
new Vector2(5.0f, 50.0f),
};
int x = baseX;
int y = baseY;
// Outline Shapes
c.PushState();
{
c.DrawCircle(x, y, 25);
x += 100;
c.DrawCircleSegment(x, y, 25, 0.0f, MathF.RadAngle30 * 4, true);
x += 100;
c.DrawLine(x, y , x + 50, y + 25);
c.DrawDashLine(x, y + 25, x + 50, y + 50);
c.DrawThickLine(x, y + 50, x + 50, y + 75, 3);
x += 100;
c.DrawOval(x, y, 50, 50);
x += 100;
c.DrawOvalSegment(x, y, 50, 50, 0.0f, MathF.RadAngle30 * 4, true);
x += 100;
c.DrawPolygon(polygon, x, y);
x += 100;
c.DrawRect(x, y, 50, 50);
x += 100;
c.DrawText("Hello World", x, y, drawBackground: true);
x = baseX;
y += 100;
}
c.PopState();
// Filled Shapes
c.PushState();
{
c.FillCircle(x, y, 25);
x += 100;
c.FillCircleSegment(x, y, 0, 25, MathF.RadAngle30 * 0, MathF.RadAngle30 * 4);
c.FillCircleSegment(x, y, 0, 25, MathF.RadAngle30 * 5, MathF.RadAngle30 * 9, 10);
x += 100;
c.FillThickLine(x, y + 25, x + 50, y + 50, 3);
x += 100;
c.FillOval(x, y, 50, 50);
x += 100;
c.FillOvalSegment(x, y, 0, 50, 50, MathF.RadAngle30 * 0, MathF.RadAngle30 * 4);
c.FillOvalSegment(x, y, 0, 50, 50, MathF.RadAngle30 * 5, MathF.RadAngle30 * 9, 10);
x += 100;
c.FillPolygon(polygon, x, y);
x += 100;
c.FillRect(x, y, 50, 50);
x = baseX;
y += 100;
}
c.PopState();
}
示例2: DrawLocalAngleConstraint
private void DrawLocalAngleConstraint(Canvas canvas, RigidBody body, Vector2 anchor, float minAngle, float maxAngle, float currentAngle, float radius)
{
Vector3 bodyPos = body.GameObj.Transform.Pos;
ColorRgba clr = this.JointColor;
ColorRgba clrErr = this.JointErrorColor;
Vector2 anchorToWorld = body.GameObj.Transform.GetWorldVector(anchor);
Vector2 angleVecMin = Vector2.FromAngleLength(minAngle, radius);
Vector2 angleVecMax = Vector2.FromAngleLength(maxAngle, radius);
Vector2 errorVec = Vector2.FromAngleLength(currentAngle, radius);
float angleDistMin = MathF.Abs(currentAngle - minAngle);
float angleDistMax = MathF.Abs(currentAngle - maxAngle);
float angleRange = maxAngle - minAngle;
bool hasError = angleDistMin > angleDistMax ? angleDistMin >= angleRange : angleDistMax >= angleRange;
if (hasError)
{
float circleBegin = currentAngle;
float circleEnd = angleDistMin < angleDistMax ? minAngle : maxAngle;
if (MathF.TurnDir(circleBegin, circleEnd) < 0)
{
MathF.Swap(ref circleBegin, ref circleEnd);
circleEnd = circleBegin + MathF.CircularDist(circleBegin, circleEnd);
}
canvas.State.SetMaterial(new BatchInfo(DrawTechnique.Alpha, clrErr));
canvas.DrawLine(
bodyPos.X + anchorToWorld.X,
bodyPos.Y + anchorToWorld.Y,
bodyPos.Z,
bodyPos.X + anchorToWorld.X + errorVec.X,
bodyPos.Y + anchorToWorld.Y + errorVec.Y,
bodyPos.Z);
canvas.DrawCircleSegment(
bodyPos.X + anchorToWorld.X,
bodyPos.Y + anchorToWorld.Y,
bodyPos.Z,
radius,
circleBegin,
circleEnd);
this.DrawLocalText(canvas, body,
string.Format("{0:F0}°", MathF.RadToDeg(currentAngle)),
anchorToWorld + errorVec,
Vector2.UnitY,
errorVec.Angle);
}
canvas.State.SetMaterial(new BatchInfo(DrawTechnique.Alpha, clr));
canvas.DrawCircleSegment(
bodyPos.X + anchorToWorld.X,
bodyPos.Y + anchorToWorld.Y,
bodyPos.Z,
radius,
minAngle,
maxAngle);
canvas.DrawLine(
bodyPos.X + anchorToWorld.X,
bodyPos.Y + anchorToWorld.Y,
bodyPos.Z,
bodyPos.X + anchorToWorld.X + angleVecMin.X,
bodyPos.Y + anchorToWorld.Y + angleVecMin.Y,
bodyPos.Z);
canvas.DrawLine(
bodyPos.X + anchorToWorld.X,
bodyPos.Y + anchorToWorld.Y,
bodyPos.Z,
bodyPos.X + anchorToWorld.X + angleVecMax.X,
bodyPos.Y + anchorToWorld.Y + angleVecMax.Y,
bodyPos.Z);
this.DrawLocalText(canvas, body,
string.Format("{0:F0}°", MathF.RadToDeg(minAngle)),
anchorToWorld + angleVecMin,
angleVecMin.Angle);
this.DrawLocalText(canvas, body,
string.Format("{0:F0}°", MathF.RadToDeg(maxAngle)),
anchorToWorld + angleVecMax,
angleVecMax.Angle);
}
示例3: DrawLocalAngleMotor
private void DrawLocalAngleMotor(Canvas canvas, RigidBody body, Vector2 anchor, float speed, float maxTorque, float radius)
{
Vector3 bodyPos = body.GameObj.Transform.Pos;
ColorRgba clr = this.MotorColor;
float baseAngle = body.GameObj.Transform.Angle;
float speedAngle = baseAngle + speed;
float maxTorqueAngle = baseAngle + MathF.Sign(speed) * maxTorque * 0.01f;
Vector2 anchorToWorld = body.GameObj.Transform.GetWorldVector(anchor);
Vector2 arrowBase = anchorToWorld + Vector2.FromAngleLength(speedAngle, radius);
Vector2 arrorA = Vector2.FromAngleLength(speedAngle - MathF.RadAngle45, MathF.Sign(speed) * radius * 0.05f);
Vector2 arrorB = Vector2.FromAngleLength(speedAngle - MathF.RadAngle45 + MathF.RadAngle270, MathF.Sign(speed) * radius * 0.05f);
canvas.State.SetMaterial(new BatchInfo(DrawTechnique.Alpha, clr));
canvas.DrawCircleSegment(
bodyPos.X + anchorToWorld.X,
bodyPos.Y + anchorToWorld.Y,
bodyPos.Z,
radius - 2,
MathF.Sign(speed) >= 0 ? baseAngle : maxTorqueAngle,
MathF.Sign(speed) >= 0 ? maxTorqueAngle : baseAngle);
canvas.DrawCircleSegment(
bodyPos.X + anchorToWorld.X,
bodyPos.Y + anchorToWorld.Y,
bodyPos.Z,
radius + 2,
MathF.Sign(speed) >= 0 ? baseAngle : maxTorqueAngle,
MathF.Sign(speed) >= 0 ? maxTorqueAngle : baseAngle);
canvas.DrawCircleSegment(
bodyPos.X + anchorToWorld.X,
bodyPos.Y + anchorToWorld.Y,
bodyPos.Z,
radius,
MathF.Sign(speed) >= 0 ? baseAngle : speedAngle,
MathF.Sign(speed) >= 0 ? speedAngle : baseAngle);
canvas.DrawLine(
bodyPos.X + arrowBase.X,
bodyPos.Y + arrowBase.Y,
bodyPos.Z,
bodyPos.X + arrowBase.X + arrorA.X,
bodyPos.Y + arrowBase.Y + arrorA.Y,
bodyPos.Z);
canvas.DrawLine(
bodyPos.X + arrowBase.X,
bodyPos.Y + arrowBase.Y,
bodyPos.Z,
bodyPos.X + arrowBase.X + arrorB.X,
bodyPos.Y + arrowBase.Y + arrorB.Y,
bodyPos.Z);
}