#include #include #include "ezwin.h" using namespace std ; // This must be imported. extern float (*fTab[])(const float, const float) ; enum color float2color(const float f) { enum color colors[] = { Red, Yellow, Green, Cyan, Blue, Magenta } ; const int colorn = 6 ; return colors[(int)((f - floor(f)) * colorn)] ; } void PlotPoints(SimpleWindow &W, float (*f)(const float, const float)) { int i, j ; const int Res = 100 ; const float invRes = 1.0f/Res ; float centX = W.GetWidth()*0.5 ; float centY = W.GetHeight()*0.5 ; float maxDim = ( centX > centY ? centX : centY ) ; float boxDim = maxDim/Res ; float axLW = maxDim*0.010 ; // Plot the function for (i=-Res; iClose() ; delete pW ; if (fTab[++funcIndex] == NULL) funcIndex = 0 ; ostringstream winName ; winName << "Function " << funcIndex+1 ; pW = new SimpleWindow(winName.str(), 18.0f, 18.0f, home) ; pW->Open() ; pW->SetMouseClickCallback(nextPlot) ; pW->SetRefreshCallback(refreshPlot) ; PlotPoints(*pW, fTab[funcIndex]) ; return 0 ; } int ApiMain() { pW = new SimpleWindow("Function 1", 18.0f, 18.0f, home) ; pW->Open() ; pW->SetMouseClickCallback(nextPlot) ; pW->SetRefreshCallback(refreshPlot) ; PlotPoints(*pW, fTab[0]) ; return 0 ; } int ApiEnd() { pW->Close() ; return 0 ; }