Exemple #1
0
        public async void DrawCurveControlLines(Canvas2DContext ctx, BezierCurve curve)
        {
            await ctx.BeginPathAsync();

            await ctx.MoveToAsync(curve.ControlPoint1.X, curve.ControlPoint1.Y);

            await ctx.LineToAsync(curve.StartPoint.X, curve.StartPoint.Y);

            //await ctx.SetStrokeStyleAsync("red");
            await ctx.StrokeAsync();

            await ctx.BeginPathAsync();

            //await ctx.SetFillStyleAsync("yellow");
            await ctx.ArcAsync(curve.ControlPoint1.X, curve.ControlPoint1.Y, 5, 0, Math.PI * 2);

            await ctx.FillAsync();

            await ctx.BeginPathAsync();

            await ctx.MoveToAsync(curve.ControlPoint2.X, curve.ControlPoint2.Y);

            await ctx.LineToAsync(curve.EndPoint.X, curve.EndPoint.Y);

            //await ctx.SetStrokeStyleAsync("red");
            await ctx.StrokeAsync();

            await ctx.BeginPathAsync();

            // await ctx.SetFillStyleAsync("yellow");
            await ctx.ArcAsync(curve.ControlPoint2.X, curve.ControlPoint2.Y, 5, 0, Math.PI * 2);

            await ctx.FillAsync();
        }
Exemple #2
0
        private async Task TraceLineAsync(double x, double y)
        {
            if (_lastX is not null && _lastY is not null)
            {
                await _canvas2DContext.SetLineWidthAsync(LineWidth);

                await _canvas2DContext.BeginPathAsync();

                await _canvas2DContext.MoveToAsync(_lastX.Value, _lastY.Value);

                await _canvas2DContext.LineToAsync(x, y);

                await _canvas2DContext.StrokeAsync();
            }

            await _canvas2DContext.BeginPathAsync();

            await _canvas2DContext.ArcAsync(x, y, PointSize, 0, Radius, anticlockwise : true);

            await _canvas2DContext.ClosePathAsync();

            await _canvas2DContext.FillAsync();

            _lastX = x;
            _lastY = y;
        }
Exemple #3
0
        public override async void Draw(Canvas2DContext batch)
        {
            await batch.SetFillStyleAsync("green");

            await batch.ArcAsync(95, 50, 40, 0, 2 *Math.PI);

            await batch.StrokeAsync();
        }
Exemple #4
0
        public override async Task Draw(Canvas2DContext context)
        {
            await context.BeginPathAsync();

            await context.ArcAsync(Position.X, Position.Y, Size / 2, 0, 2 *Math.PI);

            await context.SetFillStyleAsync("blue");

            await context.FillAsync();
        }
        public static async Task DrawOn(this IDisplayable element, Canvas2DContext context)
        {
            await context.BeginPathAsync();

            await context.ArcAsync(element.Position.X, element.Position.Y, element.Size / 2, 0, Math.PI * 2);

            await context.SetFillStyleAsync(element.Color);

            await context.FillAsync();

            await context.ClosePathAsync();
        }
Exemple #6
0
        public async void DrawPathPoints(Canvas2DContext ctx, List <PointF> pathpoints)
        {
            Utils.dOut("DrawPathPoints", pathpoints.Count);

            foreach (var point in pathpoints)
            {
                await ctx.BeginPathAsync();

                await ctx.ArcAsync(point.X, point.Y, 2, 0, Math.PI * 2);

                await ctx.FillAsync();
            }
        }
Exemple #7
0
        public async void DrawGrid(Canvas2DContext ctx)
        {
            var enemygrid = new EnemyGrid();

            await ctx.BeginPathAsync();

            enemygrid.GridPoints.Where(a => a.Row == 1).ToList().ForEach(async a => {
                await ctx.ArcAsync(a.Point.X, a.Point.Y, 5, 0, Math.PI * 2);
            });
            await ctx.FillAsync();

            await ctx.BeginPathAsync();

            enemygrid.GridPoints.Where(a => a.Row == 2).ToList().ForEach(async a => {
                await ctx.ArcAsync(a.Point.X, a.Point.Y, 5, 0, Math.PI * 2);
            });
            await ctx.FillAsync();

            await ctx.BeginPathAsync();

            enemygrid.GridPoints.Where(a => a.Row == 3).ToList().ForEach(async a => {
                await ctx.ArcAsync(a.Point.X, a.Point.Y, 5, 0, Math.PI * 2);
            });
            await ctx.FillAsync();

            await ctx.BeginPathAsync();

            enemygrid.GridPoints.Where(a => a.Row == 4).ToList().ForEach(async a => {
                await ctx.ArcAsync(a.Point.X, a.Point.Y, 5, 0, Math.PI * 2);
            });
            await ctx.FillAsync();

            await ctx.BeginPathAsync();

            enemygrid.GridPoints.Where(a => a.Row == 5).ToList().ForEach(async a => {
                await ctx.ArcAsync(a.Point.X, a.Point.Y, 5, 0, Math.PI * 2);
            });
            await ctx.FillAsync();
        }
        /// <summary>
        /// 画表盘圆
        ///</summary>
        ///<param name="strokeStyle"></param>
        ///<param name="radius">半径</param>
        ///<param name="fillStyle">填充色</param>
        /// <returns></returns>
        private async Task DrawCicleAsync(string strokeStyle, double radius, string fillStyle)
        {
            await _context.SaveAsync();

            await _context.TranslateAsync(radius, radius);

            await _context.BeginPathAsync();

            await _context.SetStrokeStyleAsync(strokeStyle);

            await _context.ArcAsync(0, 0, radius, 0, 2 *Math.PI, true);

            await _context.SetFillStyleAsync(fillStyle);

            await _context.FillAsync();

            await _context.RestoreAsync();
        }
Exemple #9
0
 public void Apply(ArcNode arcNode)
 {
     _canvas2DContext.ArcAsync(arcNode.Position.X, arcNode.Position.Y, arcNode.Radius, arcNode.StartAngle,
                               arcNode.EndAngle, arcNode.IsCounterClockwise);
 }