本文整理汇总了C#中Canvas.FillCircleSegment方法的典型用法代码示例。如果您正苦于以下问题:C# Canvas.FillCircleSegment方法的具体用法?C# Canvas.FillCircleSegment怎么用?C# Canvas.FillCircleSegment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Canvas
的用法示例。
在下文中一共展示了Canvas.FillCircleSegment方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(Canvas target, Vector3 basePos, float baseRotation, float baseScale)
{
float circleRadius = 5.0f;
float borderRadius = DefaultOutlineWidth;
// Scale anti-proportional to perspective scale in order to keep a constant size
// in screen space even when actually drawing in world space.
{
float scale = 1.0f;
Vector3 posTemp = this.pos + basePos;
target.DrawDevice.PreprocessCoords(ref posTemp, ref scale);
circleRadius /= scale;
borderRadius /= scale;
}
// Determine circle position
Vector3 circlePos = this.pos;
MathF.TransformCoord(ref circlePos.X, ref circlePos.Y, baseRotation, baseScale);
circlePos += basePos;
// Draw circle
target.State.ColorTint *= this.Color;
target.FillCircle(
circlePos.X,
circlePos.Y,
circlePos.Z,
circleRadius - borderRadius * 0.5f);
// Draw circle outline
if (target.DrawDevice.DepthWrite) target.State.ZOffset -= 1;
target.State.ColorTint *= ColorRgba.Black;
target.FillCircleSegment(
circlePos.X,
circlePos.Y,
circlePos.Z,
circleRadius,
0.0f,
MathF.RadAngle360,
borderRadius);
}
示例2: Draw
public override void Draw(Canvas target, Vector3 basePos, float baseRotation, float baseScale)
{
float borderRadius = DefaultOutlineWidth;
float circleRadius = this.radius * baseScale;
// Scale anti-proportional to perspective scale in order to keep a constant size
// in screen space even when actually drawing in world space.
{
float scale = 1.0f;
Vector3 posTemp = this.pos + basePos;
target.DrawDevice.PreprocessCoords(ref posTemp, ref scale);
borderRadius /= scale;
if (this.invariantScale) circleRadius /= scale;
}
// Determine circle position
Vector3 circlePos = this.pos;
MathF.TransformCoord(ref circlePos.X, ref circlePos.Y, baseRotation, baseScale);
circlePos += basePos;
// Draw circle
target.State.ColorTint *= this.Color;
target.FillCircleSegment(
circlePos.X,
circlePos.Y,
circlePos.Z,
circleRadius - borderRadius * 0.5f,
this.minAngle + baseRotation,
this.maxAngle + baseRotation);
// Draw circle outline
if (target.DrawDevice.DepthWrite) target.State.ZOffset -= 0.1f;
target.State.ColorTint *= ColorRgba.Black;
target.FillCircleSegment(
circlePos.X,
circlePos.Y,
circlePos.Z,
circleRadius,
this.minAngle + baseRotation,
this.maxAngle + baseRotation,
borderRadius);
if (MathF.CircularDist(this.minAngle, this.maxAngle) > MathF.RadAngle1 * 0.001f)
{
Vector2 minAngleVec = Vector2.FromAngleLength(this.minAngle + baseRotation, circleRadius);
Vector2 maxAngleVec = Vector2.FromAngleLength(this.maxAngle + baseRotation, circleRadius);
target.FillThickLine(
circlePos.X,
circlePos.Y,
circlePos.Z,
circlePos.X + minAngleVec.X,
circlePos.Y + minAngleVec.Y,
circlePos.Z,
borderRadius);
target.FillThickLine(
circlePos.X,
circlePos.Y,
circlePos.Z,
circlePos.X + maxAngleVec.X,
circlePos.Y + maxAngleVec.Y,
circlePos.Z,
borderRadius);
}
}
示例3: 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();
}
示例4: Draw
public override void Draw(Canvas target, Vector3 basePos, float baseRotation, float baseScale)
{
float originRadius = 5.0f;
float vectorThickness = 4.0f;
float borderRadius = DefaultOutlineWidth;
// Scale anti-proportional to perspective scale in order to keep a constant size
// in screen space even when actually drawing in world space.
{
float scale = 1.0f;
Vector3 posTemp = this.posA + basePos;
target.DrawDevice.PreprocessCoords(ref posTemp, ref scale);
originRadius /= scale;
borderRadius /= scale;
vectorThickness /= scale;
}
// Determine base and target positions
Vector3 originPos = this.posA;
Vector3 targetPos = this.posB;
MathF.TransformCoord(ref originPos.X, ref originPos.Y, baseRotation, baseScale);
MathF.TransformCoord(ref targetPos.X, ref targetPos.Y, baseRotation, baseScale);
originPos += basePos;
targetPos += basePos;
// Create connection polygon
float vectorLen = (targetPos.Xy - originPos.Xy).Length;
Vector2 dirForward = (targetPos.Xy - originPos.Xy).Normalized;
Vector2 dirLeft = dirForward.PerpendicularLeft;
Vector2 dirRight = -dirLeft;
Vector2[] connection = new Vector2[4];
connection[0] = dirLeft * vectorThickness * 0.5f;
connection[1] = dirLeft * vectorThickness * 0.5f + dirForward * vectorLen;
connection[2] = dirRight * vectorThickness * 0.5f + dirForward * vectorLen;
connection[3] = dirRight * vectorThickness * 0.5f;
// Draw vector and outline
ColorRgba areaColor = target.State.ColorTint * this.Color;
ColorRgba outlineColor = areaColor * ColorRgba.Black;
target.State.ColorTint = areaColor;
target.FillPolygon(
connection,
originPos.X,
originPos.Y,
originPos.Z);
if (target.DrawDevice.DepthWrite) target.State.ZOffset -= 0.1f;
target.State.ColorTint = outlineColor;
target.FillPolygonOutline(
connection,
borderRadius,
originPos.X,
originPos.Y,
originPos.Z);
// Draw connection points and outline
if (target.DrawDevice.DepthWrite) target.State.ZOffset -= 0.1f;
target.State.ColorTint = areaColor;
target.FillCircle(
originPos.X,
originPos.Y,
originPos.Z,
originRadius - borderRadius * 0.5f);
target.FillCircle(
targetPos.X,
targetPos.Y,
targetPos.Z,
originRadius - borderRadius * 0.5f);
if (target.DrawDevice.DepthWrite) target.State.ZOffset -= 0.1f;
target.State.ColorTint = outlineColor;
target.FillCircleSegment(
originPos.X,
originPos.Y,
originPos.Z,
originRadius,
0.0f,
MathF.RadAngle360,
borderRadius);
target.FillCircleSegment(
targetPos.X,
targetPos.Y,
targetPos.Z,
originRadius,
0.0f,
MathF.RadAngle360,
borderRadius);
}
示例5: DrawShapeOutline
private void DrawShapeOutline(Canvas canvas, Transform transform, CircleShapeInfo shape)
{
Vector3 pos = transform.Pos;
float angle = transform.Angle;
float scale = transform.Scale;
if (this.wrapTexture)
{
canvas.State.TextureCoordinateRect = new Rect(
shape.Radius * 2.0f / canvas.State.TextureBaseSize.X,
shape.Radius * 2.0f / canvas.State.TextureBaseSize.Y);
}
canvas.State.TransformScale = new Vector2(scale, scale);
canvas.State.TransformAngle = angle;
canvas.State.TransformHandle = -shape.Position;
canvas.FillCircleSegment(
pos.X,
pos.Y,
pos.Z,
shape.Radius,
0.0f,
MathF.RadAngle360,
this.outlineWidth);
}
示例6: Draw
public override void Draw(Canvas target, Vector3 basePos, float baseRotation, float baseScale)
{
float originRadius = 5.0f;
float vectorThickness = 4.0f;
float borderRadius = DefaultOutlineWidth;
float vectorLengthFactor = 1.0f;
// Scale anti-proportional to perspective scale in order to keep a constant size
// in screen space even when actually drawing in world space.
{
float scale = 1.0f;
Vector3 posTemp = this.origin + basePos;
target.DrawDevice.PreprocessCoords(ref posTemp, ref scale);
originRadius /= scale;
borderRadius /= scale;
vectorThickness /= scale;
if (this.invariantScale) vectorLengthFactor /= scale;
}
// Determine base and target positions
Vector3 originPos = this.origin;
Vector3 targetPos = this.origin + new Vector3(this.vec * vectorLengthFactor);
MathF.TransformCoord(ref originPos.X, ref originPos.Y, baseRotation, baseScale);
MathF.TransformCoord(ref targetPos.X, ref targetPos.Y, baseRotation, baseScale);
originPos += basePos;
targetPos += basePos;
// Downscale vector arrow, if too small for display otherwise
float vectorLen = (targetPos.Xy - originPos.Xy).Length;
float vectorLenScale = MathF.Clamp(vectorLen / (vectorThickness * 7.0f), 0.0f, 1.0f);
vectorThickness *= vectorLenScale;
// Create arrow polygon
Vector2 dirForward = (targetPos.Xy - originPos.Xy).Normalized;
Vector2 dirLeft = dirForward.PerpendicularLeft;
Vector2 dirRight = -dirLeft;
Vector2[] arrow = new Vector2[7];
arrow[0] = dirLeft * vectorThickness * 0.5f;
arrow[1] = dirLeft * vectorThickness * 0.5f + dirForward * (vectorLen - vectorThickness * 2);
arrow[2] = dirLeft * vectorThickness * 1.25f + dirForward * (vectorLen - vectorThickness * 2);
arrow[3] = dirForward * vectorLen;
arrow[4] = dirRight * vectorThickness * 1.25f + dirForward * (vectorLen - vectorThickness * 2);
arrow[5] = dirRight * vectorThickness * 0.5f + dirForward * (vectorLen - vectorThickness * 2);
arrow[6] = dirRight * vectorThickness * 0.5f;
Vector2[] arrowHead = new Vector2[3];
arrowHead[0] = arrow[2];
arrowHead[1] = arrow[3];
arrowHead[2] = arrow[4];
Vector2[] arrowLine = new Vector2[4];
arrowLine[0] = arrow[0];
arrowLine[1] = arrow[1];
arrowLine[2] = arrow[5];
arrowLine[3] = arrow[6];
// Draw vector and outline
ColorRgba areaColor = target.State.ColorTint * this.Color;
ColorRgba outlineColor = areaColor * ColorRgba.Black;
target.State.ColorTint = areaColor;
target.FillPolygon(
arrowLine,
originPos.X,
originPos.Y,
originPos.Z);
target.FillPolygon(
arrowHead,
originPos.X,
originPos.Y,
originPos.Z);
if (target.DrawDevice.DepthWrite) target.State.ZOffset -= 0.1f;
target.State.ColorTint = outlineColor;
target.FillPolygonOutline(
arrow,
borderRadius,
originPos.X,
originPos.Y,
originPos.Z);
// Draw origin and outline
if (target.DrawDevice.DepthWrite) target.State.ZOffset -= 0.1f;
target.State.ColorTint = areaColor;
target.FillCircle(
originPos.X,
originPos.Y,
originPos.Z,
originRadius - borderRadius * 0.5f);
if (target.DrawDevice.DepthWrite) target.State.ZOffset -= 0.1f;
target.State.ColorTint = outlineColor;
target.FillCircleSegment(
originPos.X,
originPos.Y,
originPos.Z,
originRadius,
0.0f,
MathF.RadAngle360,
borderRadius);
}