Пример #1
0
 /// <summary>
 /// Draw the current stroke on the CanvasDrawingSession.
 /// </summary>
 /// <param name="canvasDrawingSession">CanvasDrawingSession to be drawn</param>
 /// <param name="x">offset x coordinate</param>
 /// <param name="y">offset y coordinate</param>
 public void Draw(CanvasDrawingSession canvasDrawingSession, float x = 0f, float y = 0f)
 {
     Build();
     canvasDrawingSession.DrawCachedGeometry(CanvasCachedGeometry, x, y, Color);
     //foreach (var fp in points)
     //    canvasDrawingSession.FillCircle(new Vector2(fp.X / 56 * Scale + x, fp.Y / 56 * Scale + y), 2, Colors.LightYellow);
     //foreach (var fp in filtered)
     //    canvasDrawingSession.FillCircle(new Vector2(fp.X / 56 * Scale + x, fp.Y / 56 * Scale + y), 2, Colors.LightPink);
 }
Пример #2
0
        public void Draw(double targetElapsedTimeInMs, long updateCount, CanvasDrawingSession ds)
        {
            ds.DrawCachedGeometry(clockFaceCachedFill, backgroundBrush);

            double updatesPerSecond = 1000.0 / targetElapsedTimeInMs;
            int    seconds          = (int)((updateCount / updatesPerSecond) % 10);

            hueRotationEffect.Angle = (float)Math.PI * (seconds / 10.0f) * 2.0f;

            using (var timeSegmentGeometry = CreateTimeSegmentGeometry(ds, updateCount, updatesPerSecond))
            {
                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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        /// <summary>
        /// user needs to call "ds.Clear(Colors.Transparent);" before this function if necessary
        /// </summary>
        /// <param name="ds"></param>
        /// <param name="lineColor"></param>
        /// <param name="lineWidth"></param>
        /// <param name="fillColor"></param>
        /// <param name="m"></param>
        public void Draw(CanvasDrawingSession ds, Color lineColor, float lineWidth, Color fillColor, Matrix3x2 m)
        {
            /*if (m != null)
             *  _cg = _cg.Transform(m);
             * if (!(lineColor == Colors.Transparent))
             * {
             *  ds.DrawGeometry(_cg, lineColor, lineWidth);
             * }
             *
             * if (fillColor != null)
             *  ds.FillGeometry(_cg, fillColor);//*/

            ds.Transform = m;
            if (_ccgStroke != null && lineColor != Colors.Transparent)
            {
                ds.DrawCachedGeometry(_ccgStroke, lineColor);
            }
            if (_ccgFill != null && fillColor != Colors.Transparent)
            {
                ds.DrawCachedGeometry(_ccgFill, fillColor);
            }

            ds.Transform = Matrix3x2.Identity;
        }
Пример #5
0
 /**
  *   Draw the entire dancer's path as a translucent colored line
  * @param ds  Canvas to draw to
  */
 public void drawPath(CanvasDrawingSession ds)
 {
     if (pathpath == null)
     {
         var savebeat = lastbeat;
         CanvasPathBuilder pathBuilder = new CanvasPathBuilder(ds);
         animateComputed(0.0);
         var loc = location;
         pathBuilder.BeginFigure(loc.X, loc.Y);
         for (double beat = 0.1; beat <= beats; beat += 0.1)
         {
             animateComputed(beat);
             loc = location;
             pathBuilder.AddLine(loc.X, loc.Y);
         }
         pathBuilder.EndFigure(CanvasFigureLoop.Open);
         var cg = CanvasGeometry.CreatePath(pathBuilder);
         pathpath = CanvasCachedGeometry.CreateStroke(cg, 0.1f);
         animate(savebeat); //  restore current position
     }
     ds.DrawCachedGeometry(pathpath, Color.FromArgb(80, fillColor.R, fillColor.G, fillColor.B));
 }
Пример #6
0
        public static void DrawGeometry(Tile.Feature feature, float scale, CanvasDrawingSession session, Windows.UI.Color fillColor, Windows.UI.Color strokeColor, float innerLineWidth, float outerLineWidth, CanvasStrokeStyle strokeStyle)
        {
            Queue <uint> q  = new Queue <uint>(feature.Geometries);
            float        cx = 0;
            float        cy = 0;

            List <System.Numerics.Vector2> poly = new List <System.Numerics.Vector2>();

            while (q.Count > 0)
            {
                var cmd = DecodeCommand(q.Dequeue());
                switch (cmd.Item1)
                {
                case GeometryCommand.MoveTo:
                    cx += DecodeParameter(q.Dequeue()) * scale;
                    cy += DecodeParameter(q.Dequeue()) * scale;
                    poly.Add(new System.Numerics.Vector2(cx, cy));
                    break;

                case GeometryCommand.LineTo:
                    for (int it = 0; it < cmd.count; it++)
                    {
                        cx += DecodeParameter(q.Dequeue()) * scale;
                        cy += DecodeParameter(q.Dequeue()) * scale;
                        poly.Add(new System.Numerics.Vector2(cx, cy));
                    }
                    break;

                case GeometryCommand.ClosePath:
                    if (feature.Type == Tile.GeomType.Polygon)
                    {
                        CanvasGeometry geom = CanvasGeometry.CreatePolygon(session.Device, poly.ToArray());
                        var            cf   = CanvasCachedGeometry.CreateFill(geom);
                        var            cd   = CanvasCachedGeometry.CreateStroke(geom, 1);
                        cache.Add(cf); cache.Add(cd);
                        session.DrawCachedGeometry(cf, fillColor);
                        session.DrawCachedGeometry(cd, strokeColor);
                        //session.FillGeometry(geom, fillColor);
                        //session.DrawGeometry(geom, strokeColor);
                    }
                    poly.Clear();
                    break;
                }
            }
            if (feature.Type == Tile.GeomType.Linestring)
            {
                CanvasPathBuilder pathBuilder = new CanvasPathBuilder(session);
                pathBuilder.SetSegmentOptions(CanvasFigureSegmentOptions.ForceRoundLineJoin);
                pathBuilder.BeginFigure(poly[0]);
                for (int it = 1; it < (poly.Count); it++)
                {
                    pathBuilder.AddLine(poly[it]);

                    //if(outerLineWidth > 0)
                    //	session.DrawLine(poly[it], poly[it + 1], strokeColor, outerLineWidth, strokeStyle);
                    //if (innerLineWidth > 0)
                    //	session.DrawLine(poly[it], poly[it + 1], fillColor, innerLineWidth, strokeStyle);
                }
                pathBuilder.EndFigure(CanvasFigureLoop.Open);
                var geometry = CanvasGeometry.CreatePath(pathBuilder);
                if (outerLineWidth > 0)
                {
                    var cg = CanvasCachedGeometry.CreateStroke(geometry, outerLineWidth, strokeStyle);
                    cache.Add(cg);
                    session.DrawCachedGeometry(cg, strokeColor);
                    //session.DrawGeometry(geometry, strokeColor, outerLineWidth, strokeStyle);
                }
                if (innerLineWidth > 0)
                {
                    var cg = CanvasCachedGeometry.CreateStroke(geometry, innerLineWidth, strokeStyle);
                    cache.Add(cg);
                    session.DrawCachedGeometry(cg, fillColor);
                    //session.DrawGeometry(geometry, fillColor, innerLineWidth, strokeStyle);
                }
                poly.Clear();
            }
        }