Skip to content

Commit

Permalink
set var values to -ve and autorotate and zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
ben crabbe committed Jul 13, 2017
1 parent dbce6a6 commit f511b66
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
18 changes: 12 additions & 6 deletions draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
#include <stdio.h>
#include <SDL2/SDL.h>

typedef struct display
{
typedef struct display {
SDL_bool finished;
SDL_bool skip;
SDL_Window *win;
Expand Down Expand Up @@ -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();

Expand All @@ -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);
}
Expand Down Expand Up @@ -158,6 +163,7 @@ pointArray * scale(pointArray * path, scaler * s)
}

for(int point = 0; point<path->numberOfPoints; ++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]) +
Expand Down
4 changes: 2 additions & 2 deletions main.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test1.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
DO A FROM -15 TO 15 {
DO A FROM -25 TO 25 {
DO B FROM 1 TO 300 {

SET C := 12.14 A ^ ;
SET I := C 1.034 * ;
SET J := I C + ;
SET Q := 1 J / ;

RT 213
RT 134
SET D := C B * ;
FD D
}
Expand Down

0 comments on commit f511b66

Please sign in to comment.