private void CalculateMultiReturn()
      {
        double mult = 2 * Math.PI / 800;
        double r, g, b;
        int index = 0;

        // Assign the parser variables
        ParserVariable x = new ParserVariable(0);
        ParserVariable y = new ParserVariable(0);
        muParser.Parser p = new muParser.Parser(muParser.Parser.EBaseType.tpDOUBLE);
        p.DefineOprt("%", new Parser.Fun2Delegate(mod), 2);
        p.SetExpr(m_parserImg[0].GetExpr() + "," + m_parserImg[1].GetExpr() + "," + m_parserImg[2].GetExpr());
        p.DefineVar("x", x);
        p.DefineVar("y", y);

        for (int yi = 0; yi < pbImage.Height; ++yi)
        {
          y.Value = (yi - 400) * mult;
          for (int xi = 0; xi < pbImage.Width; ++xi)
          {
            x.Value = (xi - 400) * mult;

            int nNum;
            double[] ret = p.EvalMultiExpr();
            r = GetColorComponent(ret[0]);
            g = GetColorComponent(ret[1]);
            b = GetColorComponent(ret[2]);

            m_data[index] = (byte)(r * 255);
            m_data[index + 1] = (byte)(g * 255);
            m_data[index + 2] = (byte)(b * 255);
            index += 3;
          }
        }
      }
      public WndSample()
      {
        InitializeComponent();
        CreateInitialImage();
        PopulatePresets();

        cbDec.SelectedIndex = 0;
        cbArg.SelectedIndex = 1;
        m_data = new byte[pbImage.Width * pbImage.Height * 3];
        rbNormal.Checked = true;

        try
        {
          m_parser = new Parser(Parser.EBaseType.tpDOUBLE);
          lbVersion.Text = String.Format("muParser V{0}", m_parser.GetVersion());
          m_parser.DefineFun("fun1", new Parser.Fun1Delegate(fun1), true);
          m_parser.DefineFun("fun3", new Parser.Fun3Delegate(fun3), true);
          m_parser.DefineFun("fun4", new Parser.Fun4Delegate(fun4), true);
          m_parser.DefineFun("fun5", new Parser.Fun5Delegate(fun5), true);
          m_parser.DefineFun("fun6", new Parser.Fun6Delegate(fun6), true);
          m_parser.DefineFun("fun7", new Parser.Fun7Delegate(fun7), true);
          m_parser.DefineFun("fun8", new Parser.Fun8Delegate(fun8), true);
          m_parser.DefineFun("fun9", new Parser.Fun9Delegate(fun9), true);
          m_parser.DefineFun("fun10", new Parser.Fun10Delegate(fun10), true);

          m_parser.DefineFun("prod", new Parser.MultFunDelegate(prod), true);
          m_parser.DefineOprt("%", new Parser.Fun2Delegate(mod), 2);
          m_parser.DefineOprt("and", new Parser.Fun2Delegate(mod), 2);

          //m_parser.DefinePostfixOprt("m", new muParser.Parser.Fun1Delegate(milli));
          m_parser.DefineInfixOprt("!", new muParser.Parser.Fun1Delegate(not), muParser.Parser.EPrec.prLOGIC);

          m_parser.DefineVar("ans", m_ans);
          m_parser.DefineVar("my_var1", m_val1);
          m_parser.DefineVar("my_var2", m_val2);

          // Initialize parsers used for the image calculation
          for (int i = 0; i < 3; ++i)
          {
            m_parserImg[i] = new Parser(Parser.EBaseType.tpDOUBLE);
            m_parserImg[i].DefineOprt("%", new Parser.Fun2Delegate(mod), 2);
          }

          PreCalculateBulkVariables();
        }
        catch (ParserException exc)
        {
          DumpException(exc);
        }

        m_history = new List<String>();
      }
Beispiel #3
0
      public WndSample()
      {
        InitializeComponent();
        CreateInitialImage();
        PopulatePresets();

        cbDec.SelectedIndex = 0;
        cbArg.SelectedIndex = 1;
        m_data = new byte[pbImage.Width * pbImage.Height * 3];
        
        try
        {
          m_parser = new Parser();
          lbVersion.Text = String.Format("muParserSSE V{0}", m_parser.GetVersion());
          m_parser.DefineFun("fun1", new Parser.Fun1Delegate(fun1), true);
          m_parser.DefineFun("fun3", new Parser.Fun3Delegate(fun3), true);
          m_parser.DefineFun("fun4", new Parser.Fun4Delegate(fun4), true);
          m_parser.DefineFun("fun5", new Parser.Fun5Delegate(fun5), true);

          //m_parser.DefinePostfixOprt("m", new muParser.Parser.Fun1Delegate(milli));
          m_parser.DefineInfixOprt("!", new muParser.Parser.Fun1Delegate(not), muParser.Parser.EPrec.prLOGIC);

          m_parser.DefineVar("ans", m_ans);
          m_parser.DefineVar("my_var1", m_val1);
          m_parser.DefineVar("my_var2", m_val2);

          // Initialize parsers used for the image calculation
          for (int i = 0; i < 3; ++i)
          {
            m_parserImg[i] = new Parser();
          }
        }
        catch (ParserException exc)
        {
          DumpException(exc);
        }
      
        m_history = new List<String>();
      }
Beispiel #4
0
        public WndSample()
        {
            InitializeComponent();
            CreateInitialImage();
            PopulatePresets();

            cbDec.SelectedIndex = 0;
            cbArg.SelectedIndex = 1;
            m_data = new byte[pbImage.Width * pbImage.Height * 3];

            try
            {
              m_parser = new Parser();
              lbVersion.Text = String.Format("muParserSSE V{0}", m_parser.GetVersion());
              m_parser.DefineFun("fun1", new Parser.Fun1Delegate(fun1), true);
              m_parser.DefineFun("fun3", new Parser.Fun3Delegate(fun3), true);
              m_parser.DefineFun("fun4", new Parser.Fun4Delegate(fun4), true);
              m_parser.DefineFun("fun5", new Parser.Fun5Delegate(fun5), true);

              //m_parser.DefinePostfixOprt("m", new muParser.Parser.Fun1Delegate(milli));
              m_parser.DefineInfixOprt("!", new muParser.Parser.Fun1Delegate(not), muParser.Parser.EPrec.prLOGIC);

              m_parser.DefineVar("ans", m_ans);
              m_parser.DefineVar("my_var1", m_val1);
              m_parser.DefineVar("my_var2", m_val2);

              // Initialize parsers used for the image calculation
              for (int i = 0; i < 3; ++i)
              {
            m_parserImg[i] = new Parser();
              }
            }
            catch (ParserException exc)
            {
              DumpException(exc);
            }

            m_history = new List<String>();
        }
 public CalcState(ManualResetEvent reset, muParser.Parser parser, int offset)
 {
     Reset = reset;
     Parser = parser;
     Offset = offset;
 }