Ejemplo n.º 1
0
        public void Render(GraphBuilder context, IImageProcessingContext <Rgba32> renderContext, GraphicsOptions options)
        {
            PointF originPixelPos = (context.GridRegion.Position() + context.Origin);

            if (Axis.IsHorizontal)
            {
                float leftBound  = context.GridRegion.Left;
                float rightBound = context.GridRegion.Right;

                float xData = EnableForZero ? 0 : TickDistance;
                float x     = originPixelPos.X + context.ToPixelsHorizontal(xData);

                // doesn't lend itself to log scales...
                float pixelTick = context.ToPixelsHorizontal(TickDistance);

                while (x < rightBound)
                {
                    Image <Rgba32> generatedLabel = GenerateLabel(xData, options);
                    renderContext.DrawImage(generatedLabel, generatedLabel.Size(), new Point((int)x, (int)originPixelPos.Y), options);

                    x     += pixelTick;
                    xData += TickDistance;
                }

                xData = -TickDistance;
                x     = originPixelPos.X + context.ToPixelsHorizontal(xData);


                while (x > leftBound)
                {
                    x     -= pixelTick;
                    xData -= TickDistance;
                }
            }
            else
            {
                float topBound    = context.GridRegion.Left;
                float bottomBound = context.GridRegion.Right;

                float yData = EnableForZero ? 0 : TickDistance;
                float y     = originPixelPos.Y + context.ToPixelsVertical(yData);

                // doesn't lend itself to log scales...
                float pixelTick = context.ToPixelsVertical(TickDistance);

                while (y < bottomBound)
                {
                    Image <Rgba32> generatedLabel = GenerateLabel(yData, options);
                    renderContext.DrawImage(generatedLabel, generatedLabel.Size(), new Point((int)originPixelPos.X, (int)y), options);

                    y     += pixelTick;
                    yData += TickDistance;
                }

                yData = -TickDistance;
                y     = originPixelPos.Y + context.ToPixelsVertical(yData);


                while (y > topBound)
                {
                    Image <Rgba32> generatedLabel = GenerateLabel(yData, options);
                    renderContext.DrawImage(generatedLabel, generatedLabel.Size(), new Point((int)originPixelPos.X, (int)y), options);

                    y     -= pixelTick;
                    yData -= TickDistance;
                }
            }
        }