{-# 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 = (a -> a) -> Active a -> Active a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> a) -> Active a -> Active a)
-> (Point (V a) (N a) -> a -> a)
-> Point (V a) (N a)
-> Active a
-> Active a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Point (V a) (N a) -> a -> a
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 = (a -> a) -> Active a -> Active a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> a) -> Active a -> Active a)
-> (Transformation (V a) (N a) -> a -> a)
-> Transformation (V a) (N a)
-> Active a
-> Active a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Transformation (V a) (N a) -> a -> a
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 = (a -> a) -> Active a -> Active a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> a) -> Active a -> Active a)
-> (Style (V a) (N a) -> a -> a)
-> Style (V a) (N a)
-> Active a
-> Active a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Style (V a) (N a) -> a -> a
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 = t -> Active t
forall (f :: * -> *) a. Applicative f => a -> f a
pure (t -> Active t)
-> (Located (Trail (V t) (N t)) -> t)
-> Located (Trail (V t) (N t))
-> Active t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Located (Trail (V t) (N t)) -> t
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 =
(a -> Active a) -> (Dynamic a -> Active a) -> Active a -> Active a
forall a b. (a -> b) -> (Dynamic a -> b) -> Active a -> b
onActive
(\a
c1 ->
Vn a -> a -> a -> a
forall a. Juxtaposable a => Vn a -> a -> a -> a
juxtapose Vn a
Vn (Active a)
v a
c1 (a -> a) -> Active a -> Active a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Active a
a2
)
((Time Rational
-> Time Rational -> (Time Rational -> a) -> Active a)
-> Dynamic a -> Active a
forall a b.
(Time Rational -> Time Rational -> (Time Rational -> a) -> b)
-> Dynamic a -> b
onDynamic ((Time Rational
-> Time Rational -> (Time Rational -> a) -> Active a)
-> Dynamic a -> Active a)
-> (Time Rational
-> Time Rational -> (Time Rational -> a) -> Active a)
-> Dynamic a
-> Active a
forall a b. (a -> b) -> a -> b
$ \Time Rational
s1 Time Rational
e1 Time Rational -> a
d1 ->
(a -> Active a) -> (Dynamic a -> Active a) -> Active a -> Active a
forall a b. (a -> b) -> (Dynamic a -> b) -> Active a -> b
onActive
(\a
c2 ->
Time Rational -> Time Rational -> (Time Rational -> a) -> Active a
forall a.
Time Rational -> Time Rational -> (Time Rational -> a) -> Active a
mkActive Time Rational
s1 Time Rational
e1 (\Time Rational
t -> Vn a -> a -> a -> a
forall a. Juxtaposable a => Vn a -> a -> a -> a
juxtapose Vn a
Vn (Active a)
v (Time Rational -> a
d1 Time Rational
t) a
c2)
)
((Time Rational
-> Time Rational -> (Time Rational -> a) -> Active a)
-> Dynamic a -> Active a
forall a b.
(Time Rational -> Time Rational -> (Time Rational -> a) -> b)
-> Dynamic a -> b
onDynamic ((Time Rational
-> Time Rational -> (Time Rational -> a) -> Active a)
-> Dynamic a -> Active a)
-> (Time Rational
-> Time Rational -> (Time Rational -> a) -> Active a)
-> Dynamic a
-> Active a
forall a b. (a -> b) -> a -> b
$ \Time Rational
s2 Time Rational
e2 Time Rational -> a
d2 ->
Time Rational -> Time Rational -> (Time Rational -> a) -> Active a
forall a.
Time Rational -> Time Rational -> (Time Rational -> a) -> Active a
mkActive Time Rational
s2 Time Rational
e2 (\Time Rational
t -> Vn a -> a -> a -> a
forall a. Juxtaposable a => Vn a -> a -> a -> a
juxtapose Vn a
Vn (Active a)
v (Time Rational -> a
d1 Time Rational
t) (Time Rational -> a
d2 Time Rational
t))
)
Active a
a2
)
Active a
a1