示例#1
0
        /*
         * public virtual ~gradients_application()
         * {
         *  FILE* fd = fopen(full_file_name("settings.dat"), "w");
         *  fprintf(fd, "%f\n", m_center_x);
         *  fprintf(fd, "%f\n", m_center_y);
         *  fprintf(fd, "%f\n", m_scale);
         *  fprintf(fd, "%f\n", m_angle);
         *  fprintf(fd, "%f\n", m_spline_r.x(0));
         *  fprintf(fd, "%f\n", m_spline_r.y(0));
         *  fprintf(fd, "%f\n", m_spline_r.x(1));
         *  fprintf(fd, "%f\n", m_spline_r.y(1));
         *  fprintf(fd, "%f\n", m_spline_r.x(2));
         *  fprintf(fd, "%f\n", m_spline_r.y(2));
         *  fprintf(fd, "%f\n", m_spline_r.x(3));
         *  fprintf(fd, "%f\n", m_spline_r.y(3));
         *  fprintf(fd, "%f\n", m_spline_r.x(4));
         *  fprintf(fd, "%f\n", m_spline_r.y(4));
         *  fprintf(fd, "%f\n", m_spline_r.x(5));
         *  fprintf(fd, "%f\n", m_spline_r.y(5));
         *  fprintf(fd, "%f\n", m_spline_g.x(0));
         *  fprintf(fd, "%f\n", m_spline_g.y(0));
         *  fprintf(fd, "%f\n", m_spline_g.x(1));
         *  fprintf(fd, "%f\n", m_spline_g.y(1));
         *  fprintf(fd, "%f\n", m_spline_g.x(2));
         *  fprintf(fd, "%f\n", m_spline_g.y(2));
         *  fprintf(fd, "%f\n", m_spline_g.x(3));
         *  fprintf(fd, "%f\n", m_spline_g.y(3));
         *  fprintf(fd, "%f\n", m_spline_g.x(4));
         *  fprintf(fd, "%f\n", m_spline_g.y(4));
         *  fprintf(fd, "%f\n", m_spline_g.x(5));
         *  fprintf(fd, "%f\n", m_spline_g.y(5));
         *  fprintf(fd, "%f\n", m_spline_b.x(0));
         *  fprintf(fd, "%f\n", m_spline_b.y(0));
         *  fprintf(fd, "%f\n", m_spline_b.x(1));
         *  fprintf(fd, "%f\n", m_spline_b.y(1));
         *  fprintf(fd, "%f\n", m_spline_b.x(2));
         *  fprintf(fd, "%f\n", m_spline_b.y(2));
         *  fprintf(fd, "%f\n", m_spline_b.x(3));
         *  fprintf(fd, "%f\n", m_spline_b.y(3));
         *  fprintf(fd, "%f\n", m_spline_b.x(4));
         *  fprintf(fd, "%f\n", m_spline_b.y(4));
         *  fprintf(fd, "%f\n", m_spline_b.x(5));
         *  fprintf(fd, "%f\n", m_spline_b.y(5));
         *  fprintf(fd, "%f\n", m_spline_a.x(0));
         *  fprintf(fd, "%f\n", m_spline_a.y(0));
         *  fprintf(fd, "%f\n", m_spline_a.x(1));
         *  fprintf(fd, "%f\n", m_spline_a.y(1));
         *  fprintf(fd, "%f\n", m_spline_a.x(2));
         *  fprintf(fd, "%f\n", m_spline_a.y(2));
         *  fprintf(fd, "%f\n", m_spline_a.x(3));
         *  fprintf(fd, "%f\n", m_spline_a.y(3));
         *  fprintf(fd, "%f\n", m_spline_a.x(4));
         *  fprintf(fd, "%f\n", m_spline_a.y(4));
         *  fprintf(fd, "%f\n", m_spline_a.x(5));
         *  fprintf(fd, "%f\n", m_spline_a.y(5));
         *  double x1,y1,x2,y2;
         *  m_profile.values(&x1, &y1, &x2, &y2);
         *  fprintf(fd, "%f\n", x1);
         *  fprintf(fd, "%f\n", y1);
         *  fprintf(fd, "%f\n", x2);
         *  fprintf(fd, "%f\n", y2);
         *  fclose(fd);
         * }
         */

        GradientsApplication(PixelFormats format, ERenderOrigin RenderOrigin)
            : base(format, RenderOrigin)
        {
            m_profile      = new gamma_ctrl <T>(10.0, 10.0, 200.0, 170.0 - 5.0);
            m_spline_r     = new spline_ctrl <T>(210, 10, 210 + 250, 5 + 40, 6);
            m_spline_g     = new spline_ctrl <T>(210, 10 + 40, 210 + 250, 5 + 80, 6);
            m_spline_b     = new spline_ctrl <T>(210, 10 + 80, 210 + 250, 5 + 120, 6);
            m_spline_a     = new spline_ctrl <T>(210, 10 + 120, 210 + 250, 5 + 160, 6);
            m_GradTypeRBox = new AGG.UI.rbox_ctrl <T>(10.0, 180.0, 200.0, 300.0);
            m_GradWrapRBox = new rbox_ctrl <T>(10, 310, 200, 375);

            m_pdx = (M.Zero <T>());
            m_pdy = M.Zero <T>();
            m_SaveData.m_center_x = (center_x);
            m_SaveData.m_center_y = (center_y);
            m_SaveData.m_scale    = M.One <T>();
            m_prev_scale          = M.One <T>();
            m_SaveData.m_angle    = M.Zero <T>();
            m_prev_angle          = M.Zero <T>();
            m_scale_x             = M.One <T>();
            m_prev_scale_x        = M.One <T>();
            m_scale_y             = M.One <T>();
            m_prev_scale_y        = M.One <T>();
            m_mouse_move          = (false);


            AddChild(m_profile);
            AddChild(m_spline_r);
            AddChild(m_spline_g);
            AddChild(m_spline_b);
            AddChild(m_spline_a);
            AddChild(m_GradTypeRBox);
            AddChild(m_GradWrapRBox);

            m_profile.border_width(2.0, 2.0);

            m_spline_r.background_color(new RGBA_Bytes(1.0, 0.8, 0.8));
            m_spline_g.background_color(new RGBA_Bytes(0.8, 1.0, 0.8));
            m_spline_b.background_color(new RGBA_Bytes(0.8, 0.8, 1.0));
            m_spline_a.background_color(new RGBA_Bytes(1.0, 1.0, 1.0));

            m_spline_r.border_width(1.0, 2.0);
            m_spline_g.border_width(1.0, 2.0);
            m_spline_b.border_width(1.0, 2.0);
            m_spline_a.border_width(1.0, 2.0);
            m_GradTypeRBox.border_width(2.0, 2.0);
            m_GradWrapRBox.border_width(2.0, 2.0);

            m_spline_r.point(0, 0.0, 1.0);
            m_spline_r.point(1, 1.0 / 5.0, 1.0 - 1.0 / 5.0);
            m_spline_r.point(2, 2.0 / 5.0, 1.0 - 2.0 / 5.0);
            m_spline_r.point(3, 3.0 / 5.0, 1.0 - 3.0 / 5.0);
            m_spline_r.point(4, 4.0 / 5.0, 1.0 - 4.0 / 5.0);
            m_spline_r.point(5, 1.0, 0.0);
            m_spline_r.update_spline();

            m_spline_g.point(0, 0.0, 1.0);
            m_spline_g.point(1, 1.0 / 5.0, 1.0 - 1.0 / 5.0);
            m_spline_g.point(2, 2.0 / 5.0, 1.0 - 2.0 / 5.0);
            m_spline_g.point(3, 3.0 / 5.0, 1.0 - 3.0 / 5.0);
            m_spline_g.point(4, 4.0 / 5.0, 1.0 - 4.0 / 5.0);
            m_spline_g.point(5, 1.0, 0.0);
            m_spline_g.update_spline();

            m_spline_b.point(0, 0.0, 1.0);
            m_spline_b.point(1, 1.0 / 5.0, 1.0 - 1.0 / 5.0);
            m_spline_b.point(2, 2.0 / 5.0, 1.0 - 2.0 / 5.0);
            m_spline_b.point(3, 3.0 / 5.0, 1.0 - 3.0 / 5.0);
            m_spline_b.point(4, 4.0 / 5.0, 1.0 - 4.0 / 5.0);
            m_spline_b.point(5, 1.0, 0.0);
            m_spline_b.update_spline();

            m_spline_a.point(0, 0.0, 1.0);
            m_spline_a.point(1, 1.0 / 5.0, 1.0);
            m_spline_a.point(2, 2.0 / 5.0, 1.0);
            m_spline_a.point(3, 3.0 / 5.0, 1.0);
            m_spline_a.point(4, 4.0 / 5.0, 1.0);
            m_spline_a.point(5, 1.0, 1.0);
            m_spline_a.update_spline();

            m_GradTypeRBox.add_item("Circular");
            m_GradTypeRBox.add_item("Diamond");
            m_GradTypeRBox.add_item("Linear");
            m_GradTypeRBox.add_item("XY");
            m_GradTypeRBox.add_item("sqrt(XY)");
            m_GradTypeRBox.add_item("Conic");
            m_GradTypeRBox.cur_item(0);

            m_GradWrapRBox.add_item("Reflect");
            m_GradWrapRBox.add_item("Repeat");
            m_GradWrapRBox.add_item("Clamp");
            m_GradWrapRBox.cur_item(0);

            /*
             * FILE* fd = fopen(full_file_name("settings.dat"), "r");
             * if(fd)
             * {
             *  float x;
             *  float y;
             *  float x2;
             *  float y2;
             *  float t;
             *
             *  fscanf(fd, "%f\n", &t); m_center_x = t;
             *  fscanf(fd, "%f\n", &t); m_center_y = t;
             *  fscanf(fd, "%f\n", &t); m_scale = t;
             *  fscanf(fd, "%f\n", &t); m_angle = t;
             *  fscanf(fd, "%f\n", &x);
             *  fscanf(fd, "%f\n", &y); m_spline_r.point(0, x, y);
             *  fscanf(fd, "%f\n", &x);
             *  fscanf(fd, "%f\n", &y); m_spline_r.point(1, x, y);
             *  fscanf(fd, "%f\n", &x);
             *  fscanf(fd, "%f\n", &y); m_spline_r.point(2, x, y);
             *  fscanf(fd, "%f\n", &x);
             *  fscanf(fd, "%f\n", &y); m_spline_r.point(3, x, y);
             *  fscanf(fd, "%f\n", &x);
             *  fscanf(fd, "%f\n", &y); m_spline_r.point(4, x, y);
             *  fscanf(fd, "%f\n", &x);
             *  fscanf(fd, "%f\n", &y); m_spline_r.point(5, x, y);
             *  fscanf(fd, "%f\n", &x);
             *  fscanf(fd, "%f\n", &y); m_spline_g.point(0, x, y);
             *  fscanf(fd, "%f\n", &x);
             *  fscanf(fd, "%f\n", &y); m_spline_g.point(1, x, y);
             *  fscanf(fd, "%f\n", &x);
             *  fscanf(fd, "%f\n", &y); m_spline_g.point(2, x, y);
             *  fscanf(fd, "%f\n", &x);
             *  fscanf(fd, "%f\n", &y); m_spline_g.point(3, x, y);
             *  fscanf(fd, "%f\n", &x);
             *  fscanf(fd, "%f\n", &y); m_spline_g.point(4, x, y);
             *  fscanf(fd, "%f\n", &x);
             *  fscanf(fd, "%f\n", &y); m_spline_g.point(5, x, y);
             *  fscanf(fd, "%f\n", &x);
             *  fscanf(fd, "%f\n", &y); m_spline_b.point(0, x, y);
             *  fscanf(fd, "%f\n", &x);
             *  fscanf(fd, "%f\n", &y); m_spline_b.point(1, x, y);
             *  fscanf(fd, "%f\n", &x);
             *  fscanf(fd, "%f\n", &y); m_spline_b.point(2, x, y);
             *  fscanf(fd, "%f\n", &x);
             *  fscanf(fd, "%f\n", &y); m_spline_b.point(3, x, y);
             *  fscanf(fd, "%f\n", &x);
             *  fscanf(fd, "%f\n", &y); m_spline_b.point(4, x, y);
             *  fscanf(fd, "%f\n", &x);
             *  fscanf(fd, "%f\n", &y); m_spline_b.point(5, x, y);
             *  fscanf(fd, "%f\n", &x);
             *  fscanf(fd, "%f\n", &y); m_spline_a.point(0, x, y);
             *  fscanf(fd, "%f\n", &x);
             *  fscanf(fd, "%f\n", &y); m_spline_a.point(1, x, y);
             *  fscanf(fd, "%f\n", &x);
             *  fscanf(fd, "%f\n", &y); m_spline_a.point(2, x, y);
             *  fscanf(fd, "%f\n", &x);
             *  fscanf(fd, "%f\n", &y); m_spline_a.point(3, x, y);
             *  fscanf(fd, "%f\n", &x);
             *  fscanf(fd, "%f\n", &y); m_spline_a.point(4, x, y);
             *  fscanf(fd, "%f\n", &x);
             *  fscanf(fd, "%f\n", &y); m_spline_a.point(5, x, y);
             *  m_spline_r.update_spline();
             *  m_spline_g.update_spline();
             *  m_spline_b.update_spline();
             *  m_spline_a.update_spline();
             *  fscanf(fd, "%f\n", &x);
             *  fscanf(fd, "%f\n", &y);
             *  fscanf(fd, "%f\n", &x2);
             *  fscanf(fd, "%f\n", &y2);
             *  m_profile.values(x, y, x2, y2);
             *  fclose(fd);
             * }
             */
        }
示例#2
0
        public Gradients()
        {
            AnchorAll();
            //m_profile = new gamma_ctrl(new Vector2(10.0, 10.0), new Vector2(190, 155.0));
            //m_spline_r = new spline_ctrl(new Vector2(210, 10), new Vector2(250, 5 + 30), 6);
            //m_spline_g = new spline_ctrl(new Vector2(210, 10 + 40), new Vector2(250, 5 + 30), 6);
            //m_spline_b = new spline_ctrl(new Vector2(210, 10 + 80), new Vector2(250, 5 + 30), 6);
            //m_spline_a = new spline_ctrl(new Vector2(210, 10 + 120), new Vector2(250, 5 + 30), 6);
            m_profile             = new gamma_ctrl(new Vector2(10.0, 10.0), new Vector2(190, 155.0));
            m_spline_r            = new spline_ctrl(new Vector2(210, 10), new Vector2(250, 5 + 30), 6);
            m_spline_g            = new spline_ctrl(new Vector2(210, 10 + 40), new Vector2(250, 5 + 30), 6);
            m_spline_b            = new spline_ctrl(new Vector2(210, 10 + 80), new Vector2(250, 5 + 30), 6);
            m_spline_a            = new spline_ctrl(new Vector2(210, 10 + 120), new Vector2(250, 5 + 30), 6);
            m_profile.MouseMove  += new MouseEventHandler(NeedRedraw);
            m_spline_r.MouseMove += new MouseEventHandler(NeedRedraw);
            m_spline_g.MouseMove += new MouseEventHandler(NeedRedraw);
            m_spline_b.MouseMove += new MouseEventHandler(NeedRedraw);
            m_spline_a.MouseMove += new MouseEventHandler(NeedRedraw);
            m_GradTypeRBox        = new RadioButtonGroup(new Vector2(10.0, 180.0), new Vector2(190.0, 120.0));
            m_GradWrapRBox        = new RadioButtonGroup(new Vector2(10, 310), new Vector2(190, 65));

            m_pdx = (0.0);
            m_pdy = (0.0);
            m_SaveData.m_center_x = (center_x);
            m_SaveData.m_center_y = (center_y);
            m_SaveData.m_scale    = (1.0);
            m_prev_scale          = (1.0);
            m_SaveData.m_angle    = (0.0);
            m_prev_angle          = (0.0);
            m_scale_x             = (1.0);
            m_prev_scale_x        = (1.0);
            m_scale_y             = (1.0);
            m_prev_scale_y        = (1.0);
            m_mouse_move          = (false);


            AddChild(m_profile);
            AddChild(m_spline_r);
            AddChild(m_spline_g);
            AddChild(m_spline_b);
            AddChild(m_spline_a);
            AddChild(m_GradTypeRBox);
            AddChild(m_GradWrapRBox);

            m_profile.border_width(2.0, 2.0);

            m_spline_r.background_color(new RGBA_Bytes(1.0, 0.8, 0.8));
            m_spline_g.background_color(new RGBA_Bytes(0.8, 1.0, 0.8));
            m_spline_b.background_color(new RGBA_Bytes(0.8, 0.8, 1.0));
            m_spline_a.background_color(new RGBA_Bytes(1.0, 1.0, 1.0));

            m_spline_r.border_width(1.0, 2.0);
            m_spline_g.border_width(1.0, 2.0);
            m_spline_b.border_width(1.0, 2.0);
            m_spline_a.border_width(1.0, 2.0);

            m_spline_r.point(0, 0.0, 1.0);
            m_spline_r.point(1, 1.0 / 5.0, 1.0 - 1.0 / 5.0);
            m_spline_r.point(2, 2.0 / 5.0, 1.0 - 2.0 / 5.0);
            m_spline_r.point(3, 3.0 / 5.0, 1.0 - 3.0 / 5.0);
            m_spline_r.point(4, 4.0 / 5.0, 1.0 - 4.0 / 5.0);
            m_spline_r.point(5, 1.0, 0.0);
            m_spline_r.update_spline();

            m_spline_g.point(0, 0.0, 1.0);
            m_spline_g.point(1, 1.0 / 5.0, 1.0 - 1.0 / 5.0);
            m_spline_g.point(2, 2.0 / 5.0, 1.0 - 2.0 / 5.0);
            m_spline_g.point(3, 3.0 / 5.0, 1.0 - 3.0 / 5.0);
            m_spline_g.point(4, 4.0 / 5.0, 1.0 - 4.0 / 5.0);
            m_spline_g.point(5, 1.0, 0.0);
            m_spline_g.update_spline();

            m_spline_b.point(0, 0.0, 1.0);
            m_spline_b.point(1, 1.0 / 5.0, 1.0 - 1.0 / 5.0);
            m_spline_b.point(2, 2.0 / 5.0, 1.0 - 2.0 / 5.0);
            m_spline_b.point(3, 3.0 / 5.0, 1.0 - 3.0 / 5.0);
            m_spline_b.point(4, 4.0 / 5.0, 1.0 - 4.0 / 5.0);
            m_spline_b.point(5, 1.0, 0.0);
            m_spline_b.update_spline();

            m_spline_a.point(0, 0.0, 1.0);
            m_spline_a.point(1, 1.0 / 5.0, 1.0);
            m_spline_a.point(2, 2.0 / 5.0, 1.0);
            m_spline_a.point(3, 3.0 / 5.0, 1.0);
            m_spline_a.point(4, 4.0 / 5.0, 1.0);
            m_spline_a.point(5, 1.0, 1.0);
            m_spline_a.update_spline();

            m_GradTypeRBox.AddRadioButton("Circular");
            m_GradTypeRBox.AddRadioButton("Diamond");
            m_GradTypeRBox.AddRadioButton("Linear");
            m_GradTypeRBox.AddRadioButton("XY");
            m_GradTypeRBox.AddRadioButton("sqrt(XY)");
            m_GradTypeRBox.AddRadioButton("Conic");
            m_GradTypeRBox.SelectedIndex = 0;

            m_GradWrapRBox.AddRadioButton("Reflect");
            m_GradWrapRBox.AddRadioButton("Repeat");
            m_GradWrapRBox.AddRadioButton("Clamp");
            m_GradWrapRBox.SelectedIndex = 0;
        }