本文整理汇总了C#中Microsoft.Graphics.Canvas.CanvasDrawingSession.DrawGeometry方法的典型用法代码示例。如果您正苦于以下问题:C# CanvasDrawingSession.DrawGeometry方法的具体用法?C# CanvasDrawingSession.DrawGeometry怎么用?C# CanvasDrawingSession.DrawGeometry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Graphics.Canvas.CanvasDrawingSession
的用法示例。
在下文中一共展示了CanvasDrawingSession.DrawGeometry方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawDryInk_GeometryMethod
private void DrawDryInk_GeometryMethod(CanvasDrawingSession ds, IReadOnlyList<InkStroke> strokes)
{
//
// This converts the ink strokes to geometry, then draws the geometry outline
// with a dotted stroke style.
//
var strokeStyle = new CanvasStrokeStyle { DashStyle = CanvasDashStyle.Dot };
var strokesGroupedByColor = from stroke in strokes
group stroke by stroke.DrawingAttributes.Color into strokesOfColor
select strokesOfColor;
foreach (var strokesOfColor in strokesGroupedByColor)
{
var geometry = CanvasGeometry.CreateInk(ds, strokesOfColor.ToList()).Outline();
ds.DrawGeometry(geometry, strokesOfColor.Key, 1, strokeStyle);
}
}
示例2: DrawTriangle
private void DrawTriangle(CanvasControl sender, CanvasDrawingSession ds)
{
var width = (float) sender.ActualWidth;
var height = (float) sender.ActualHeight;
var stroke = this.defaultStroke;
var center = new Vector2(width / 2, height / 2);
var scale = (width / 2) - (stroke * 2);
var triangleGeometry = CreateTriangleGeometry(sender, scale, center);
ds.FillGeometry(triangleGeometry, ForegroundColor);
ds.DrawGeometry(triangleGeometry, GlowColor, stroke);
}
示例3: DrawSelectionLasso
private void DrawSelectionLasso(CanvasControl sender, CanvasDrawingSession ds)
{
if (selectionPolylinePoints == null) return;
if (selectionPolylinePoints.Count == 0) return;
CanvasPathBuilder selectionLasso = new CanvasPathBuilder(canvasControl);
selectionLasso.BeginFigure(selectionPolylinePoints[0].ToVector2());
for (int i = 1; i < selectionPolylinePoints.Count; ++i)
{
selectionLasso.AddLine(selectionPolylinePoints[i].ToVector2());
}
selectionLasso.EndFigure(CanvasFigureLoop.Open);
CanvasGeometry pathGeometry = CanvasGeometry.CreatePath(selectionLasso);
ds.DrawGeometry(pathGeometry, Colors.Magenta, 5.0f);
}
示例4: DrawBezier
void DrawBezier(CanvasDrawingSession drawingSession, Vector2 start, Vector2 ctrl0, Vector2 ctrl1, Vector2 end)
{
CanvasPathBuilder pathBuilder = new CanvasPathBuilder(canvasControl);
pathBuilder.BeginFigure(start);
pathBuilder.AddCubicBezier(ctrl0, ctrl1, end);
pathBuilder.EndFigure(CanvasFigureLoop.Open);
CanvasGeometry geometry = CanvasGeometry.CreatePath(pathBuilder);
drawingSession.DrawGeometry(geometry, Colors.White, 5.0f);
}
示例5: DrawHeart
private void DrawHeart(CanvasControl sender, CanvasDrawingSession ds)
{
var width = (float) sender.ActualWidth;
var height = (float) sender.ActualHeight;
var stroke = this.defaultStroke / 2;
var scale = Math.Min(width,height) / 2 - stroke;
var center = new Vector2(width / 2 , height / 2);
var heartGeometry = CreateHeart(sender, scale, center);
ds.FillGeometry(heartGeometry, ForegroundColor);
ds.DrawGeometry(heartGeometry, GlowColor, stroke);
}
示例6: DrawContactGeometry
static void DrawContactGeometry(CanvasDrawingSession ds, CanvasGeometry geom)
{
if (geom == null)
return;
ds.FillGeometry(geom, Colors.Green);
ds.DrawGeometry(geom, Colors.Blue, 5);
}
示例7: Draw
public void Draw(ICanvasAnimatedControl sender, CanvasTimingInformation timingInformation, CanvasDrawingSession ds)
{
ds.DrawCachedGeometry(clockFaceCachedFill, backgroundBrush);
double fractionSecond;
int seconds;
if (sender.IsFixedTimeStep)
{
double updatesPerSecond = 1000.0 / sender.TargetElapsedTime.TotalMilliseconds;
seconds = (int)((timingInformation.UpdateCount / updatesPerSecond) % 10);
double updates = (double)timingInformation.UpdateCount;
fractionSecond = (updates / updatesPerSecond) % 1.0;
}
else
{
double totalMilliseconds = timingInformation.TotalTime.TotalMilliseconds;
double millisecondsThisIteration = totalMilliseconds % 1000;
fractionSecond = millisecondsThisIteration / 1000.0f;
seconds = (int)timingInformation.TotalTime.TotalSeconds % 10;
}
hueRotationEffect.Angle = (float)Math.PI * (seconds / 10.0f) * 2.0f;
using (var timeSegmentGeometry = CreateTimeSegmentGeometry(ds, fractionSecond))
{
ds.FillGeometry(timeSegmentGeometry, foregroundBrush);
DrawSecondsText(ds, new Vector2(center), seconds);
ds.DrawGeometry(timeSegmentGeometry, Colors.White, 1, hairlineStrokeStyle);
}
ds.DrawCachedGeometry(clockFaceCachedStroke18, Colors.White);
ds.DrawCachedGeometry(clockFaceCachedStroke16, Colors.Black);
}
示例8: DisplayRegionEditInProgress
public void DisplayRegionEditInProgress(CanvasDrawingSession drawingSession, List<Vector2> points, float zoomFactor)
{
if (RegionSelectionMode == SelectionMode.MagicWand)
{
// Display a magic wand selection.
var mask = GetMagicWandMask(points, zoomFactor);
var border = GetSelectionBorder(mask, zoomFactor);
drawingSession.Blend = CanvasBlend.Add;
drawingSession.DrawImage(mask, Vector2.Zero, SourceBitmap.Bounds, 0.25f);
drawingSession.Blend = CanvasBlend.SourceOver;
drawingSession.DrawImage(border);
}
else
{
// Display a geometric shape selection.
var geometry = GetSelectionGeometry(drawingSession, points);
drawingSession.Blend = CanvasBlend.Add;
drawingSession.FillGeometry(geometry, Color.FromArgb(0x20, 0xFF, 0xFF, 0xFF));
drawingSession.Blend = CanvasBlend.SourceOver;
drawingSession.DrawGeometry(geometry, Colors.Magenta, 1f / zoomFactor);
}
}
示例9: DrawDryInk_CustomGeometryMethod
private void DrawDryInk_CustomGeometryMethod(CanvasDrawingSession ds, IReadOnlyList<InkStroke> strokes)
{
//
// This shows off the fact that apps can use the custom drying path
// to render dry ink using Win2D, and not necessarily
// rely on the built-in rendering in CanvasDrawingSession.DrawInk.
//
foreach (var stroke in strokes)
{
var color = stroke.DrawingAttributes.Color;
var inkPoints = stroke.GetInkPoints();
if (inkPoints.Count > 0)
{
CanvasPathBuilder pathBuilder = new CanvasPathBuilder(canvasControl);
pathBuilder.BeginFigure(inkPoints[0].Position.ToVector2());
for (int i = 1; i < inkPoints.Count; i++)
{
pathBuilder.AddLine(inkPoints[i].Position.ToVector2());
ds.DrawCircle(inkPoints[i].Position.ToVector2(), 3, color);
}
pathBuilder.EndFigure(CanvasFigureLoop.Open);
CanvasGeometry geometry = CanvasGeometry.CreatePath(pathBuilder);
ds.DrawGeometry(geometry, color);
}
}
}
示例10: DrawDryInk_GeometryMethod
private void DrawDryInk_GeometryMethod(CanvasDrawingSession ds, IReadOnlyList<InkStroke> strokes)
{
//
// This converts the ink strokes to geometry, then draws the geometry outline
// with a dotted stroke style.
//
var strokeStyle = new CanvasStrokeStyle { DashStyle = CanvasDashStyle.Dot };
var strokesGroupedByColor = from stroke in strokes
where !IsPencilStroke(stroke)
group stroke by stroke.DrawingAttributes.Color into strokesOfColor
select strokesOfColor;
foreach (var strokesOfColor in strokesGroupedByColor)
{
var geometry = CanvasGeometry.CreateInk(ds, strokesOfColor.ToList()).Outline();
ds.DrawGeometry(geometry, strokesOfColor.Key, 1, strokeStyle);
}
// Display text labels in place of any pencil strokes, because we cannot create geometry for those.
foreach (var pencilStroke in strokes.Where(IsPencilStroke))
{
ds.DrawText("CanvasGeometry.CreateInk does not support pencil strokes",
pencilStroke.BoundingRect,
pencilStroke.DrawingAttributes.Color,
centerTextFormat);
}
}
示例11: Draw
public void Draw(ICanvasAnimatedControl sender, CanvasDrawingSession drawingSession)
{
if (currentThunder == null)
{
return;
}
// 保护原先画布的混合模式
var previousBlend = drawingSession.Blend;
drawingSession.Blend = blendState;
var builder = new CanvasPathBuilder(sender);
builder.BeginFigure(0, 0);
for (int i = 0; i < currentThunder.LifeLong; i++)
{
builder.AddLine(currentThunder.Path[i].X, currentThunder.Path[i].Y);
}
builder.EndFigure(CanvasFigureLoop.Open);
builder.SetSegmentOptions(CanvasFigureSegmentOptions.ForceRoundLineJoin);
// Draw the particle.
var path = CanvasGeometry.CreatePath(builder);
var NormalizeLifeTime = currentThunder.TimeSinceStart / currentThunder.Duration;
byte opacity = (byte)((NormalizeLifeTime - 1) * (NormalizeLifeTime - 1) * 255);
CanvasCommandList cl = new CanvasCommandList(sender);
using (CanvasDrawingSession clds = cl.CreateDrawingSession())
{
clds.DrawGeometry(path, currentThunder.Position, Color.FromArgb((byte)(0.75f * opacity), 255, 255, 255), 6 * currentThunder.Luminace);
}
var lightAmount = 20.6f * currentThunder.Luminace * (NormalizeLifeTime - 1) * (NormalizeLifeTime - 1);
blur.Source = cl;
blur.BlurAmount = lightAmount;
drawingSession.DrawImage(blur);
drawingSession.DrawGeometry(path, currentThunder.Position, Color.FromArgb(opacity, 255, 240, 180), 2 * currentThunder.Luminace);
drawingSession.Blend = previousBlend;
if (NormalizeLifeTime > 1)
{
currentThunder = null;
}
}
示例12: drawDOMArrow
private static void drawDOMArrow(ICanvasResourceCreator device, CanvasDrawingSession ds, Point[] domPoints)
{
// Pen pen = new Pen(Color.Black, 3f);
//pen.MiterLimit = 3;
CanvasPathBuilder domPath = new CanvasPathBuilder(device);
CanvasPathBuilder domArrow = new CanvasPathBuilder(device);
if (domPoints[1].X == 0 && domPoints[1].Y == 0)
{
domPath.BeginFigure(domPoints[0].ToVector2());
domPath.AddLine(domPoints[2].ToVector2());
domPath.EndFigure(CanvasFigureLoop.Open);
}
else
{
domPath.BeginFigure(domPoints[0].ToVector2());
domPath.AddLine(domPoints[1].ToVector2());
domPath.AddLine(domPoints[2].ToVector2());
domPath.EndFigure(CanvasFigureLoop.Open);
}
domArrow.BeginFigure(domPoints[3].ToVector2());
domArrow.AddLine(domPoints[4].ToVector2());
domArrow.AddLine(domPoints[5].ToVector2());
domArrow.EndFigure(CanvasFigureLoop.Closed);
CanvasGeometry cgPath = CanvasGeometry.CreatePath(domPath);
CanvasGeometry cgArrow = CanvasGeometry.CreatePath(domArrow);
ds.DrawGeometry(cgPath, Colors.Black,3f);
ds.FillGeometry(cgArrow, Colors.Black);
}