drawColorwheel :: Context -> CFloat -> CFloat -> CFloat -> CFloat -> CFloat -> IO ()
drawColorwheel c x y w h t =
  do save c
     forM_ [0..5] $ \i ->
       do let a0 = i / 6 * pi * 2 - aeps
              a1 = (i+1)/6*pi*2+aeps
          beginPath c
          arc c cx cy r0 a0 a1 CW
          arc c cx cy r1 a1 a0 CCW
          closePath c
          let ax = cx + cos a0 * (r0+r1)*0.5
              ay = cy+sin a0 * (r0+r1)*0.5
              bx = cx + cos a1 * (r0+r1) * 0.5
              by = cy + sin a1 * (r0 + r1) * 0.5
          paint <- linearGradient c ax ay bx by (hsla (a0/(2*pi)) 1 0.55 255) (hsla (a1/(2*pi)) 1 0.55 255)
          fillPaint c paint
          fill c
     beginPath c
     circle c cx cy (r0-0.5)
     circle c cx cy (r1+0.5)
     strokeColor c (rgba 0 0 0 64)
     strokeWidth c 1
     stroke c

     save c
     translate c cx cy
     rotate c (hue*pi*2)

     strokeWidth c 2
     beginPath c
     rect c (r0-1) (-3) (r1-r0+2) 6
     strokeColor c (rgba 255 255 255 192)
     stroke c

     paint <- boxGradient c (r0-3) (-5) (r1-r0+6) 10 2 4 (rgba 0 0 0 128) (rgba 0 0 0 0)
     beginPath c
     rect c (r0-2-10) (-4-10) (r1-r0+4+20) (8+20)
     rect c (r0-2) (-4) (r1-r0+4) 8
     pathWinding c (fromIntegral$fromEnum Hole)
     fillPaint c paint
     fill c

     let r = r0 - 6
         ax = cos (120/180*pi) * r
         ay = sin(120/180*pi) * r
         bx = cos (-120/180*pi) * r
         by = sin(-120/180*pi) * r
     beginPath c
     moveTo c r 0
     lineTo c ax ay
     lineTo c bx by
     closePath c
     paint <- linearGradient c r 0 ax ay (hsla hue 1 0.5 255) (rgba 255 255 255 255)
     fillPaint c paint
     fill c
     strokeColor c (rgba 0 0 0 64)
     stroke c

     let ax = cos (120/180*pi)*r*0.3
         ay = sin(120/180*pi)*r*0.4
     strokeWidth c 2
     beginPath c
     circle c ax ay 5
     strokeColor c (rgba 255 255 255 192)
     stroke c

     paint <- radialGradient c ax ay 7 9 (rgba 0 0 0 64) (rgba 0 0 0 0)
     beginPath c
     rect c (ax-20) (ay-20) 40 40
     circle c ax ay 7
     pathWinding c (fromIntegral$fromEnum Hole)
     fillPaint c paint
     fill c
     restore c
     restore c
  where hue = sin (t * 0.12)
        cx = x + w*0.5
        cy = y+h*0.5
        r1 = min w h * 0.5 - 5
        r0 = r1 - 20
        aeps = 0.5 / r1
drawColorwheel :: Context -> CFloat -> CFloat -> CFloat -> CFloat -> CFloat -> IO ()
drawColorwheel c x y w h t =
  do save c
     forM_ [0..5] $ \i ->
       do let a0 = i / 6 * pi * 2 - aeps
              a1 = (i+1)/6*pi*2+aeps
          beginPath c
          arc c cx cy r0 a0 a1 CW
          arc c cx cy r1 a1 a0 CCW
          closePath c
          let ax = cx + cos a0 * (r0+r1)*0.5
              ay = cy+sin a0 * (r0+r1)*0.5
              bx = cx + cos a1 * (r0+r1) * 0.5
              by = cy + sin a1 * (r0 + r1) * 0.5
          paint <- linearGradient c ax ay bx by (hsla (a0/(2*pi)) 1 0.55 255) (hsla (a1/(2*pi)) 1 0.55 255)
          fillPaint c paint
          fill c
     beginPath c
     circle c cx cy (r0-0.5)
     circle c cx cy (r1+0.5)
     strokeColor c (rgba 0 0 0 64)
     strokeWidth c 1
     stroke c

     save c
     translate c cx cy
     rotate c (hue*pi*2)

     strokeWidth c 2
     beginPath c
     rect c (r0-1) (-3) (r1-r0+2) 6
     strokeColor c (rgba 255 255 255 192)
     stroke c

     paint <- boxGradient c (r0-3) (-5) (r1-r0+6) 10 2 4 (rgba 0 0 0 128) (rgba 0 0 0 0)
     beginPath c
     rect c (r0-2-10) (-4-10) (r1-r0+4+20) (8+20)
     rect c (r0-2) (-4) (r1-r0+4) 8
     pathWinding c (fromIntegral$fromEnum Hole)
     fillPaint c paint
     fill c

     let r = r0 - 6
         ax = cos (120/180*pi) * r
         ay = sin(120/180*pi) * r
         bx = cos (-120/180*pi) * r
         by = sin(-120/180*pi) * r
     beginPath c
     moveTo c r 0
     lineTo c ax ay
     lineTo c bx by
     closePath c
     paint <- linearGradient c r 0 ax ay (hsla hue 1 0.5 255) (rgba 255 255 255 255)
     fillPaint c paint
     fill c
     strokeColor c (rgba 0 0 0 64)
     stroke c

     let ax = cos (120/180*pi)*r*0.3
         ay = sin(120/180*pi)*r*0.4
     strokeWidth c 2
     beginPath c
     circle c ax ay 5
     strokeColor c (rgba 255 255 255 192)
     stroke c

     paint <- radialGradient c ax ay 7 9 (rgba 0 0 0 64) (rgba 0 0 0 0)
     beginPath c
     rect c (ax-20) (ay-20) 40 40
     circle c ax ay 7
     pathWinding c (fromIntegral$fromEnum Hole)
     fillPaint c paint
     fill c
     restore c
     restore c
  where hue = sin (t * 0.12)
        cx = x + w*0.5
        cy = y+h*0.5
        r1 = min w h * 0.5 - 5
        r0 = r1 - 20
        aeps = 0.5 / r1
drawColorwheel c x y w h t =
  do save c
     forM_ [0..5] $ \i ->
       do let a0 = i / 6 * pi * 2 - aeps
              a1 = (i+1)/6*pi*2+aeps
          beginPath c
          arc c cx cy r0 a0 a1 CW
          arc c cx cy r1 a1 a0 CCW
          closePath c
          let ax = cx + cos a0 * (r0+r1)*0.5
              ay = cy+sin a0 * (r0+r1)*0.5
              bx = cx + cos a1 * (r0+r1) * 0.5
              by = cy + sin a1 * (r0 + r1) * 0.5
          paint <- linearGradient c ax ay bx by (hsla (a0/(2*pi)) 1 0.55 255) (hsla (a1/(2*pi)) 1 0.55 255)
          fillPaint c paint
          fill c
     beginPath c
     circle c cx cy (r0-0.5)
     circle c cx cy (r1+0.5)
     strokeColor c (rgba 0 0 0 64)
     strokeWidth c 1
     stroke c

     save c
     translate c cx cy
     rotate c (hue*pi*2)

     strokeWidth c 2
     beginPath c
     rect c (r0-1) (-3) (r1-r0+2) 6
     strokeColor c (rgba 255 255 255 192)
     stroke c

     paint <- boxGradient c (r0-3) (-5) (r1-r0+6) 10 2 4 (rgba 0 0 0 128) (rgba 0 0 0 0)
     beginPath c
     rect c (r0-2-10) (-4-10) (r1-r0+4+20) (8+20)
     rect c (r0-2) (-4) (r1-r0+4) 8
     pathWinding c (fromIntegral$fromEnum Hole)
     fillPaint c paint
     fill c

     let r = r0 - 6
         ax = cos (120/180*pi) * r
         ay = sin(120/180*pi) * r
         bx = cos (-120/180*pi) * r
         by = sin(-120/180*pi) * r
     beginPath c
     moveTo c r 0
     lineTo c ax ay
     lineTo c bx by
     closePath c
     paint <- linearGradient c r 0 ax ay (hsla hue 1 0.5 255) (rgba 255 255 255 255)
     fillPaint c paint
     fill c
     strokeColor c (rgba 0 0 0 64)
     stroke c

     let ax = cos (120/180*pi)*r*0.3
         ay = sin(120/180*pi)*r*0.4
     strokeWidth c 2
     beginPath c
     circle c ax ay 5
     strokeColor c (rgba 255 255 255 192)
     stroke c

     paint <- radialGradient c ax ay 7 9 (rgba 0 0 0 64) (rgba 0 0 0 0)
     beginPath c
     rect c (ax-20) (ay-20) 40 40
     circle c ax ay 7
     pathWinding c (fromIntegral$fromEnum Hole)
     fillPaint c paint
     fill c
     restore c
     restore c
  where hue = sin (t * 0.12)
        cx = x + w*0.5
        cy = y+h*0.5
        r1 = min w h * 0.5 - 5
        r0 = r1 - 20
        aeps = 0.5 / r1