int main(void) { int klawisz, dlugosc[2]; int wektor1[] = {1, 2, 3, 4, 5}; int wektor2[] = {10, 20, 30, 40, 50}; do { printf("\nWybierz operacje na wektorach:\n 1 - odleglosc\n 2 - normy\n 3 - suma\n 4 - roznica\n\nPodaj cyfre: "); scanf("%d",&klawisz); if((klawisz != 1) || (klawisz != 2) || (klawisz != 3) || (klawisz != 4)) continue; } while((klawisz != 1) && (klawisz != 2) && (klawisz != 3) && (klawisz != 4)); dlugosc[0] = sizeof wektor1/sizeof(int); dlugosc[1] = sizeof wektor2/sizeof(int); switch(klawisz) { case 1: odleglosc(wektor1, wektor2, dlugosc[0], dlugosc[1]); break; case 2: normy(wektor1, wektor2, dlugosc[0], dlugosc[1]); break; case 3: suma(wektor1, wektor2, dlugosc[0], dlugosc[1]); break; case 4: roznica(wektor1, wektor2, dlugosc[0], dlugosc[1]); break; } system("pause"); }
static void _send(Cord * buf) { if (sp == SIZE) _flush(); points[sp].x = normx(buf->x); points[sp++].y = normy(buf->y); }
static int polyg(int type) { int x, y, w, h; scanf("%d %d %d %d", &x, &y, &w, &h); dplot(type, normx(x), normy(y + h), norm(w), norm(h)); return (0); }
static void circle(int x0, int y0, int r1, int r2, int arg1, int arg2) { int x, y; unsigned int width, height; arg1 /= 10; arg2 /= 10; width = normx(abs(r1 * cos((double) arg1))); height = normx(abs(r2 * sin((double) arg2))); x = normx(x0) - width; y = normy(y0) - height; width *= 2; height *= 2; XDrawArc(display, main_window, gc, x, y, width, height, arg1 * 64, arg2 * 64); }
static void hatching(int type) { int n; int frame; int d, angle; scanf("%d %d", &d, &angle); for (n = 0; _getcord(&pb); n++) { points[n].x = normx(pb.x); points[n].y = normy(pb.y); } points[n].x = points[0].x; points[n].y = points[0].y; switch (type -= 20) { case 1: frame = 1; type = -1; break; case 2: frame = 0; type = -1; break; case 3: frame = 1; type = -1; break; default: if (type < 0) { frame = 0; type = -type; } else frame = 1; break; } polyline(points, frame, type, n); }
void plot(void) { int c; int w, n, xmin, ymin, xmax, ymax; int x0, y0, r1, r2, arg1, arg2; while ((c = getchar()) != EOF) { switch (c) { case 'M': scanf("%d %d", &pb.x, &pb.y); _move(pb.x, pb.y); break; case 'D': _line(); break; case '%': scanf("%d", &n); hatching(n); break; /* polyg(n); break; */ case 'P': get_str(); break; case 'S': scanf("%d", &ch); break; case 'Q': scanf("%d", &cw); break; case 'R': scanf("%d", &th); th = (th == 0) ? 0 : 1; break; case 'L': scanf("%d", &w); line_type(w); break; case 'K': scanf("%d", &w); join_type(w); break; case 'W': scanf("%d %d %d %d %d %d", &x0, &y0, &r1, &r2, &arg1, &arg2); circle(x0, y0, r1, r2, arg1, arg2); break; case 'N': scanf("%d", &w); mark(w); break; case 'J': scanf("%d", &w); newpen(w); break; case '\\': scanf("%d %d", &xmin, &ymin); break; case 'Z': scanf("%d %d", &xmax, &ymax); if (!landscape) { if (xmax > XLENG) xmax = XLENG; if (ymax > YLENG) ymax = YLENG; } else { if (xmax > YLENG) xmax = YLENG; if (ymax > XLENG) ymax = XLENG; } clip(normx(xmin), normy(ymax), normx(xmax), normy(ymin)); break; case ';': case ':': break; default: break; } } }
static void _move(int x, int y) { points[0].x = normx(x); points[0].y = normy(y); }