{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Diagrams.Animation.Active where
import Diagrams.Core
import Diagrams.TrailLike
import Data.Active
type instance V (Active a) = V a
type instance N (Active a) = N a
instance HasOrigin a => HasOrigin (Active a) where
moveOriginTo :: Point (V (Active a)) (N (Active a)) -> Active a -> Active a
moveOriginTo = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall t. HasOrigin t => Point (V t) (N t) -> t -> t
moveOriginTo
instance Transformable a => Transformable (Active a) where
transform :: Transformation (V (Active a)) (N (Active a))
-> Active a -> Active a
transform = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall t. Transformable t => Transformation (V t) (N t) -> t -> t
transform
instance HasStyle a => HasStyle (Active a) where
applyStyle :: Style (V (Active a)) (N (Active a)) -> Active a -> Active a
applyStyle = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. HasStyle a => Style (V a) (N a) -> a -> a
applyStyle
instance TrailLike t => TrailLike (Active t) where
trailLike :: Located (Trail (V (Active t)) (N (Active t))) -> Active t
trailLike = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall t. TrailLike t => Located (Trail (V t) (N t)) -> t
trailLike
instance Juxtaposable a => Juxtaposable (Active a) where
juxtapose :: Vn (Active a) -> Active a -> Active a -> Active a
juxtapose Vn (Active a)
v Active a
a1 Active a
a2 =
forall a b. (a -> b) -> (Dynamic a -> b) -> Active a -> b
onActive
(\a
c1 ->
forall a. Juxtaposable a => Vn a -> a -> a -> a
juxtapose Vn (Active a)
v a
c1 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Active a
a2
)
(forall a b.
(Time Rational -> Time Rational -> (Time Rational -> a) -> b)
-> Dynamic a -> b
onDynamic forall a b. (a -> b) -> a -> b
$ \Time Rational
s1 Time Rational
e1 Time Rational -> a
d1 ->
forall a b. (a -> b) -> (Dynamic a -> b) -> Active a -> b
onActive
(\a
c2 ->
forall a.
Time Rational -> Time Rational -> (Time Rational -> a) -> Active a
mkActive Time Rational
s1 Time Rational
e1 (\Time Rational
t -> forall a. Juxtaposable a => Vn a -> a -> a -> a
juxtapose Vn (Active a)
v (Time Rational -> a
d1 Time Rational
t) a
c2)
)
(forall a b.
(Time Rational -> Time Rational -> (Time Rational -> a) -> b)
-> Dynamic a -> b
onDynamic forall a b. (a -> b) -> a -> b
$ \Time Rational
s2 Time Rational
e2 Time Rational -> a
d2 ->
forall a.
Time Rational -> Time Rational -> (Time Rational -> a) -> Active a
mkActive Time Rational
s2 Time Rational
e2 (\Time Rational
t -> forall a. Juxtaposable a => Vn a -> a -> a -> a
juxtapose Vn (Active a)
v (Time Rational -> a
d1 Time Rational
t) (Time Rational -> a
d2 Time Rational
t))
)
Active a
a2
)
Active a
a1