Пример #1
0
        private void InitializeLocalVariable()
        {
            DrawMode();
            GraphicFunctions.a = 0;
            GraphicFunctions.b = 10;
            GraphicFunctions.c = 0;
            GraphicFunctions.d = 10;
            GraphicFunctions.w = pictureBox1.Width;
            GraphicFunctions.h = pictureBox1.Height;

            domain = new Domain();
            ClearWindow();
            polygon       = new Polygon();
            config        = new Config();
            u             = null;
            pallette      = null;
            textBox1.Text = "";

            mode = ProgramMode.DrawMode;
            Matrix k = new Matrix(2, 2);

            k[0, 0] = 4;
            k[0, 1] = 0;
            k[1, 0] = 0;
            k[1, 1] = 3;
            model   = new Model(k, 0, 1);
        }
Пример #2
0
 private void DrawResult()
 {
     ClearWindow();
     pallette = new Pallette(u.Min(), u.Max());
     foreach (Triangle tr in domain.mesh.triangles)
     {
         GraphicFunctions.FillTriangle(g, domain.mesh.nodes[tr.IndexA], domain.mesh.nodes[tr.IndexB], domain.mesh.nodes[tr.IndexC],
                                       u[tr.IndexA], u[tr.IndexB], u[tr.IndexC], pallette);
     }
     pictureBox1.Image = btm;
 }
        private static void FillHalfTriangle(Graphics grfx, Point a, Point b, Point c, double va, double v, Pallette pallette)
        {
            if ((a.Y == b.Y) && (b.Y == c.Y))
            {
                return;
            }
            if ((a.X == b.X) && (b.X == c.X))
            {
                return;
            }

            PathGradientBrush pthGrBrush = new PathGradientBrush(new Point[] { a, b, c });


            ColorBlend colorBlend = new ColorBlend();

            if (va < v)
            {
                List <Color> l = pallette.GetColorPallette(va, v);
                l.Reverse();
                colorBlend.Colors = l.ToArray();
            }
            else
            {
                List <Color> l = pallette.GetColorPallette(v, va);
                colorBlend.Colors = l.ToArray();
            }

            colorBlend.Positions           = pallette.GetRelativaPossition();
            pthGrBrush.InterpolationColors = colorBlend;
            pthGrBrush.CenterPoint         = a;

            grfx.FillRectangle(pthGrBrush, new Rectangle(0, 0, (int)w, (int)h));
        }
        public static void FillTriangle(Graphics g, Node pa, Node pb, Node pc, double ua, double ub, double uc, Pallette pallette)
        {
            double[] v         = new double[] { ua, ub, uc };
            Node[]   p         = new Node[] { pa, pb, pc };
            int[]    indexator = new int[v.Length];
            indexator[0] = IMin(v);
            indexator[2] = IMax(v);
            indexator[1] = 3 - indexator[0] - indexator[2];

            Node   a  = p[indexator[0]];
            Node   b  = p[indexator[2]];
            Node   c  = p[indexator[1]];
            double vA = v[indexator[0]];
            double vB = v[indexator[2]];
            double vC = v[indexator[1]];
            double vD = v[indexator[1]];

            Node d = AdditionNode(v, p);

            FillHalfTriangle(g, ConvertToScreen(a), ConvertToScreen(d), ConvertToScreen(c), vA, vC, pallette);
            FillHalfTriangle(g, ConvertToScreen(b), ConvertToScreen(d), ConvertToScreen(c), vB, vC, pallette);
        }