From f511b6649a9edee1526a99576087b376b9f3ced3 Mon Sep 17 00:00:00 2001 From: ben crabbe Date: Thu, 13 Jul 2017 08:20:33 -0700 Subject: [PATCH] set var values to -ve and autorotate and zoom --- draw.c | 18 ++++++++++++------ main.h | 4 ++-- test1.txt | 4 ++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/draw.c b/draw.c index bdc8b7e..b73a537 100644 --- a/draw.c +++ b/draw.c @@ -10,8 +10,7 @@ #include #include -typedef struct display -{ +typedef struct display { SDL_bool finished; SDL_bool skip; SDL_Window *win; @@ -60,9 +59,12 @@ void testScalePath(); /** Draws lines between each of the points in path to an sdl window */ -void draw(pointArray * path) +void draw(pointArray * path) { - if(VERBOSE) printPath(path, "orininal path:"); + if(VERBOSE) { + printPath(path, "orininal path:"); + } + display * d = startSDL(); @@ -72,14 +74,17 @@ void draw(pointArray * path) printf("Press up and down arrows to zoom in/out.\n"); while(!d->finished) { renderPath(d, scaledPath); - sdlKey key = getSdlKeyPresses(d); + /* sdlKey key = getSdlKeyPresses(d); if(key==UP) zoom(s,1);//zoomin else if(key==DOWN) zoom(s,0);//zoomout else if(key==LEFT) rotate(s,0); else if(key==RIGHT) rotate(s,1); + */ + rotate(s,1); + zoom(s,1); freePath(scaledPath); scaledPath = scale(path, s); - if(VERBOSE) printPath(scaledPath, "orininal path:"); + // if(VERBOSE) printPath(scaledPath, "orininal path:"); checkSDLwinClosed(d); SDL_Delay(1e3/FPS); } @@ -158,6 +163,7 @@ pointArray * scale(pointArray * path, scaler * s) } for(int point = 0; pointnumberOfPoints; ++point) { + // for(dimension dim = X; dim<=DIM_MAX; ++dim) { scaledPath->array[point].r[0] = (cos(s->rotation)*(path->array[point].r[0]*s->scale[0]) + diff --git a/main.h b/main.h index 6f838af..46e7ca6 100644 --- a/main.h +++ b/main.h @@ -21,9 +21,9 @@ #define SDL_WINDOW_WIDTH 900 #define SDL_WINDOW_HEIGHT 660 #define STRETCH_TO_FIT_WINDOW 0 -#define ZOOM_SENSITIVITY 0.7 //zooming will increase scale by a factor of ZOOM_SENSITIVITY*100 % +#define ZOOM_SENSITIVITY 0.1 //zooming will increase scale by a factor of ZOOM_SENSITIVITY*100 % #define SCALE_AT_START 0.3 //of screen width -#define ROTATION_SENSITIVITY 0.01 +#define ROTATION_SENSITIVITY 0.05 #ifndef M_PI #define M_PI 3.14159265359 diff --git a/test1.txt b/test1.txt index fd390d2..f48e4e1 100644 --- a/test1.txt +++ b/test1.txt @@ -1,5 +1,5 @@ { -DO A FROM -15 TO 15 { +DO A FROM -25 TO 25 { DO B FROM 1 TO 300 { SET C := 12.14 A ^ ; @@ -7,7 +7,7 @@ DO B FROM 1 TO 300 { SET J := I C + ; SET Q := 1 J / ; - RT 213 + RT 134 SET D := C B * ; FD D }