#include #include #include #include #include Image *background; void dodraw() { int n = 4; int h, w, pn, qn; Point p[4], q[4]; Point **pp; Point **qq; Image* color; w = screen->r.max.x - screen->r.min.x; h = screen->r.max.y - screen->r.min.y; p[0] = Pt(screen->r.min.x, screen->r.min.y + w*0.5); p[1] = Pt(screen->r.min.x + w*0.3, screen->r.min.y + h*0.4); p[2] = Pt(screen->r.min.x + w*0.7, screen->r.min.y + h*0.3); p[3] = Pt(screen->r.max.x, screen->r.min.y + w*0.2); q[3] = Pt(screen->r.min.x, screen->r.min.y + w*0.9); q[2] = Pt(screen->r.min.x + w*0.3, screen->r.min.y + h*0.6); q[1] = Pt(screen->r.min.x + w*0.7, screen->r.min.y + h*0.4); q[0] = Pt(screen->r.max.x, screen->r.min.y + w*0.25); draw(screen, screen->r, background, nil, ZP); // bezspline(screen, p, n, Enddisc, Enddisc, 4, display->black, ZP); // bezspline(screen, q, n, Enddisc, Enddisc, 4, display->black, ZP); /* Not sure how big to make these until after bezsplinepts. */ pp = malloc(4096); qq = malloc(4096); pn = bezsplinepts(p, n, pp); qn = bezsplinepts(q, n, qq); color = allocimagemix(display, DPalebluegreen, DBluegreen); Point *z = malloc((pn + qn) * sizeof(Point)); memcpy(z, *pp, pn * sizeof(Point)); memcpy(z+pn, *qq, qn * sizeof(Point)); poly(screen, z, pn+qn, Enddisc, Enddisc, 5, color, ZP); fillpoly(screen, z, pn+qn, ~0, allocimagemix(display, DBluegreen, DWhite), ZP); } void eresized(int new) { dodraw(); flushimage(display, 1); } void main(int argc, char *argv[]) { Event e; ARGBEGIN { } ARGEND initdraw(nil, nil, argv0); background = allocimagemix(display, DWhite, 0xFFEEFFFF); einit(Ekeyboard|Emouse); dodraw(); flushimage(display, 1); for (;;) { switch(event(&e)) { case Ekeyboard: if(e.kbdc==0x7F || e.kbdc=='q') exits(0); dodraw(); // print("int:%d char:%c\n", e.kbdc, e.kbdc); break; case Emouse: if(e.mouse.buttons) dodraw(); break; } } }