Example #1
0
 public void Draw(Chart2DSpriteContainer sprites, Vector2 direction, Vector2 offset)
 {
     sprites.Color = this.color;
     sprites.DrawLine(offset - direction * this.lengthNegative,
                      offset + direction * this.lengthPositive,
                      sprites.ThinLineWidth);
 }
Example #2
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;
            }
        }
Example #3
0
 public void Draw(Chart2DSpriteContainer sprites, Vector2 direction, Vector2 offset)
 {
     sprites.Color = this.color;
     sprites.DrawLine(offset - direction * this.lengthNegative,
         offset + direction * this.lengthPositive,
         sprites.ThinLineWidth);
 }
Example #4
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);
     }
 }
Example #5
0
        public void Draw(Chart2DSpriteContainer sprites, IAxis axis1, IAxis axis2, Vector2 offset)
        {
            if (this.HorizontalLines != null)
                foreach (var line in this.HorizontalLines)
                    line.Draw(sprites, axis1, axis2, offset, Vector2.UnitX, Vector2.UnitY);

            if (this.VerticalLines != null)
                foreach (var line in this.VerticalLines)
                    line.Draw(sprites, axis2, axis1, offset, Vector2.UnitY, Vector2.UnitX);
        }
Example #6
0
 public override void Draw(Chart2DSpriteContainer sprites, IAxis axis1, IAxis axis2, Vector2 offset)
 {
     if (sprites.CanDrawBarsFast)
     {
         this.drawFast(sprites, axis1, axis2, offset);
     }
     else
     {
         this.drawSlow(sprites, axis1, axis2, offset);
     }
 }
Example #7
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;
            }
        }
Example #8
0
        public void Draw(Chart2DSpriteContainer sprites, IAxis axis1, IAxis axis2, Vector2 offset)
        {
            if (this.HorizontalLines != null)
            {
                foreach (var line in this.HorizontalLines)
                {
                    line.Draw(sprites, axis1, axis2, offset, Vector2.UnitX, Vector2.UnitY);
                }
            }

            if (this.VerticalLines != null)
            {
                foreach (var line in this.VerticalLines)
                {
                    line.Draw(sprites, axis2, axis1, offset, Vector2.UnitY, Vector2.UnitX);
                }
            }
        }
Example #9
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;
            }
        }
Example #10
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);
            }
        }
Example #11
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);
            }
        }
Example #12
0
 public abstract void Draw(Chart2DSpriteContainer sprites, IAxis axis1, IAxis axis2, Vector2 offset);