/* * File: trygraphics2.c * ------------- * Eric Siegel testing graphics some more */ #include <stdio.h> #include <math.h> #include "genlib.h" #include "simpio.h" #include "graphics.h" #define PI 3.14159 /* This function draws a line from (x1,y1) to (x2,y2) */ void AbsLine(double x1, double y1, double x2, double y2) { MovePen(x1,y1); DrawLine(x2-x1,y2-y1); } main() { double cx, cy; /* center of window */ double height, width; double i, dy; InitGraphics(); width = GetWindowWidth(); /* window width */ cx = width / 2; /* center of x-axis */ height = GetWindowHeight(); /* window height */ cy = height / 2; /* center of y-axis */ /* Funky grid pattern */ SetPenColor("Red"); for(i=0; i < height; i += .1) { AbsLine(0,i,height-i,0); } /* Parabolic arc, dude */ SetPenColor("Blue"); for(dy=0; dy < 1; dy += .1) { DrawLine(.5,dy); } /* Crave the Sine Wave */ SetPenColor("Dark Gray"); SetPenColor("Green"); for(i=0; i < 2*PI ; i+=.01) { AbsLine(i,cy+sin(i),i,cy+sin(i)); } }
email: evs at cs dot columbia dot edu