Ejemplo n.º 1
0
        public spline_ctrl_impl(T x1, T y1, T x2, T y2,
                                uint num_pnt)
            : base(x1, y1, x2, y2)
        {
            m_curve_pnt  = new PathStorage <T>();
            m_curve_poly = new ConvStroke <T>(m_curve_pnt);
            m_ellipse    = new Ellipse <T>();

            m_num_pnt      = (num_pnt);
            m_border_width = M.One <T>();
            m_border_extra = M.Zero <T>();
            m_curve_width  = M.One <T>();
            m_point_size   = M.New <T>(3.0);
            m_curve_poly   = new ConvStroke <T>(m_curve_pnt);
            m_idx          = (0);
            m_vertex       = (0);
            m_active_pnt   = (-1);
            m_move_pnt     = (-1);
            m_pdx          = M.Zero <T>();
            m_pdy          = M.Zero <T>();
            if (m_num_pnt < 4)
            {
                m_num_pnt = 4;
            }
            if (m_num_pnt > 32)
            {
                m_num_pnt = 32;
            }

            for (int i = 0; i < m_num_pnt; i++)
            {
                m_xp[i] = M.New <T>(i).Divide(m_num_pnt - 1);
                m_yp[i] = M.New <T>(0.5);
            }
            calc_spline_box();
            update_spline();
            {
                m_spline.Init((int)m_num_pnt, m_xp, m_yp);
                for (int i = 0; i < 256; i++)
                {
                    m_spline_values[i] = m_spline.Get(M.New <T>(i).Divide(255.0));
                    if (m_spline_values[i].LessThan(0.0))
                    {
                        m_spline_values[i] = M.Zero <T>();
                    }
                    if (m_spline_values[i].GreaterThan(1.0))
                    {
                        m_spline_values[i] = M.One <T>();
                    }
                    m_spline_values8[i] = (byte)(m_spline_values[i].ToDouble() * 255.0);
                }
            }
        }
Ejemplo n.º 2
0
        public void values(T kx1, T ky1, T kx2, T ky2)
        {
            if (kx1.LessThan(0.001))
            {
                kx1 = M.New <T>(0.001);
            }
            if (kx1.GreaterThan(1.999))
            {
                kx1 = M.New <T>(1.999);
            }
            if (ky1.LessThan(0.001))
            {
                ky1 = M.New <T>(0.001);
            }
            if (ky1.GreaterThan(1.999))
            {
                ky1 = M.New <T>(1.999);
            }
            if (kx2.LessThan(0.001))
            {
                kx2 = M.New <T>(0.001);
            }
            if (kx2.GreaterThan(1.999))
            {
                kx2 = M.New <T>(1.999);
            }
            if (ky2.LessThan(0.001))
            {
                ky2 = M.New <T>(0.001);
            }
            if (ky2.GreaterThan(1.999))
            {
                ky2 = M.New <T>(1.999);
            }

            m_x[0] = M.Zero <T>();
            m_y[0] = M.Zero <T>();
            m_x[1] = kx1.Multiply(0.25);
            m_y[1] = ky1.Multiply(0.25);
            m_x[2] = M.One <T>().Subtract(kx2.Multiply(0.25));
            m_y[2] = M.One <T>().Subtract(ky2.Multiply(0.25));
            m_x[3] = M.One <T>();
            m_y[3] = M.One <T>();

            m_spline.Init(4, m_x, m_y);

            int i;

            for (i = 0; i < 256; i++)
            {
                m_gamma[i] = (byte)(y(M.New <T>(i).Divide(255.0)).ToDouble() * 255.0);
            }
        }