67int main(
int argc,
char *argv[])
77 GrapherExpr expr(exprStr);
80 std::cerr <<
"expression failed " << expr.
parseError() << std::endl;
93 auto buffer = std::vector<char>(w * h,
' ');
96 int j_zero =
static_cast<int>((-ymin) / (ymax - ymin) * h);
97 if (j_zero >= 0 && j_zero < h) {
98 for (
int i = 0; i < w; i++) {
99 buffer[i + j_zero * w] =
'-';
103 int i_zero =
static_cast<int>((-xmin) / (xmax - xmin) * w);
104 if (i_zero >= 0 && i_zero < w) {
105 for (
int j = 0; j < h; j++) {
106 buffer[i_zero + j * w] =
'|';
111 const int samplesPerPixel = 10;
112 const double one_over_samples_per_pixel = 1. / samplesPerPixel;
113 for (
int i = 0; i < w; i++) {
114 for (
int sample = 0; sample < samplesPerPixel; sample++) {
116 double dx = double(sample) * one_over_samples_per_pixel;
117 double x = double(dx + i) / double(w) * (xmax - xmin) + xmin;
120 const double *val = expr.
evalFP();
126 int j =
static_cast<int>((y - ymin) / (ymax - ymin) * h);
129 buffer[i + j * w] =
'#';
134 for (
int j = h - 1; j >= 0; j--) {
135 for (
int i = 0; i < w; i++) {
136 std::cout << buffer[i + j * w];
138 std::cout << std::endl;