// Use this for initialization void Start() { int varSize = 100; char[] uResult = new char[varSize]; // Initialize the Python Interpreter GameMath.PythonFunctions.PyInit(); // Create a quadratic expression initialized to 1*(1*x - 2)**2 + 1 GameMath.QuadExpr quadCurve = new GameMath.QuadExpr(1, 1, 2, 1); quadCurve.ResourceFolder.StrData = "Equation Images"; quadCurve.FileName.StrData = "newEQ.png"; quadCurve.SetEqColor(1, 1, 0); quadCurve.GenerateEqImage(); //Debug.Log (quadCurve.REqColor.ToString ());//quadCurve.ExprString); //Debug.Log (System.Environment.Version); //CallCPPFunc.CallCPPFunc.PyCallGenEqSharp("genEQ", "genPNG", quadCurve.ExprString.ToCharArray(), origEqColor.r.ToString().ToCharArray(), origEqColor.g.ToString().ToCharArray(), origEqColor.b.ToString().ToCharArray(), origEqColor.a.ToString().ToCharArray(), "300".ToCharArray(), "Equation Images".ToCharArray(), "test1.png".ToCharArray(), uResult); }
// Use this for initialization void Start() { int varSize = 100; char[] uResult = new char[varSize]; // Initialize the Python Interpreter GameMath.PythonFunctions.PyInit (); // Create a quadratic expression initialized to 1*(1*x - 2)**2 + 1 GameMath.QuadExpr quadCurve = new GameMath.QuadExpr(1, 1, 2, 1); quadCurve.ResourceFolder.StrData = "Equation Images"; quadCurve.FileName.StrData = "newEQ.png"; quadCurve.SetEqColor (1, 1, 0); quadCurve.GenerateEqImage(); //Debug.Log (quadCurve.REqColor.ToString ());//quadCurve.ExprString); //Debug.Log (System.Environment.Version); //CallCPPFunc.CallCPPFunc.PyCallGenEqSharp("genEQ", "genPNG", quadCurve.ExprString.ToCharArray(), origEqColor.r.ToString().ToCharArray(), origEqColor.g.ToString().ToCharArray(), origEqColor.b.ToString().ToCharArray(), origEqColor.a.ToString().ToCharArray(), "300".ToCharArray(), "Equation Images".ToCharArray(), "test1.png".ToCharArray(), uResult); }
private void PythonEquationGenerator(GameObject equationObject, string fileName, string testImageName) { GameMath.Expression Curve = null; switch ((int)eqChoose.GetComponent <UpdateValue>().ReturnVariable()) { case 0: { Curve = new GameMath.LinearExpr(); break; } case 1: { Curve = new GameMath.QuadExpr(); break; } case 2: { Curve = new GameMath.CubeExpr(); break; } case 3: { Curve = new GameMath.AbsExpr(); break; } case 4: { Curve = new GameMath.SqrtExpr(); break; } case 5: { Curve = new GameMath.CbrtExpr(); break; } case 6: { Curve = new GameMath.RecipExpr(); break; } default: { Curve = new GameMath.LinearExpr(); break; } } Curve.AVertStretch.FloatData = equationObject.GetComponent <UserEquationInput>().VarA; Curve.BHorizStretch.FloatData = equationObject.GetComponent <UserEquationInput>().VarB; Curve.CHorizShift.FloatData = equationObject.GetComponent <UserEquationInput>().VarC; Curve.DVertShift.FloatData = equationObject.GetComponent <UserEquationInput>().VarD; //Debug.Log(Curve.ExprString.StrData); Curve.PyExpression(); Curve.ResourceFolder.StrData = "Equation Images"; Curve.FileName.StrData = fileName; Curve.SetEqColor(equationObject.GetComponent <UserEquationInput>().CurrentColor.r, equationObject.GetComponent <UserEquationInput>().CurrentColor.g, equationObject.GetComponent <UserEquationInput>().CurrentColor.b); Debug.Log(Application.persistentDataPath); //create PNG for Equation Curve.GenerateEqImage(); /* * GameMath.QuadExpr quadCurve = new GameMath.QuadExpr(); * * quadCurve.AVertStretch.FloatData = equationObject.GetComponent<UserEquationInput>().VarA; * quadCurve.BHorizStretch.FloatData = equationObject.GetComponent<UserEquationInput>().VarB; * quadCurve.CHorizShift.FloatData = equationObject.GetComponent<UserEquationInput>().VarC; * quadCurve.DVertShift.FloatData = equationObject.GetComponent<UserEquationInput>().VarD; * * quadCurve.PyExpression(); * * quadCurve.ResourceFolder.StrData = "Equation Images"; * quadCurve.FileName.StrData = fileName; * * quadCurve.SetEqColor(equationObject.GetComponent<UserEquationInput>().CurrentColor.r, equationObject.GetComponent<UserEquationInput>().CurrentColor.g, equationObject.GetComponent<UserEquationInput>().CurrentColor.b); * * Debug.Log(quadCurve.ExprString.StrData); * * //create PNG for Equation * quadCurve.GenerateEqImage(); */ //grab image from file and display UnityEditor.AssetDatabase.Refresh(); string rootF = "Equation Images/" + testImageName; Sprite myEquation_image = Resources.Load(rootF, typeof(Sprite)) as Sprite; //Debug.Log (rootF); Equation_Output_ref.GetComponent <Image> ().sprite = myEquation_image; }
private void PythonPlotGenerator(GameObject equationObject, string fileName, string testImageName) { GameMath.Plot newCurve = new GameMath.Plot(); GameMath.Expression newExpr = null; switch ((int)eqChoose.GetComponent <UpdateValue>().ReturnVariable()) { case 0: { newExpr = new GameMath.LinearExpr(); break; } case 1: { newExpr = new GameMath.QuadExpr(); break; } case 2: { newExpr = new GameMath.CubeExpr(); break; } case 3: { newExpr = new GameMath.AbsExpr(); break; } case 4: { newExpr = new GameMath.SqrtExpr(); break; } case 5: { newExpr = new GameMath.CbrtExpr(); break; } case 6: { newExpr = new GameMath.RecipExpr(); break; } default: { newExpr = new GameMath.LinearExpr(); break; } } newExpr.AVertStretch.FloatData = equationObject.GetComponent <UserEquationInput>().VarA; newExpr.BHorizStretch.FloatData = equationObject.GetComponent <UserEquationInput>().VarB; newExpr.CHorizShift.FloatData = equationObject.GetComponent <UserEquationInput>().VarC; newExpr.DVertShift.FloatData = equationObject.GetComponent <UserEquationInput>().VarD; newExpr.PyExpression(); Debug.Log(newExpr.PlotString.StrData); //GameMath.AbsExpr newExpr = new GameMath.AbsExpr(equationObject.GetComponent<UserEquationInput>().VarA, equationObject.GetComponent<UserEquationInput>().VarB, equationObject.GetComponent<UserEquationInput>().VarC, equationObject.GetComponent<UserEquationInput>().VarD); //newCurve.Expr.StrData = "1*(1*x+0)**0.5+0"; //newCurve.Expr.StrData = equationObject.GetComponent<UserEquationInput> ().CurrentPythonEq; newCurve.Expr.StrData = newExpr.PlotString.StrData; //Debug.Log(newExpr.PlotString.StrData); //newCurve.XStart.FloatData = 0f; GameMath.Axes newGraph = new GameMath.Axes(); newGraph.AddCurve(newCurve); newGraph.ResourceFolder.StrData = "Plot Figures"; //newGraph.FileName = "newGRAPH.png"; newGraph.FileName.StrData = fileName; newGraph.GenerateGrid(); newGraph.GeneratePlot(0); UnityEditor.AssetDatabase.Refresh(); string rootF = "Plot Figures/" + testImageName + "_AXES"; Sprite myPlot_image = Resources.Load(rootF, typeof(Sprite)) as Sprite; Plot_Output_ref.GetComponent <Image> ().sprite = myPlot_image; string rootC = "Plot Figures/" + testImageName + "_0"; Sprite myCurve_image = Resources.Load(rootC, typeof(Sprite)) as Sprite; Curve_Output_ref.GetComponent <Image> ().sprite = myCurve_image; }
private void PythonEquationGenerator(GameObject equationObject, string fileName, string testImageName) { GameMath.Expression Curve = null; switch ((int)eqChoose.GetComponent<UpdateValue>().ReturnVariable()) { case 0: { Curve = new GameMath.LinearExpr(); break; } case 1: { Curve = new GameMath.QuadExpr(); break; } case 2: { Curve = new GameMath.CubeExpr(); break; } case 3: { Curve = new GameMath.AbsExpr(); break; } case 4: { Curve = new GameMath.SqrtExpr(); break; } case 5: { Curve = new GameMath.CbrtExpr(); break; } case 6: { Curve = new GameMath.RecipExpr(); break; } default: { Curve = new GameMath.LinearExpr(); break; } } Curve.AVertStretch.FloatData = equationObject.GetComponent<UserEquationInput>().VarA; Curve.BHorizStretch.FloatData = equationObject.GetComponent<UserEquationInput>().VarB; Curve.CHorizShift.FloatData = equationObject.GetComponent<UserEquationInput>().VarC; Curve.DVertShift.FloatData = equationObject.GetComponent<UserEquationInput>().VarD; //Debug.Log(Curve.ExprString.StrData); Curve.PyExpression(); Curve.ResourceFolder.StrData = "Equation Images"; Curve.FileName.StrData = fileName; Curve.SetEqColor(equationObject.GetComponent<UserEquationInput>().CurrentColor.r, equationObject.GetComponent<UserEquationInput>().CurrentColor.g, equationObject.GetComponent<UserEquationInput>().CurrentColor.b); Debug.Log(Application.persistentDataPath); //create PNG for Equation Curve.GenerateEqImage(); /* GameMath.QuadExpr quadCurve = new GameMath.QuadExpr(); quadCurve.AVertStretch.FloatData = equationObject.GetComponent<UserEquationInput>().VarA; quadCurve.BHorizStretch.FloatData = equationObject.GetComponent<UserEquationInput>().VarB; quadCurve.CHorizShift.FloatData = equationObject.GetComponent<UserEquationInput>().VarC; quadCurve.DVertShift.FloatData = equationObject.GetComponent<UserEquationInput>().VarD; quadCurve.PyExpression(); quadCurve.ResourceFolder.StrData = "Equation Images"; quadCurve.FileName.StrData = fileName; quadCurve.SetEqColor(equationObject.GetComponent<UserEquationInput>().CurrentColor.r, equationObject.GetComponent<UserEquationInput>().CurrentColor.g, equationObject.GetComponent<UserEquationInput>().CurrentColor.b); Debug.Log(quadCurve.ExprString.StrData); //create PNG for Equation quadCurve.GenerateEqImage(); */ //grab image from file and display UnityEditor.AssetDatabase.Refresh(); string rootF = "Equation Images/" + testImageName; Sprite myEquation_image = Resources.Load(rootF, typeof(Sprite)) as Sprite; //Debug.Log (rootF); Equation_Output_ref.GetComponent<Image> ().sprite = myEquation_image; }
private void PythonPlotGenerator(GameObject equationObject, string fileName, string testImageName) { GameMath.Plot newCurve = new GameMath.Plot (); GameMath.Expression newExpr = null; switch ((int)eqChoose.GetComponent<UpdateValue>().ReturnVariable()) { case 0: { newExpr = new GameMath.LinearExpr(); break; } case 1: { newExpr = new GameMath.QuadExpr(); break; } case 2: { newExpr = new GameMath.CubeExpr(); break; } case 3: { newExpr = new GameMath.AbsExpr(); break; } case 4: { newExpr = new GameMath.SqrtExpr(); break; } case 5: { newExpr = new GameMath.CbrtExpr(); break; } case 6: { newExpr = new GameMath.RecipExpr(); break; } default: { newExpr = new GameMath.LinearExpr(); break; } } newExpr.AVertStretch.FloatData = equationObject.GetComponent<UserEquationInput>().VarA; newExpr.BHorizStretch.FloatData = equationObject.GetComponent<UserEquationInput>().VarB; newExpr.CHorizShift.FloatData = equationObject.GetComponent<UserEquationInput>().VarC; newExpr.DVertShift.FloatData = equationObject.GetComponent<UserEquationInput>().VarD; newExpr.PyExpression(); Debug.Log(newExpr.PlotString.StrData); //GameMath.AbsExpr newExpr = new GameMath.AbsExpr(equationObject.GetComponent<UserEquationInput>().VarA, equationObject.GetComponent<UserEquationInput>().VarB, equationObject.GetComponent<UserEquationInput>().VarC, equationObject.GetComponent<UserEquationInput>().VarD); //newCurve.Expr.StrData = "1*(1*x+0)**0.5+0"; //newCurve.Expr.StrData = equationObject.GetComponent<UserEquationInput> ().CurrentPythonEq; newCurve.Expr.StrData = newExpr.PlotString.StrData; //Debug.Log(newExpr.PlotString.StrData); //newCurve.XStart.FloatData = 0f; GameMath.Axes newGraph = new GameMath.Axes(); newGraph.AddCurve(newCurve); newGraph.ResourceFolder.StrData = "Plot Figures"; //newGraph.FileName = "newGRAPH.png"; newGraph.FileName.StrData = fileName; newGraph.GenerateGrid(); newGraph.GeneratePlot(0); UnityEditor.AssetDatabase.Refresh(); string rootF = "Plot Figures/" + testImageName+"_AXES"; Sprite myPlot_image = Resources.Load(rootF, typeof(Sprite)) as Sprite; Plot_Output_ref.GetComponent<Image> ().sprite = myPlot_image; string rootC = "Plot Figures/" + testImageName+"_0"; Sprite myCurve_image = Resources.Load(rootC, typeof(Sprite)) as Sprite; Curve_Output_ref.GetComponent<Image> ().sprite = myCurve_image; }