#!/usr/bin/env bx

# export OPTIMIZE=1

Main()
	gr_fast()
	space()

	if !vid
		error("xshm pixmaps are not working")

	qtrig_init()

	bm_enabled = 0

	bm_start()

	bm("got image")

	int da = 0
	int dr = 0

	sleep_step_debug = 1

	repeat
		long *px = pixel(vid, 0, 0)
		da+=2

		int y
		for y=h_2-1; y>=-h_2; --y
			int r2 = sqr(w_2) + sqr(y)
			for(x, -w_2, w_2)
				int a

				num s, atn
				qSin(s, r2/100.0+dr)
				qAtan2(atn, y, x)
				mod_fast(a, atn+s*50+da, 360)

				*px++ = rb[a]

				r2 += 2*x+1   # maintain r2 = x*x+y*y

		bm("calc done")
#		sleep_step(0.15)
		Paint()
		bm("painted")
		bm_start()

	gr_free()

def trig_unit deg
def screen_trans fast

use b

#use sched.h
