示例#1
0
        public void Draw(Chart2DSpriteContainer sprites, IAxis axis1, IAxis axis2, Vector2 offset)
        {
            sprites.Color = this.color;

            Vector2 lastPoint = default(Vector2);
            bool    first     = true;

            foreach (var point in this.drawablePoints)
            {
                var pd = point.Position;

                var p = offset + new Vector2((float)axis1.DataToChart(pd.X), (float)axis2.DataToChart(pd.Y));

                if (first)
                {
                    first     = false;
                    lastPoint = p;
                    continue;
                }

                sprites.DrawLine(lastPoint, p, sprites.ThickLineWidth);

                lastPoint = p;
            }
        }
示例#2
0
        private void drawFast(Chart2DSpriteContainer sprites, IAxis axis1, IAxis axis2, Vector2 offset)
        {
            float previousX = 0;
            bool  first     = true;

            float baseDrawY = (float)axis2.DataToChart(0) + offset.Y;

            foreach (var bars in this.drawnPoints(axis1, offset))
            {
                if (first)
                {
                    previousX = bars.XCoordinate;
                    first     = false;
                    continue;
                }

                var y = 0f;
                var i = 0;

                var drawY = baseDrawY;

                ushort vOffset;
                var    vertexArray = sprites.DrawFastBars(bars.Value.Count, out vOffset);

                foreach (var value in bars.Value)
                {
                    var argb = this.colors[i % this.colors.Count];

                    var newY = y + (float)value;

                    var newDrawY = (float)axis2.DataToChart(newY) + offset.Y;

                    vertexArray[vOffset + i] = new FastChart2DBarVertex(
                        new Vector2(previousX, drawY), new Vector2(bars.XCoordinate - previousX, newDrawY - drawY),
                        argb);


                    drawY = newDrawY;
                    y     = newY;
                    i++;
                }

                previousX = bars.XCoordinate;
            }
        }
示例#3
0
 public void Draw(Chart2DSpriteContainer sprites, IAxis axis1, IAxis axis2, Vector2 offset)
 {
     sprites.Color = this.color;
     foreach (var point in this.points)
     {
         var x = (float)axis1.DataToChart(point.Position.X);
         var y = (float)axis2.DataToChart(point.Position.Y);
         sprites.DrawPoint(new Vector2(x, y) + offset, sprites.LargePointSize);
     }
 }
示例#4
0
        private void drawSlow(Chart2DSpriteContainer sprites, IAxis axis1, IAxis axis2, Vector2 offset)
        {
            float previousX = 0;
            bool  first     = true;

            float baseDrawY = (float)axis2.DataToChart(0) + offset.Y;

            foreach (var bars in this.drawnPoints(axis1, offset))
            {
                if (first)
                {
                    previousX = bars.XCoordinate;
                    first     = false;
                    continue;
                }

                var y = 0f;
                var i = 0;

                var drawY = baseDrawY;

                foreach (var value in bars.Value)
                {
                    sprites.Color = this.colors[(i++) % this.colors.Count];

                    var newY = y + (float)value;

                    var newDrawY = (float)axis2.DataToChart(newY) + offset.Y;

                    sprites.DrawQuad(
                        new Vector2(previousX, drawY),
                        new Vector2(previousX, newDrawY),
                        new Vector2(bars.XCoordinate, newDrawY),
                        new Vector2(bars.XCoordinate, drawY)
                        );

                    drawY = newDrawY;
                    y     = newY;
                }

                previousX = bars.XCoordinate;
            }
        }
示例#5
0
        public void Draw(Chart2DSpriteContainer sprites, IAxis parallelAxis, IAxis perpendicularAxis,
                         Vector2 offset, Vector2 direction, Vector2 axisUnit)
        {
            sprites.Color = this.color;

            var minOffset = offset + direction * (float)parallelAxis.DataToChart(parallelAxis.MinValue);
            var maxOffset = offset + direction * (float)parallelAxis.DataToChart(parallelAxis.MaxValue);

            int minI = this.repeat ? (int)((perpendicularAxis.MinValue - this.StartValue) / this.interval) : 0;
            int maxI = this.repeat ? (int)((perpendicularAxis.MaxValue - this.StartValue) / this.interval) : 0;

            for (int i = minI; i <= maxI; i++)
            {
                var position = axisUnit * (float)perpendicularAxis.DataToChart(this.StartValue + this.interval * i);

                sprites.DrawLine(
                    minOffset + position,
                    maxOffset + position,
                    sprites.ThinLineWidth);
            }
        }
示例#6
0
        public void Draw(Chart2DSpriteContainer sprites, IAxis parallelAxis, IAxis perpendicularAxis,
            Vector2 offset, Vector2 direction, Vector2 axisUnit)
        {
            sprites.Color = this.color;

            var minOffset = offset + direction * (float)parallelAxis.DataToChart(parallelAxis.MinValue);
            var maxOffset = offset + direction * (float)parallelAxis.DataToChart(parallelAxis.MaxValue);

            int minI = this.repeat ? (int)((perpendicularAxis.MinValue - this.StartValue) / this.interval) : 0;
            int maxI = this.repeat ? (int)((perpendicularAxis.MaxValue - this.StartValue) / this.interval) : 0;

            for (int i = minI; i <= maxI; i++)
            {
                var position = axisUnit * (float)perpendicularAxis.DataToChart(this.StartValue + this.interval * i);

                sprites.DrawLine(
                    minOffset + position,
                    maxOffset + position,
                    sprites.ThinLineWidth);
            }
        }
示例#7
0
        protected IEnumerable <DrawableValue> drawnPoints(IAxis axis1, Vector2 offset)
        {
            int minI = Math.Max(0, this.values.Count - this.maxNumberOfValues);
            int xI   = 0;

            for (int i = minI; i < this.values.Count; i++)
            {
                var x = (float)(axis1.DataToChart(xI * this.drawStepSize) + this.drawOffset) + offset.X;
                var v = this.values[i];

                yield return(new DrawableValue(v, x));

                xI++;
            }
        }