module WindMill where import Pan -- -- Defines a function that is 0 at the origin and has a value between 0 and 1 -- proportial to the distance from the origin. The function has value 1 at -- distance r from the origin. circularField r pt = let d = distO pt in if d < r then d / r else 1 yellowI :: ImageC yellowI = lift0 (Col 1 1 0 1) yellowToBlue :: Frac -> ImageC yellowToBlue n = lerpI (circularField n) blueI yellowI bigCircle n = uscale n udisk smallCircle n = compR $ uscale n udisk fanRegionPolar :: Int -> PolarRegion fanRegionPolar numSpokes (Pol r a) = even (floor (a / frac)) where frac = 2*pi / fromIntegral (2*numSpokes) polarReg :: PolarRegion -> Region polarReg reg p = reg (toPolar p) fanRegion :: Int -> Region fanRegion n = polarReg (fanRegionPolar n) intersection :: UI Region intersection = do n <- makeISlider "spokes" (3,15) 8 r1 <- makeSlider "outer radius" (10,100) 30 r2 <- makeSlider "inner radius" (1,30) 5 return $ bigCircle r1 `intersectR` smallCircle r2 `intersectR` fanRegion n croppedYellowToBlue = do n <- makeISlider "spokes" (3,15) 8 r1 <- makeSlider "outer radius" (10,100) 30 r2 <- makeSlider "inner radius" (1,30) 5 let intersection = bigCircle r1 `intersectR` smallCircle r2 `intersectR` fanRegion n return $ crop intersection (yellowToBlue r1) effect = do cytb <- croppedYellowToBlue imageToDisplayFun cytb