#lang planet dyoo/moby:3:9
(require (planet dyoo/moby:3:9/phone/tilt))
(define initial-world (make-color 0 0 0))
(define (tilt w azimuth pitch roll)
(make-color (scale azimuth 360)
(scale (+ pitch 90) 180)
(scale (+ roll 90) 180)))
(define (scale n domain-bound)
(inexact->exact (floor (* (/ n domain-bound) 255))))
(define view (list (js-div '((id "background")))))
(define (draw-html w) view)
(define (draw-css w)
(list (list "background"
(list "background-color"
(format "rgb(~a, ~a, ~a)"
(color-red w)
(color-green w)
(color-blue w)))
(list "width" "300")
(list "height" "300"))))
(big-bang initial-world
(on-tilt tilt)
(to-draw-page draw-html draw-css))