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); } } }
public T y(T x) { if (x.LessThan(0.0)) { x = M.Zero <T>(); } if (x.GreaterThan(1.0)) { x = M.One <T>(); } T val = m_spline.Get(x); if (val.LessThan(0.0)) { val = M.Zero <T>(); } if (val.GreaterThan(1.0)) { val = M.One <T>(); } return(val); }