#include #include #include "object.h" #include "mygraph.h" #include "mydebug.h" #include "Xroutines.h" extern int DEBUG; void draw_line(environment * env, point e1, point e2); void dc_drawline (int x1, int y1, int x2, int y2, environment * env); void draw_polylist_with_lines (polylist thing, environment * env); void draw_grid_with_line (grid thing, environment * env); void draw_object( environment * env ) { switch(env->the_object.kind) { case POLYLIST: draw_polylist_with_lines (env->the_object.go.pl, env); break; case GRID: draw_grid_with_line(env->the_object.go.gd, env); break; } } void draw_grid_with_line (grid thing, environment * env) { int i,j; for (i=0;i<(thing.x-1);i++){ for (j=0;j<(thing.y-1);j++){ draw_line(env, thing.point_list[i*thing.y+j], thing.point_list[(i+1)*thing.y+j]); draw_line(env, thing.point_list[i*thing.y+j], thing.point_list[i*thing.y+j+1]); } draw_line(env, thing.point_list[i*thing.y+(thing.y-1)], thing.point_list[(i+1)*thing.y+(thing.y-1)]); } i = thing.x-1; for (j=0;j<(thing.y-1);j++){ draw_line(env, thing.point_list[i*thing.y+j], thing.point_list[i*thing.y+j+1]); } } void draw_polylist_with_lines (polylist thing, environment * env) { int i,j; for (i=0;i 0) { printf("Drawing line (%5.2f,%5.2f,%5.2f) (%5.2f,%5.2f,%5.2f)\n", e1.x,e1.y,e1.z, e2.x,e2.y,e2.z); } nx1 = e1.x + e1.z * 0.3535534; ny1 = e1.y + e1.z * 0.3535534; nx2 = e2.x + e2.z * 0.3535534; ny2 = e2.y + e2.z * 0.3535534; dcx1 = (int) (200+env->mult*nx1); dcx2 = (int) (200+env->mult*nx2); dcy1 = (int) (200 - env->mult*ny1); dcy2 = (int) (200 - env->mult*ny2); dc_drawline(dcx1,dcy1,dcx2,dcy2,env); } void dc_drawline (int x1, int y1, int x2, int y2, environment * env){ XSetLine(env->db,x1,y1, x2,y2); }