예제 #1
0
        private void DrawColorFill(Graphics g, Surfaces[] ScaledSurfaces)
        {
            int NSurf = ScaledSurfaces.Length;

            for (int i = 0; i < NSurf; i++)
            {
                int NSide = ScaledSurfaces[i].Sides.Length;
                for (int j = 0; j < NSide; j++)
                {
                    int NAreas = ScaledSurfaces[i].Sides[j].Areas.Length;
                    for (int k = 0; k < NAreas; k++)
                    {
                        Vector[] X = ScaledSurfaces[i].Sides[j].Areas[k];
                        double[] Y = ScaledSurfaces[i].Sides[j].AreaValues[k].Values;
                        Color    C1, C2;
                        Vector   X1, X2;
                        int      M = 5;
                        Single[] XColor;
                        Color[]  Colors;
                        OOPsColor.Calculate_LineGradientBrushParameters_ForPolygon(X, Y, out X1, out X2, out C1, out C2, M, out XColor, out Colors);
                        PointF P1 = GetGraphicsPoint(X1);
                        PointF P2 = GetGraphicsPoint(X2);
                        LinearGradientBrush MyBrush      = new LinearGradientBrush(P1, P2, C1, C2);
                        ColorBlend          myColorBlend = new ColorBlend(M);
                        myColorBlend.Colors         = Colors;
                        myColorBlend.Positions      = XColor;
                        MyBrush.InterpolationColors = myColorBlend;
                        PointF[] Points = GetGraphicsPoint(X);
                        g.FillPolygon(MyBrush, Points);
                    }
                }
            }
        }
예제 #2
0
        public static void Calculate_Gradient_PointsAndValues(Vector[] X, double[] Y, out Vector X1, out Vector X2, out double Y1, out double Y2)
        {
            Vector[] DX;
            Vector   Center_X, Gradient;
            double   Center_Y;

            OOPsColor.Calculate_YGradient(X, Y, out Center_X, out DX, out Center_Y, out Gradient);
            double d_min, d_max;
            Vector n = new Vector(2);

            if (Gradient.Magnitude() > 1.0E-20)
            {
                n = Gradient.UnitVector();
            }
            else
            {
                n.Values[0] = 1.0D;
            }
            Find_MaxMinAlongDirection(DX, n, out d_min, out d_max);

            d_min *= 1.05D;
            d_max *= 1.05D;

            X1 = Center_X + d_min * n;
            X2 = Center_X + d_max * n;

            double n_Dot_Gradient = Vector.DotProduct(n, Gradient);

            Y1 = Center_Y + d_min * n_Dot_Gradient;
            Y2 = Center_Y + d_max * n_Dot_Gradient;
        }
예제 #3
0
        public static void Calculate_LineGradientBrushParameters_ForPolygon(Vector[] X, double[] Y, out Vector X1, out Vector X2, out Color C1, out Color C2, int N, out Single[] XColor, out Color[] Colors)
        {
            double Y1, Y2;

            Calculate_Gradient_PointsAndValues(X, Y, out X1, out X2, out Y1, out Y2);
            C1 = ColorScale(Y1);
            C2 = ColorScale(Y2);
            OOPsColor.GetColorsToUse(N, Y1, Y2, out XColor, out Colors);
        }
예제 #4
0
        public void AddColorScale(ref Graphics g)
        {
            Vector V_Width = new Vector(2);

            V_Width.Values[0] = ScaleWidth;
            Vector V_Height = new Vector(2);

            V_Height.Values[1] = ScaleHeight;

            int    NCB  = NumberOfColorBlocks;
            double NCBD = Convert.ToDouble(NCB);
            Vector DH   = V_Height / NCBD;

            for (int i = 0; i < NCB; i++)
            {
                Vector     CB_TopLeft = TopLeft + Convert.ToDouble(i) * DH;
                Color      fillColor  = OOPsColor.ColorScale(1.0D - Convert.ToDouble(i) / (NCBD - 1.0D));
                SolidBrush brush      = new SolidBrush(fillColor);
                DrawingTools.FillRectangle(g, brush, CB_TopLeft, ScaleWidth, DH.Values[1]);
            }
            Vector TopRight    = TopLeft + V_Width;
            Vector BottomRight = TopRight + V_Height;

            DrawingTools.DrawLine(g, AxisPen, TopRight, BottomRight);

            double NTicksD = Convert.ToDouble(NumberOfTicks);

            V_Height.Values[1] -= LineWidth;
            DH = V_Height / (NTicksD - 1.0D);
            Vector Start = TopRight;

            Start.Values[1] += LineWidth / 2.0D;
            Vector End = new Vector(Start);

            End.Values[0] += TickLength;
            for (int i = 0; i < NumberOfTicks; i++)
            {
                Vector H = Convert.ToDouble(i) * DH;
                DrawingTools.DrawLine(g, AxisPen, Start + H, End + H);
                Vector TitleTopC = End + H;
                TitleTopC.Values[0] += TickPad + ScaleText[i].Width / 2.0D;
                TitleTopC.Values[1] -= ScaleText[i].Height / 2.0D;
                ScaleText[i].DrawTitle(g, TitleTopC);
            }
        }