本文整理汇总了C#中Canvas.FillPolygonOutline方法的典型用法代码示例。如果您正苦于以下问题:C# Canvas.FillPolygonOutline方法的具体用法?C# Canvas.FillPolygonOutline怎么用?C# Canvas.FillPolygonOutline使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Canvas
的用法示例。
在下文中一共展示了Canvas.FillPolygonOutline方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(Canvas target, Vector3 basePos, float baseRotation, float baseScale)
{
float borderRadius = DefaultOutlineWidth;
float polyScale = 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.pos + basePos;
target.DrawDevice.PreprocessCoords(ref posTemp, ref scale);
borderRadius /= scale;
if (this.invariantScale) polyScale /= scale;
}
// Determine base position
Vector3 circlePos = this.pos;
MathF.TransformCoord(ref circlePos.X, ref circlePos.Y, baseRotation, baseScale);
circlePos += basePos;
// Draw polygon and outline
target.State.ColorTint *= this.Color;
target.State.TransformAngle = baseRotation;
target.State.TransformScale = new Vector2(baseScale, baseScale) * polyScale;
target.FillPolygon(
this.vertices,
circlePos.X,
circlePos.Y,
circlePos.Z);
if (target.DrawDevice.DepthWrite) target.State.ZOffset -= 0.1f;
target.State.ColorTint *= ColorRgba.Black;
target.FillPolygonOutline(
this.vertices,
borderRadius / polyScale,
circlePos.X,
circlePos.Y,
circlePos.Z);
}
示例2: 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);
}
示例3: DrawShapeOutline
private void DrawShapeOutline(Canvas canvas, Transform transform, LoopShapeInfo shape)
{
Vector3 pos = transform.Pos;
float angle = transform.Angle;
float scale = transform.Scale;
if (this.wrapTexture)
{
Rect pointBoundingRect = shape.Vertices.BoundingBox();
canvas.State.TextureCoordinateRect = new Rect(
pointBoundingRect.W / canvas.State.TextureBaseSize.X,
pointBoundingRect.H / canvas.State.TextureBaseSize.Y);
}
canvas.State.TransformAngle = angle;
canvas.State.TransformScale = new Vector2(scale, scale);
canvas.FillPolygonOutline(shape.Vertices, this.outlineWidth, pos.X, pos.Y, pos.Z);
}
示例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;
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);
}