commit 3076e7710dbbd6c681d8bfc6403719079509d71e
parent 0237c77c079784f1fa782b0d69c46cc0eb7b4021
Author: Christos Margiolis <christos@margiolis.net>
Date: Sat, 7 Mar 2020 07:38:46 +0200
edited README
Diffstat:
4 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/README.md b/README.md
@@ -15,3 +15,5 @@ A simple ncurses graph generator.
* Add slope, curvature etc.
* Add an options window
* Add the option to give a function while in the program
+* Add coordinates using cursor pointing
+* *(Perhaps)* add derivative calculator
diff --git a/bin/graphcurses b/bin/graphcurses
Binary files differ.
diff --git a/obj/main.o b/obj/main.o
Binary files differ.
diff --git a/src/main.cpp b/src/main.cpp
@@ -4,8 +4,8 @@
#include <iostream>
#include <string>
-#define XMIN_PLANE -2*M_PI
-#define XMAX_PLANE 2*M_PI
+#define XMIN_PLANE -2.0f*M_PI
+#define XMAX_PLANE 2.0f*M_PI
#define YMIN_PLANE -M_PI
#define YMAX_PLANE M_PI
@@ -50,8 +50,8 @@ void draw_axes(Plane &plane)
{
int ymax, xmax;
getmaxyx(stdscr, ymax, xmax);
- float x0 = scale(0, plane.xmin, plane.xmax, 0, xmax);
- float y0 = scale(0, plane.ymin, plane.ymax, ymax, 0);
+ float x0 = scale(0.0f, plane.xmin, plane.xmax, 0.0f, xmax);
+ float y0 = scale(0.0f, plane.ymin, plane.ymax, ymax, 0.0f);
float xstep, ystep;
getstep(plane, xstep, ystep);
@@ -74,8 +74,8 @@ void plot(Plane &plane, float x, float y)
{
int ymax, xmax;
getmaxyx(stdscr, ymax, xmax);
- float xp = scale(x, plane.xmin, plane.xmax, 0, xmax);
- float yp = scale(y, plane.ymin, plane.ymax, ymax, 0);
+ float xp = scale(x, plane.xmin, plane.xmax, 0.0f, xmax);
+ float yp = scale(y, plane.ymin, plane.ymax, ymax, 0.0f);
mvwaddch(stdscr, yp, xp, '.');
}
@@ -122,19 +122,19 @@ void handle_zoom(int key, Plane &plane)
void handle_key(int key, Plane &plane)
{
- float xshift = 0, yshift = 0;
+ float xshift = 0.0f, yshift = 0.0f;
switch (key)
{
- case 'k': case KEY_UP: yshift = 1; break;
- case 'j': case KEY_DOWN: yshift = -1; break;
- case 'h': case KEY_LEFT: xshift = -1; break;
- case 'l': case KEY_RIGHT: xshift = 1; break;
+ case 'k': case 'w': case KEY_UP: yshift = 1; break;
+ case 'j': case 's': case KEY_DOWN: yshift = -1; break;
+ case 'h': case 'a': case KEY_LEFT: xshift = -1; break;
+ case 'l': case 'd': case KEY_RIGHT: xshift = 1; break;
case '+': case '-': case 'r': handle_zoom(key, plane); break;
}
- xshift *= (plane.xmax - plane.xmin) / 16;
- yshift *= (plane.ymax - plane.ymin) / 16;
+ xshift *= (plane.xmax - plane.xmin) / 16.0f;
+ yshift *= (plane.ymax - plane.ymin) / 16.0f;
plane.xmin += xshift;
plane.xmax += xshift;
plane.ymin += yshift;
@@ -154,7 +154,6 @@ int main(int argc, char **argv)
if (argc > 1)
{
- if (std::string(argv[1]) == "y=") argv[1] += 2;
eval = evaluator_create(argv[1]);
if (!eval)
{