~aleteoryx/9c

c460f2906d707ca59addf4180b4447bc05ee5310 — glenda 37 years ago c2481f8
first* line!

*second line
1 files changed, 38 insertions(+), 15 deletions(-)

M spiral.c
M spiral.c => spiral.c +38 -15
@@ 1,23 1,46 @@
#include <u.h>
#include  <libc.h>
#include  <draw.h>
#include  <event.h>
#include  <cursor.h>
#include <libc.h>
#include <draw.h>
#include <event.h>
#include <cursor.h>

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);
}