void FillEllipse(Vector2 center, float radiusX, float radiusY, Color color) { if (!isWireframe) { currentDrawingSession.FillEllipse(center, radiusX, radiusY, color); } else { currentDrawingSession.DrawEllipse(center, radiusX, radiusY, Colors.Black); } }
public override void Render(Win2DRenderable renderable, CanvasDrawingSession session, Win2DColor color, bool renderControls) { var borderBrush = renderable.Resources.ThemeDarkBrush(color); var backgroundBrush = renderable.Node.IsSelected ? renderable.Resources.ThemeLightBrush(color) : renderable.Resources.ThemeNormalBrush(color); var radiusX = 0.5f * renderable.RenderSize.X; var radiusY = 0.5f * renderable.RenderSize.Y; session.FillEllipse( renderable.RenderBounds.Center, radiusX, radiusY, backgroundBrush); session.DrawEllipse( renderable.RenderBounds.Center, radiusX, radiusY, borderBrush); RenderIcon(renderable, session); RenderText(renderable, session); RenderCheckBox(renderable, session); if (!renderControls) { return; } if (renderable.Node.IsSelected) { radiusX -= SelectionMargin.X; radiusY -= SelectionMargin.Y; session.DrawEllipse( renderable.RenderBounds.Center, radiusX, radiusY, borderBrush, 2f, SelectionStrokeStyle); } RenderExpandButton(renderable, session); RenderNotesButton(renderable, session); }
internal void DrawHandle_sub(CanvasDrawingSession win2d, float x, float y, bool ellipse, Color color) { bool fill = false; int size = 4; if (ellipse) { if (fill) { win2d.FillEllipse(x, y, size, size, color); } else { win2d.DrawEllipse(x, y, size, size, color); } } else { Rect r = new Rect(x - size, y - size, size * 2, size * 2); if (fill) { win2d.FillRectangle(r, color); } else { win2d.DrawRectangle(r, color); } } }
private void DrawStones(GameTreeNode gameState, CanvasDrawingSession session) { if (gameState != null) { if (gameState.Tsumego.MarkedPositions.Any() && _settings.Tsumego.ShowPossibleMoves) { foreach (var position in gameState.Tsumego.MarkedPositions) { DrawStoneCellBackground(session, position.X, position.Y, Color.FromArgb(100, 255, 50, 0)); } } GameBoard boardState = gameState.BoardState; for (int x = SharedBoardControlState.OriginX; x < this.SharedBoardControlState.BoardWidth + SharedBoardControlState.OriginX; x++) { for (int y = SharedBoardControlState.OriginY; y < this.SharedBoardControlState.BoardHeight + SharedBoardControlState.OriginY; y++) { int translatedYCoordinate = (this.SharedBoardControlState.BoardHeight - y - 1); if (boardState[x, y] != StoneColor.None) { DrawStone(session, x, y, boardState[x, y], 1); if (_highlightLastMove) { if (gameState?.Move?.Kind == MoveKind.PlaceStone && gameState.Move.Coordinates.X == x && gameState.Move.Coordinates.Y == y) { session.DrawEllipse( new Vector2( (x - SharedBoardControlState.OriginX) * _cellSize + _halfSize, (translatedYCoordinate + SharedBoardControlState.OriginY) * _cellSize + _halfSize), _cellSize * 0.2f, _cellSize * 0.2f, boardState[x, y] == StoneColor.White ? Colors.Black : Colors.White, 3); } } } if (SharedBoardControlState.ShowTerritory && SharedBoardControlState.TerritoryMap != null) { if (SharedBoardControlState.TerritoryMap.DeadPositions.Contains(new Position(x, y))) { DrawCrossOutMark(session, x, y, Colors.Red, Colors.Transparent); } DrawTerritoryMark(session, x, y, SharedBoardControlState.TerritoryMap.Board[x, y]); } } } } }
public void Draw(CanvasDrawingSession graphics) { CanvasDevice device = CanvasDevice.GetSharedDevice(); var builder = new CanvasPathBuilder(device); var brush = new CanvasSolidColorBrush(graphics, drawingColor); graphics.DrawEllipse(centerX, centerY, radiusX, radiusY, brush, drawingSize); }
public override void Draw(ICanvasResourceCreator creator, CanvasDrawingSession session) { if (IsFill) { session.FillEllipse(CenterPoint, RadiusX, RadiusY, PenAttribute.GetBrush(creator)); } else { session.DrawEllipse(CenterPoint, RadiusX, RadiusY, PenAttribute.GetBrush(creator), PenAttribute.StrokeWidth, StrokeStyle); } }
private void DrawOval(CanvasControl sender, CanvasDrawingSession ds) { var width = (float)sender.ActualWidth; var height = (float)sender.ActualHeight; var center = new Vector2(width / 2, height / 2); var stroke = this.defaultStroke; var radiusX = (width / 3) - stroke; var radiusY = (height / 2) - stroke; ds.FillEllipse(center, radiusX, radiusY, ForegroundColor); ds.DrawEllipse(center, radiusX, radiusY, GlowColor, stroke); }
private void SetColorAndDrawDots(CanvasDrawingSession drawingSession, Color colorGamer, Dot p) //Вспомогательная функция для DrawPoints. Выбор цвета точки в зависимости от ее состояния и рисование элипса { Color c; if (p.Blocked) { drawingSession.FillEllipse(p.x, p.y, PointWidth, PointWidth, Color.FromArgb(130, colorGamer.R, colorGamer.G, colorGamer.B)); } else if (last_move != null && p.x == last_move.x & p.y == last_move.y)//точка последнего хода должна для удоиства выделяться { drawingSession.FillEllipse(p.x, p.y, PointWidth, PointWidth, Color.FromArgb(140, colorGamer.R, colorGamer.G, colorGamer.B)); drawingSession.DrawEllipse(p.x, p.y, PointWidth / 2, PointWidth / 2, Colors.WhiteSmoke, 0.05f); drawingSession.DrawEllipse(p.x, p.y, PointWidth, PointWidth, colorGamer, 0.08f); } else { int G = colorGamer.G > 50 ? colorGamer.G - 50 : 120; c = p.BlokingDots.Count > 0 ? Color.FromArgb(255, colorGamer.R, colorGamer.G, colorGamer.B) : colorGamer; drawingSession.FillEllipse(p.x, p.y, PointWidth, PointWidth, colorGamer); drawingSession.DrawEllipse(p.x, p.y, PointWidth, PointWidth, c, 0.08f); } }
private void DrawShip(double rotation, CanvasDrawingSession graphics) { var rotatedPolygon = _shipSprite.Polygon.ClonePolygon().Rotate(new Vector2(0, 0), rotation); var shipGeometry = CanvasGeometry.CreatePolygon(graphics, rotatedPolygon); if (_shieldCountDown > 0) { graphics.DrawGeometry(shipGeometry, _shipSprite.Location, Colors.DarkGray); graphics.DrawEllipse(_shipSprite.Location, 20, 20, Colors.DarkGray); } else { graphics.FillGeometry(shipGeometry, _shipSprite.Location, Colors.White); } }
internal override void Draw(CanvasControl cc, CanvasDrawingSession ds, float scale, Vector2 center, FlipState flip) { var color = GetColor(Coloring.Normal); var(cp, r1, r2) = GetCenterRadius(flip, center, scale); if (FillStroke == Fill_Stroke.Filled) { ds.FillEllipse(cp, r1, r2, color); } else { ds.DrawEllipse(cp, r1, r2, color, StrokeWidth, StrokeStyle()); } }
internal virtual void drawArc(int x, int y, int w, int h, int startAngle, int arcAngle) { Vector2 center = new Vector2(); center.X = x + w / 2; center.Y = y + h / 2; if (arcAngle == 360) { graphics.DrawEllipse(center, w / 2, h / 2, c); } else { CanvasPathBuilder builder = new CanvasPathBuilder(graphics); builder.BeginFigure(center); builder.AddArc(center, w / 2, h / 2, -(float)(2 * Math.PI * startAngle / 360), -(float)(2 * Math.PI * arcAngle / 360)); builder.EndFigure(CanvasFigureLoop.Closed); graphics.DrawGeometry(CanvasGeometry.CreatePath(builder), c); } }
private void DrawCircleMark(CanvasDrawingSession session, int x, int y, Color color, Color background) { y = (this.SharedBoardControlState.BoardHeight - 1) - y; float cellSizeHalf = _cellSize * 0.5f; session.FillRectangle( _cellSize * x, _cellSize * y, _cellSize, _cellSize, background); session.DrawEllipse( new Vector2( _cellSize * x + cellSizeHalf, _cellSize * y + cellSizeHalf), _cellSize * 0.4f, _cellSize * 0.4f, color, 3); }
internal virtual void drawArc(int x, int y, int w, int h, int startAngle, int arcAngle) { //using (createAlphaLayer()) //{ Vector2 center = new Vector2(); center.X = x + w / 2; center.Y = y + h / 2; if (arcAngle == 360) { graphics.DrawEllipse(center, w / 2, h / 2, Color.FromArgb((byte)alpha, c.R, c.G, c.B)); } else { CanvasPathBuilder builder = new CanvasPathBuilder(graphics); builder.BeginFigure(center); builder.AddArc(center, w / 2, h / 2, -(float)(2 * Math.PI * startAngle / 360), -(float)(2 * Math.PI * arcAngle / 360)); builder.EndFigure(CanvasFigureLoop.Closed); graphics.DrawGeometry(CanvasGeometry.CreatePath(builder), Color.FromArgb((byte)alpha, c.R, c.G, c.B)); } //} }
private static void DrawEllipseInternal( CanvasDrawingSession ds, Color brush, Color pen, CanvasStrokeStyle ss, bool isStroked, bool isFilled, ref Rect2 rect, double strokeWidth) { double radiusX = rect.Width / 2.0; double radiusY = rect.Height / 2.0; double x = rect.X + radiusX; double y = rect.Y + radiusY; if (isFilled) { ds.FillEllipse( (float)x, (float)y, (float)radiusX, (float)radiusY, brush); } if (isStroked) { ds.DrawEllipse( (float)x, (float)y, (float)radiusX, (float)radiusY, pen, (float)strokeWidth, ss); } }
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; } }
// For SimpleSample, we draw the same simple graphics as the sample itself. static void DrawSimpleSampleIcon(CanvasDrawingSession ds, IconInfo iconInfo) { ds.DrawEllipse(155, 115, 80, 30, Colors.Black, 3); ds.DrawText("Hello, world!", 100, 100, Colors.Yellow); }
/// <summary> /// Draws an Ellipse of at the given center, having the specified radius, using a CanvasStroke to define the stroke width, the stroke color and stroke style. /// </summary> /// <param name="session">CanvasDrawingSession</param> /// <param name="x">Offset of the Center on the x axis</param> /// <param name="y">Offset of the Center on the y axis</param> /// <param name="radiusX">Radius in the X axis</param> /// <param name="radiusY">Radius in the Y axis</param> /// <param name="stroke">CanvasStroke defining the stroke width, the stroke /// color and stroke style.</param> public static void DrawEllipse(this CanvasDrawingSession session, float x, float y, float radiusX, float radiusY, ICanvasStroke stroke) { session.DrawEllipse(x, y, radiusX, radiusY, stroke.Brush, stroke.Width, stroke.Style); }
/// <summary> /// Draws an Ellipse of at the given center, having the specified radius, using a CanvasStroke to define the stroke width, the stroke color and stroke style. /// </summary> /// <param name="session">CanvasDrawingSession</param> /// <param name="centerPoint">Center of the Circle</param> /// <param name="radiusX">Radius in the X axis</param> /// <param name="radiusY">Radius in the Y axis</param> /// <param name="stroke">CanvasStroke defining the stroke width, the stroke /// color and stroke style.</param> public static void DrawEllipse(this CanvasDrawingSession session, Vector2 centerPoint, float radiusX, float radiusY, ICanvasStroke stroke) { session.DrawEllipse(centerPoint, radiusX, radiusY, stroke.Brush, stroke.Width, stroke.Style); }
public void DrawEllipse(float xCenter, float yCenter, float hRadius, float vRadius) { ds.DrawEllipse(xCenter, yCenter, hRadius, vRadius, color, strokeWidth, strokeStyle); }
public void DrawEllipse(CanvasDrawingSession g2d, int xpos, int ypos, int width, int height, Color borderpen, float linesize) { g2d.DrawEllipse(xpos, ypos, width, height, borderpen, linesize); }
public override void Draw(CanvasDrawingSession session) { session.DrawEllipse(Position, 5, 5, Selected ? Colors.Red : Colors.Yellow); }
public void DrawOval(float x, float y, float width, float height, float w) { _c.DrawEllipse(new Vector2(x + width / 2, y + height / 2), width / 2, height / 2, wcolor, w); }
/// <summary> /// Draw a ellipse and the DodgerBlue color. /// </summary> /// <param name="drawingSession"> The drawing-session. </param> /// <param name="centerPoint"> The center point. </param> /// <param name="radiusX"> The radius X. </param> /// <param name="radiusY"> The radius Y. </param> public static void DrawEllipseDodgerBlue(this CanvasDrawingSession drawingSession, Vector2 centerPoint, float radiusX, float radiusY) { drawingSession.DrawEllipse(centerPoint, radiusX, radiusY, Windows.UI.Colors.DodgerBlue); drawingSession.FillEllipse(centerPoint, radiusX, radiusY, CanvasDrawingSessionExtensions.TranslucentDodgerBlue); }
////// // GameTree drawing ////// private void DrawGameTree(CanvasDrawingSession drawingSession, GameTreeNode gameTreeRoot) { int resultVerticalOffset = 0; WalkGameTree(gameTreeRoot, 0, ref resultVerticalOffset, 0, (node, horizontalOffset, verticalOffset, parentVerticalOffset) => { // Calculate node position Vector2 stoneTopLeft = new Vector2( horizontalOffset * NODESIZE + horizontalOffset * NODESPACING, verticalOffset * NODESIZE + verticalOffset * NODESPACING); Vector2 stoneCenter = stoneTopLeft; stoneCenter.X += NODESIZE * 0.5f; stoneCenter.Y += NODESIZE * 0.5f; string nodeText = ""; // Get text for node if (node.Move.Kind == MoveKind.PlaceStone) { nodeText = node.Move.Coordinates.ToIgsCoordinates(); } else if (node.Move.Kind == MoveKind.Pass) { nodeText = NODEPASSTEXT; } CanvasTextLayout textLayout = GetTextLayoutForString(drawingSession.Device, nodeText); // Draw node according to the color of player whose move that was if (node.Move.WhoMoves == StoneColor.Black) { // Black move drawingSession.FillEllipse(stoneCenter, NODESIZE * 0.5f, NODESIZE * 0.5f, BlackNodeColor); drawingSession.DrawTextLayout(textLayout, stoneTopLeft, Colors.White); } else if (node.Move.WhoMoves == StoneColor.White) { // White move drawingSession.FillEllipse(stoneCenter, NODESIZE * 0.5f, NODESIZE * 0.5f, WhiteNodeColor); drawingSession.DrawTextLayout(textLayout, stoneTopLeft, Colors.Black); } else { // Empty node, no move drawingSession.FillEllipse(stoneCenter, NODESIZE * 0.5f, NODESIZE * 0.5f, EmptyNodeColor); } // If the current node is the selected node, draw highlight if (node == ViewModel.SelectedGameTreeNode) { drawingSession.DrawEllipse(stoneCenter, NODESIZE * 0.5f, NODESIZE * 0.5f, HighlightNodeColor, NODEHIGHLIGHTSTROKE); } // Calculate starting and end points for line connecting two nodes Vector2 lineStart = new Vector2( (horizontalOffset) * NODESIZE + (horizontalOffset - 1) * NODESPACING, (parentVerticalOffset) * NODESIZE + parentVerticalOffset * NODESPACING + NODESIZE * 0.5f); Vector2 lineEnd = new Vector2( horizontalOffset * NODESIZE + horizontalOffset * NODESPACING, verticalOffset * NODESIZE + verticalOffset * NODESPACING + NODESIZE * 0.5f); // Draw line between new node and its parent drawingSession.DrawLine(lineStart, lineEnd, LineColor); return(GameTreeNodeCallbackResultBehavior.Continue); }); }
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; Random random = new Random(); 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_GaussianBlur: if (m_bitmap_tiger != null) { GaussianBlurEffect blurEffect = new GaussianBlurEffect(); blurEffect.StandardDeviation = (float)random.NextDouble() * 5; blurEffect.Source = m_bitmap_tiger; ds.DrawImage(blurEffect, new Vector2(horizontalLimit / 2, verticalLimit / 2)); } else { DrawNoBitmapErrorMessage(ds, horizontalLimit / 2, verticalLimit / 2); } break; case DrawnContentType.Effect_Saturation: if (m_bitmap_tiger != null) { SaturationEffect saturationEffect = new SaturationEffect(); saturationEffect.Saturation = (float)random.NextDouble(); saturationEffect.Source = m_bitmap_tiger; ds.DrawImage(saturationEffect, new Vector2(horizontalLimit / 2, verticalLimit / 2)); } else { DrawNoBitmapErrorMessage(ds, horizontalLimit / 2, verticalLimit / 2); } break; case DrawnContentType.Effect_3DTransform: if (m_bitmap_tiger != null) { Transform3DEffect transformEffect = new Transform3DEffect(); transformEffect.Source = m_bitmap_tiger; transformEffect.InterpolationMode = CanvasImageInterpolation.Cubic; transformEffect.TransformMatrix = Matrix4x4.CreateRotationZ((float)random.NextDouble(), new Vector3(0, 0, 0)); ds.DrawImage(transformEffect, new Vector2(horizontalLimit / 2, verticalLimit / 2)); } else { DrawNoBitmapErrorMessage(ds, horizontalLimit / 2, verticalLimit / 2); } break; case DrawnContentType.Effect_Blend: if (m_bitmap_tiger != null) { Transform3DEffect transformEffect = new Transform3DEffect(); transformEffect.Source = m_bitmap_tiger; transformEffect.TransformMatrix = Matrix4x4.CreateRotationZ((float)random.NextDouble(), new Vector3(0, 0, 0)); BlendEffect blendEffect = new BlendEffect(); blendEffect.Background = m_bitmap_tiger; blendEffect.Foreground = transformEffect; blendEffect.Mode = BlendEffectMode.SoftLight; ds.DrawImage(blendEffect, new Vector2(horizontalLimit / 2, verticalLimit / 2)); } else { DrawNoBitmapErrorMessage(ds, horizontalLimit / 2, verticalLimit / 2); } break; case DrawnContentType.Effect_Composite: if (m_bitmap_tiger != null) { CompositeEffect compositeEffect = new CompositeEffect(); compositeEffect.Mode = CompositeEffectMode.SourceOver; float angle = 0.0f; float angleDelta = (float)random.NextDouble() + 0.05f; int imageNumber = (int)(2 * Math.PI / angleDelta) + 1; foreach (var i in Enumerable.Range(0, imageNumber)) { Transform3DEffect transformEffect = new Transform3DEffect(); transformEffect.Source = m_bitmap_tiger; transformEffect.TransformMatrix = Matrix4x4.CreateRotationZ(angle, new Vector3(0, 0, 0)); angle += angleDelta; compositeEffect.Inputs.Add(transformEffect); } ds.DrawImage(compositeEffect, new Vector2(horizontalLimit / 2, verticalLimit / 2)); } 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.OffscreenTarget: m_imageBrush.Image = m_offscreenTarget; 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); 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; } }
private void DrawAnchorSub(CanvasDrawingSession win2d, ViewInfo viewInfo, SvgPathData.SvgPathIndex myIndex, int partIndex, float x, float y) { myIndex.PartIndex = partIndex; bool ellipse = true; switch (Command) { case 'c': case 'C': if (partIndex == 2) { ellipse = false; } break; default: break; } // bool hover = viewInfo.HoverIndex == myIndex; bool select = viewInfo.TargetPathData.GetCurrentIndex() == myIndex; Color color = Colors.Blue; bool fill = false; if (viewInfo.HoverIndex == myIndex) { fill = true; } else if (select) { color = GetColor(); fill = true; } else { color = GetColor(); } int size = 4; if (ellipse) { if (fill) { win2d.FillEllipse(x, y, size, size, color); } else { win2d.DrawEllipse(x, y, size, size, color); } } else { Rect r = new Rect(x - size, y - size, size * 2, size * 2); if (fill) { win2d.FillRectangle(r, color); } else { win2d.DrawRectangle(r, color); } } }
/// <summary> /// Draw a thick ellipse. /// </summary> /// <param name="drawingSession"> The drawing-session. </param> /// <param name="centerPoint"> The center point. </param> /// <param name="radiusX"> The radius X. </param> /// <param name="radiusY"> The radius Y. </param> public static void DrawThickEllipse(this CanvasDrawingSession drawingSession, Vector2 centerPoint, float radiusX, float radiusY) { drawingSession.DrawEllipse(centerPoint, radiusX, radiusY, Windows.UI.Colors.Black, 2); drawingSession.DrawEllipse(centerPoint, radiusX, radiusY, Windows.UI.Colors.White); }
public void Draw(CanvasDrawingSession drawingSession) { drawingSession.DrawEllipse(X, Y, Radius, Radius, Color); }