private void DrawLine(CanvasControl sender, CanvasDrawingSession ds) { var width = (float)sender.ActualWidth; var height = (float)sender.ActualHeight; var middle = height / 2; int steps = Math.Min((int)(width / 10), 30); for (int i = 0; i < steps; ++i) { var mu = (float)i / steps; var a = (float)(mu * Math.PI * 2); var color = GradientColor(mu); var x = width * mu; var y = (float)(middle + Math.Sin(a) * (middle * 0.3)); var strokeWidth = (float)(Math.Cos(a) + 1) * 5; ds.DrawLine(x, 0, x, y, color, strokeWidth); ds.DrawLine(x, height, x, y, color, 10 - strokeWidth); } }
private void DrawCanvasState(CanvasControl canvas, CanvasDrawingSession ds, int drawCount) { ds.Clear(Color.FromArgb(0, 0, 0, 0)); ds.DrawLine(0, 0, (float)canvas.ActualWidth, (float)canvas.ActualHeight, Colors.Aqua); ds.DrawLine(0, (float)canvas.ActualHeight, (float)canvas.ActualWidth, 0, Colors.Aqua); var text = String.Format("{0}x{1}\n{2} redraws", (int)canvas.ActualWidth, (int)canvas.ActualHeight, drawCount); ds.DrawText( text, 0, 0, Colors.FloralWhite, new CanvasTextFormat() { VerticalAlignment = CanvasVerticalAlignment.Top, ParagraphAlignment = ParagraphAlignment.Left, FontSize = 10 }); }
void DrawControlLines(CanvasDrawingSession drawingSession) { CanvasGradientMeshPatch[] patches = gradientMesh.Patches; for (int i=0; i<patchPoints.Count; ++i) { var pointArray = patchPoints[i]; foreach (Vector2 point in pointArray) { drawingSession.FillCircle(point, 7, Colors.White); } CanvasGradientMeshPatch patch = patches[i]; bool showInterior = patchPoints[i].Length == 16; DrawBezier(drawingSession, patch.Point00, patch.Point01, patch.Point02, patch.Point03); DrawBezier(drawingSession, patch.Point03, patch.Point13, patch.Point23, patch.Point33); DrawBezier(drawingSession, patch.Point00, patch.Point10, patch.Point20, patch.Point30); DrawBezier(drawingSession, patch.Point30, patch.Point31, patch.Point32, patch.Point33); if (showInterior) { DrawBezier(drawingSession, patch.Point10, patch.Point11, patch.Point12, patch.Point13); DrawBezier(drawingSession, patch.Point20, patch.Point21, patch.Point22, patch.Point23); DrawBezier(drawingSession, patch.Point01, patch.Point11, patch.Point21, patch.Point31); DrawBezier(drawingSession, patch.Point02, patch.Point12, patch.Point22, patch.Point32); } drawingSession.DrawLine(patch.Point00, patch.Point01, Colors.White); drawingSession.DrawLine(patch.Point02, patch.Point03, Colors.White); drawingSession.DrawLine(patch.Point03, patch.Point13, Colors.White); drawingSession.DrawLine(patch.Point23, patch.Point33, Colors.White); drawingSession.DrawLine(patch.Point33, patch.Point32, Colors.White); drawingSession.DrawLine(patch.Point31, patch.Point30, Colors.White); drawingSession.DrawLine(patch.Point30, patch.Point20, Colors.White); drawingSession.DrawLine(patch.Point10, patch.Point00, Colors.White); if (showInterior) { drawingSession.DrawLine(patch.Point01, patch.Point11, Colors.White); drawingSession.DrawLine(patch.Point21, patch.Point31, Colors.White); drawingSession.DrawLine(patch.Point02, patch.Point12, Colors.White); drawingSession.DrawLine(patch.Point22, patch.Point32, Colors.White); drawingSession.DrawLine(patch.Point10, patch.Point11, Colors.White); drawingSession.DrawLine(patch.Point12, patch.Point13, Colors.White); drawingSession.DrawLine(patch.Point20, patch.Point21, Colors.White); drawingSession.DrawLine(patch.Point22, patch.Point23, Colors.White); } } }
public void Draw(CanvasDrawingSession ds) { int pointerPointIndex = 0; Vector2 prev = new Vector2(0, 0); const float penRadius = 10; foreach (Vector2 p in points) { if (pointerPointIndex != 0) { ds.DrawLine(prev, p, Colors.DarkRed, penRadius * 2); } ds.FillEllipse(p, penRadius, penRadius, Colors.DarkRed); prev = p; pointerPointIndex++; } if (points.Count > 0) points.Dequeue(); }
public void Draw(CanvasAnimatedDrawEventArgs args, CanvasDrawingSession ds, float width, float height) { drawCount++; const int maxEntries = 120; updatesPerDraw.Enqueue(updatesThisDraw); while (updatesPerDraw.Count > maxEntries) updatesPerDraw.Dequeue(); ds.Antialiasing = CanvasAntialiasing.Aliased; var barWidth = width / (float)maxEntries; const float heightPerUpdate = 10.0f; float barBottom = height * 0.25f; int maxUpdates = 0; int maxIndex = -1; int index = 0; foreach (int update in updatesPerDraw) { float barHeight = update * heightPerUpdate; Color color = Colors.Gray; if ((Math.Max(0, drawCount - maxEntries) + index) % 60 == 0) color = Colors.White; ds.FillRectangle(barWidth * index, height - barHeight - barBottom, barWidth, barHeight + barBottom, color); if (update > maxUpdates) { maxIndex = index; maxUpdates = update; } index++; } if (maxUpdates > 0) { var y = height - maxUpdates * heightPerUpdate - barBottom; ds.DrawLine(0, y, width, y, Colors.White, 1, maxStroke); ds.DrawText( maxUpdates.ToString(), 0, height - maxUpdates * heightPerUpdate - barBottom, Colors.White, new CanvasTextFormat() { FontSize = heightPerUpdate * 2, HorizontalAlignment = CanvasHorizontalAlignment.Left, VerticalAlignment = CanvasVerticalAlignment.Bottom }); } using (var textFormat = new CanvasTextFormat() { FontSize = width * 0.05f, HorizontalAlignment = CanvasHorizontalAlignment.Left, VerticalAlignment = CanvasVerticalAlignment.Top }) { float y = 1; ds.DrawText("Updates per Draw", 1, y, Colors.White, textFormat); y += textFormat.FontSize * 2; textFormat.FontSize *= 0.6f; ds.DrawText(string.Format("{0} total updates", args.Timing.UpdateCount), 1, y, Colors.Red, textFormat); y += textFormat.FontSize * 1.2f; ds.DrawText(string.Format("{0} total draws", drawCount), 1, y, Colors.Green, textFormat); } updatesThisDraw = 0; }
private void DrawAxes(CanvasDrawingSession ds) { ds.DrawLine(origin, xAxisEnd, Colors.White, 1); ds.DrawLine(origin, yAxisEnd, Colors.White, 1); for (int i = 0; i <= 9; ++i) { float y = (maxYValue / 9.0f) * (float)i; ds.DrawText(string.Format("{0}", (int)y), new Vector2(origin.X - 5, GetY(y)), Colors.White, axisFormat); } axisFormat.VerticalAlignment = CanvasVerticalAlignment.Top; for (int i = 0; i <= 9; ++i) { float x = (maxXValue / 9.0f) * (float)i; ds.DrawText(string.Format("{0}", (int)x), new Vector2(GetX(x), origin.Y), Colors.White, axisFormat); } }
private void DrawPaths(CanvasDrawingSession ds, ProtoRoom[,] roomList, int x, int y, Color color) { float fStrokeWidth = 5; foreach (string DirectionalRoomConnection in roomList[x, y].DirectionalRoomConnections.Keys) { switch (DirectionalRoomConnection) { case "nw": ds.DrawLine((x + 0.5f) * Statics.MapResolution, (y + 0.5f) * Statics.MapResolution, ((x - 1) + 0.5f) * Statics.MapResolution, ((y - 1) + 0.5f) * Statics.MapResolution, color, fStrokeWidth); break; case "n": ds.DrawLine((x + 0.5f) * Statics.MapResolution, (y + 0.5f) * Statics.MapResolution, (x + 0.5f) * Statics.MapResolution, ((y - 1) + 0.5f) * Statics.MapResolution, color, fStrokeWidth); break; case "ne": ds.DrawLine((x + 0.5f) * Statics.MapResolution, (y + 0.5f) * Statics.MapResolution, ((x + 1) + 0.5f) * Statics.MapResolution, ((y - 1) + 0.5f) * Statics.MapResolution, color, fStrokeWidth); break; case "w": ds.DrawLine((x + 0.5f) * Statics.MapResolution, (y + 0.5f) * Statics.MapResolution, ((x - 1) + 0.5f) * Statics.MapResolution, (y + 0.5f) * Statics.MapResolution, color, fStrokeWidth); break; case "o": break; case "e": ds.DrawLine((x + 0.5f) * Statics.MapResolution, (y + 0.5f) * Statics.MapResolution, ((x + 1) + 0.5f) * Statics.MapResolution, (y + 0.5f) * Statics.MapResolution, color, fStrokeWidth); break; case "sw": ds.DrawLine((x + 0.5f) * Statics.MapResolution, (y + 0.5f) * Statics.MapResolution, ((x - 1) + 0.5f) * Statics.MapResolution, ((y + 1) + 0.5f) * Statics.MapResolution, color, fStrokeWidth); break; case "s": ds.DrawLine((x + 0.5f) * Statics.MapResolution, (y + 0.5f) * Statics.MapResolution, (x + 0.5f) * Statics.MapResolution, ((y + 1) + 0.5f) * Statics.MapResolution, color, fStrokeWidth); break; case "se": ds.DrawLine((x + 0.5f) * Statics.MapResolution, (y + 0.5f) * Statics.MapResolution, ((x + 1) + 0.5f) * Statics.MapResolution, ((y + 1) + 0.5f) * Statics.MapResolution, color, fStrokeWidth); break; default: throw new Exception(); } } }
private void DrawLine(CanvasControl sender, CanvasDrawingSession ds) { var width = (float) sender.ActualWidth; var height = (float) sender.ActualHeight; var rnd = Utils.GetRandomBoolean(); var stroke = this.defaultStroke; if(rnd) ds.DrawLine(0, 0, width - stroke, height - stroke, ForegroundColor, stroke); else ds.DrawLine(0, height - stroke, width - stroke, 0, ForegroundColor, stroke); }
//Drawn the background horizontal lines private void DrawGraphValueLines(CanvasDrawingSession ds, float width, float height) { var tickOffsetY = height / DEFAULT_GRADIENTS; float currentOffsetY = 0; for (int i = 0; i < (DEFAULT_GRADIENTS + 1); i++) { float x0 = 0; float y0 = currentOffsetY; float x1 = width; float y1 = currentOffsetY; ds.DrawLine(x0, y0, x1, y1, LINES_COLOR); // add CanvasStrokeStyle currentOffsetY += tickOffsetY; } }
void DrawStuff(CanvasDrawingSession ds) { int horizontalLimit = (int)m_canvasControl.ActualWidth; int verticalLimit = (int)m_canvasControl.ActualHeight; const float thickStrokeWidth = 80.0f; DrawnContentType drawnContentType = (DrawnContentType)m_drawnContentTypeCombo.SelectedValue; ds.Clear(NextRandomColor()); Rect rect; Vector2 point; float radiusX; float radiusY; switch (drawnContentType) { case DrawnContentType.Clear_Only: break; case DrawnContentType.Bitmap: if (m_bitmap_tiger != null) { ds.DrawImage(m_bitmap_tiger, NextRandomPoint(horizontalLimit, verticalLimit).ToVector2()); } else { DrawNoBitmapErrorMessage(ds, horizontalLimit / 2, verticalLimit / 2); } break; case DrawnContentType.Effect_Blur: if (m_bitmap_tiger != null) { GaussianBlurEffect blurEffect = new GaussianBlurEffect(); blurEffect.StandardDeviation = 2.0f; blurEffect.Source = m_bitmap_tiger; ds.DrawImage(blurEffect, NextRandomPoint(horizontalLimit, verticalLimit).ToVector2()); } else { DrawNoBitmapErrorMessage(ds, horizontalLimit / 2, verticalLimit / 2); } break; case DrawnContentType.Line_Thin: ds.DrawLine( NextRandomPoint(horizontalLimit, verticalLimit).ToVector2(), NextRandomPoint(horizontalLimit, verticalLimit).ToVector2(), NextRandomColor()); break; case DrawnContentType.Line_Thick: ds.DrawLine( NextRandomPoint(horizontalLimit, verticalLimit).ToVector2(), NextRandomPoint(horizontalLimit, verticalLimit).ToVector2(), NextRandomColor(), thickStrokeWidth); break; case DrawnContentType.Rectangle_Thin: ds.DrawRectangle( NextRandomRect(horizontalLimit, verticalLimit), NextRandomColor()); break; case DrawnContentType.Rectangle_Thick: ds.DrawRectangle( NextRandomRect(horizontalLimit, verticalLimit), NextRandomColor(), thickStrokeWidth); break; case DrawnContentType.Rectangle_Filled: ds.FillRectangle( NextRandomRect(horizontalLimit, verticalLimit), NextRandomColor()); break; case DrawnContentType.RoundedRectangle_Thin: NextRandomRoundedRect(horizontalLimit, verticalLimit, out rect, out radiusX, out radiusY); ds.DrawRoundedRectangle( rect, radiusX, radiusY, NextRandomColor()); break; case DrawnContentType.RoundedRectangle_Thick: NextRandomRoundedRect(horizontalLimit, verticalLimit, out rect, out radiusX, out radiusY); ds.DrawRoundedRectangle( rect, radiusX, radiusY, NextRandomColor(), thickStrokeWidth); break; case DrawnContentType.Ellipse_Thin: NextRandomEllipse(horizontalLimit, verticalLimit, out point, out radiusX, out radiusY); ds.DrawEllipse( point, radiusX, radiusY, NextRandomColor()); break; case DrawnContentType.Ellipse_Thick: NextRandomEllipse(horizontalLimit, verticalLimit, out point, out radiusX, out radiusY); ds.DrawEllipse( point, radiusX, radiusY, NextRandomColor(), thickStrokeWidth); break; case DrawnContentType.Ellipse_Fill: NextRandomEllipse(horizontalLimit, verticalLimit, out point, out radiusX, out radiusY); ds.FillEllipse( point, radiusX, radiusY, NextRandomColor()); break; case DrawnContentType.Circle_Fill: ds.FillCircle( NextRandomPoint(horizontalLimit, verticalLimit).ToVector2(), 100, NextRandomColor()); break; case DrawnContentType.Dashed_Lines: DrawDashedLines(ds, NextRandomColor(), horizontalLimit, verticalLimit); break; case DrawnContentType.Text: var p = NextRandomPoint(horizontalLimit, verticalLimit); var x = (float)p.X; var y = (float)p.Y; var color = NextRandomColor(); ds.DrawLine(new Vector2(x, 0), new Vector2(x, verticalLimit), color); ds.DrawLine(new Vector2(0, y), new Vector2(horizontalLimit, y), color); ds.DrawText( "Centered", p.ToVector2(), color, new CanvasTextFormat() { FontSize = 18, VerticalAlignment = CanvasVerticalAlignment.Center, ParagraphAlignment = ParagraphAlignment.Center }); var r = NextRandomRect(horizontalLimit, verticalLimit); ds.DrawRectangle(r, color); ds.DrawText( m_quiteLongText, r, NextRandomColor(), new CanvasTextFormat() { FontFamily = "Comic Sans MS", FontSize = 18, ParagraphAlignment = ParagraphAlignment.Justify, Options = CanvasDrawTextOptions.Clip }); break; case DrawnContentType.ImageBrush: if (m_bitmap_tiger != null) { m_imageBrush.Image = m_bitmap_tiger; m_imageBrush.ExtendX = (CanvasEdgeBehavior)(m_random.Next(3)); m_imageBrush.ExtendY = (CanvasEdgeBehavior)(m_random.Next(3)); ds.FillRectangle(new Rect(0, 0, horizontalLimit, verticalLimit), m_imageBrush); } else DrawNoBitmapErrorMessage(ds, horizontalLimit / 2, verticalLimit / 2); break; case DrawnContentType.Test_Scene0_Default: GeometryTestScene0.DrawGeometryTestScene(ds, TestSceneRenderingType.Default); break; case DrawnContentType.Test_Scene0_Wireframe: GeometryTestScene0.DrawGeometryTestScene(ds, TestSceneRenderingType.Wireframe); break; case DrawnContentType.Test_Scene1_Default: GeometryTestScene1.DrawGeometryTestScene(ds, TestSceneRenderingType.Default); break; case DrawnContentType.Test_Scene1_Randomized: GeometryTestScene1.DrawGeometryTestScene(ds, TestSceneRenderingType.Randomized); break; case DrawnContentType.Test_Scene1_Wireframe: GeometryTestScene1.DrawGeometryTestScene(ds, TestSceneRenderingType.Wireframe); break; default: System.Diagnostics.Debug.Assert(false); // Unexpected break; } }
void DrawDashedLines( CanvasDrawingSession ds, Color color, int horizontalLimit, int verticalLimit) { CanvasStrokeStyle strokeStyle = new CanvasStrokeStyle(); strokeStyle.DashStyle = CanvasDashStyle.Dash; for (int i = 0; i < 100; i++) { ds.DrawLine( NextRandomPoint(horizontalLimit, verticalLimit).ToVector2(), NextRandomPoint(horizontalLimit, verticalLimit).ToVector2(), color, 5.0f, strokeStyle); } }
private void DrawBackground(CanvasDrawingSession ds, Matrix3x2 transform) { const int levelUpTime = 60; // After levelling up we flash the screen white for a bit Color normalColor = Colors.Blue; Color levelUpFlashColor = Colors.White; var flashAmount = Math.Min(1, (leveledUpTimer / (float)levelUpTime)); ds.Clear(InterpolateColors(normalColor, levelUpFlashColor, flashAmount)); var topLeft = Vector2.Transform(new Vector2(0, 0), transform); var bottomRight = Vector2.Transform(new Vector2(1, 1), transform); var middle = (bottomRight.X - topLeft.X) / 2 + topLeft.X; // and display some text to let the player know what happened if (leveledUpTimer < levelUpTime * 2) { ds.DrawText("Level Up!", middle, 0, Colors.White, levelUpFormat); } // Draw some lines to show where the top / bottom of the play area is. var topLine = topLeft.Y - Letter.TextFormat.FontSize; var bottomLine = bottomRight.Y + Letter.TextFormat.FontSize; Color lineColor = levelUpFlashColor; lineColor.A = 128; ds.DrawLine(0, topLine, bottomRight.X, topLine, lineColor, 3); ds.DrawLine(0, bottomLine, bottomRight.X, bottomLine, lineColor, 3); }
public void Draw(CanvasDrawingSession ds, float alpha = 1) { // Create a drop shadow by drawing a black circle with an offset position. const float dropShadowOffset = 4; ds.FillCircle(Position + new Vector2(dropShadowOffset), Radius, AdjustAlpha(Colors.Black, alpha)); // Draw a white X. const float crossWidth = 3; float crossSize = Radius * 0.8f; Vector2 cross1 = new Vector2(crossSize, crossSize); Vector2 cross2 = new Vector2(crossSize, -crossSize); ds.DrawLine(Position - cross1, Position + cross1, AdjustAlpha(Colors.White, alpha), crossWidth); ds.DrawLine(Position - cross2, Position + cross2, AdjustAlpha(Colors.White, alpha), crossWidth); // Fill the circle with its unique color. ds.FillCircle(Position, Radius, AdjustAlpha(color, alpha)); // White border around it. ds.DrawCircle(Position, Radius, AdjustAlpha(Colors.White, alpha)); // Text label. ds.DrawText(label, Position, AdjustAlpha(Colors.White, alpha), textFormat); }
public void DrawTicks(IBin[] bins, CanvasDrawingSession session, CanvasControl canvas) { if (LabelSize.Height == 0 || LabelSize.Width == 0) { return; } double barWidth = canvas.ActualWidth / bins.Length; double canvasWidth = canvas.ActualWidth; int labelFrequency = (int)Math.Ceiling((bins.Length - 1) / (canvasWidth / LabelSize.Width)); CanvasTextFormat labelFormat = new CanvasTextFormat(); labelFormat.WordWrapping = CanvasWordWrapping.NoWrap; labelFormat.FontSize = 12; double lastLabelRight = 0; for (int barIndex = 0; barIndex < bins.Length; barIndex++) { if (barIndex % labelFrequency != 0 && barIndex < bins.Length - 1) { continue; } Rect labelRect = new Rect(); Vector2 p1 = new Vector2(); Vector2 p2 = new Vector2(); bool show = false; if (barIndex == 0) { p1.X = (float)(barWidth / 2); labelRect.X = 0; labelFormat.HorizontalAlignment = CanvasHorizontalAlignment.Left; show = false; } else if (barIndex == bins.Length - 1) { p1.X = (float)(canvasWidth - barWidth / 2); labelRect.X = canvasWidth - LabelSize.Width; labelFormat.HorizontalAlignment = CanvasHorizontalAlignment.Right; show = false; } else { p1.X = (float)(barIndex * barWidth + (barWidth / 2)); labelRect.X = (barIndex * barWidth + (barWidth / 2)) - LabelSize.Width / 2; labelFormat.HorizontalAlignment = CanvasHorizontalAlignment.Center; show = true; } p1.Y = (float)(canvas.ActualHeight - LabelSize.Height); p2.Y = (float)(canvas.ActualHeight - LabelSize.Height + TickHeight); if (!show) { p2.Y += 4; } p2.X = p1.X; session.DrawLine(p1, p2, Colors.White); if (show) { IBin bin = bins[barIndex]; string label = bin.Label; labelRect.Width = LabelSize.Width; labelRect.Height = LabelSize.Height - TickHeight - 1; labelRect.Y = canvas.ActualHeight - LabelSize.Height + TickHeight + 1; if (labelRect.Right <= canvas.ActualWidth) { session.DrawText(label, labelRect, Colors.White, labelFormat); } } } }
public static void DrawBaseline(CanvasDrawingSession ds, Vector2 layoutSize, float baselineInWorldSpace) { ds.DrawLine(0, baselineInWorldSpace, layoutSize.X, baselineInWorldSpace, Colors.LightGreen, strokeWidth * 2, dashedStroke); ds.DrawText("baseline", 100, baselineInWorldSpace, Colors.LightGreen); }
void DrawLabel(CanvasDrawingSession ds, string text, float h1InEmSpace, float h2InEmSpace, Side whichSide, int tab) { // // The heights are offset from the baseline. // float h1 = baselineInWorldSpace + EmSpaceToWorldSpace(h1InEmSpace); float h2 = baselineInWorldSpace + EmSpaceToWorldSpace(h2InEmSpace); float midHeight = (h1 + h2) / 2; float amountPerTab = sizeDim / 7.0f; if (whichSide == Side.Left) { float margin = tab * amountPerTab; ds.DrawLine(margin, h1, margin, h2, color, strokeWidth); ds.DrawLine(margin, h1, horizontalMidpoint, h1, color, strokeWidth); ds.DrawLine(margin, h2, horizontalMidpoint, h2, color, strokeWidth); ds.DrawLine(margin - amountPerTab, midHeight, margin, midHeight, color, strokeWidth); ds.DrawText(text, margin, midHeight, color, rightJustifiedTextFormat); } else { float rMargin = layoutSize.X - (tab * amountPerTab); ds.DrawLine(rMargin, h1, rMargin, h2, color, strokeWidth); ds.DrawLine(rMargin, h1, horizontalMidpoint, h1, color, strokeWidth); ds.DrawLine(rMargin, h2, horizontalMidpoint, h2, color, strokeWidth); ds.DrawLine(rMargin + amountPerTab, midHeight, rMargin, midHeight, color, strokeWidth); ds.DrawText(text, rMargin, midHeight, color, leftJustifiedTextFormat); } NextLabel(); }
void DrawSourceGraphic(PerDeviceResources resources, CanvasDrawingSession ds, float offset) { var source = GetSourceBitmap(resources); if (source != null) { // We can either draw a precreated bitmap... ds.DrawImage(source, offset, offset); } else { // ... or directly draw some shapes. ds.FillRectangle(offset, offset, testSize, testSize, Colors.Gray); ds.DrawLine(offset, offset, offset + testSize, offset + testSize, Colors.Red); ds.DrawLine(offset + testSize, offset, offset, offset + testSize, Colors.Red); ds.DrawRectangle(offset + 0.5f, offset + 0.5f, testSize - 1, testSize - 1, Colors.Blue); ds.DrawText("DPI test", new Vector2(offset + testSize / 2), Colors.Blue, resources.TextFormat); resources.AddMessage("DrawingSession ->\n"); } }
private void DrawGrid(CanvasDrawingSession ds, Vector2 cellAcross, Vector2 cellDown, Vector2 topLeft) { var gridTopLeft = topLeft; var gridBottomRight = topLeft + cellAcross * columns + cellDown * rows; ds.DrawRectangle(new Rect(gridTopLeft.ToPoint(), gridBottomRight.ToPoint()), Colors.Black, 1); for (int row = 0; row <= rows; ++row) { ds.DrawLine(topLeft + cellDown * row, topLeft + cellAcross * columns + cellDown * row, Colors.Black, 1); } for (int column = 0; column <= columns; ++column) { ds.DrawLine(topLeft + cellAcross * column, topLeft + cellAcross * column + cellDown * rows, Colors.Black, 1); } }
private static void DrawLineInternal( CanvasDrawingSession ds, Color pen, CanvasStrokeStyle ss, bool isStroked, ref N.Vector2 p0, ref N.Vector2 p1, double strokeWidth) { if (isStroked) { ds.DrawLine(p0, p1, isStroked ? pen : Colors.Transparent, (float)strokeWidth, ss); } }
private void DrawDryInk_LinesMethod(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().Select(point => point.Position.ToVector2()).ToList(); for (int i = 1; i < inkPoints.Count; i++) { ds.DrawLine(inkPoints[i - 1], inkPoints[i], color); ds.DrawCircle(inkPoints[i], 3, color); } } }
private void DrawSeries(CanvasDrawingSession ds, Scenario scenario) { var data = scenario.Data; var lastPoint = origin; var color = scenario.Color.Color; foreach (var key in data.Keys.OrderBy(k => k)) { var point = new Vector2(GetX(key), GetY((float)selector(data[key]))); ds.DrawLine(lastPoint, point, color, 2); lastPoint = point; } }