From c460f2906d707ca59addf4180b4447bc05ee5310 Mon Sep 17 00:00:00 2001 From: glenda Date: Fri, 1 Jan 1988 06:41:05 +0000 Subject: [PATCH] first* line! *second line --- spiral.c | 53 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/spiral.c b/spiral.c index 4fe1bad664382ccaef44deea7b7dc312637127f4..fe6f494e65a7795f0558dbccf25ae567dd6fd6c2 100644 --- a/spiral.c +++ b/spiral.c @@ -1,23 +1,46 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include void -main(void) +usage(void) { - double start, end; - double lastcos; + fprint(2,"usage: %s\n", argv0); + exits("usage"); +} + +Point +Spt(int x, int y) +{ + return addpt(Pt(x, y), screen->r.min); +} + +Rectangle +Srect(int x0, int y0, int x1, int y1) +{ + return rectaddpt(Rect(x0, y0, x1, y1), screen->r.min); +} + +void +main(int argc, char* argv[]) +{ + Image* drawsrc; + + ARGBEGIN{ + default: + usage(); + } ARGEND - lastcos = 1.0; + if (initdraw(nil, nil, "spiral") == -1) + sysfatal("initdraw: %r"); - start = cputime(); - for (int i = 0; i < 100000000; i++) - { - lastcos = cos(lastcos) + 1.0; - } - end = cputime(); + drawsrc = allocimagemix(display, DPurpleblue, DPurpleblue); + if (!drawsrc) + sysfatal("couldn't allocimage!"); - print("Calculating 100,000,000 cosines took %fs\n", end - start); + line(screen, Spt(10,10), Spt(50,50), Enddisc, Endsquare, 5, drawsrc, Spt(0,0)); + flushimage(display, 1); + sleep(10*1000); }