{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
module Diagrams.TwoD.Attributes (
Texture(..), solid, _SC, _AC, _LG, _RG, defaultLG, defaultRG
, GradientStop(..), stopColor, stopFraction, mkStops
, SpreadMethod(..), lineLGradient, lineRGradient
, LGradient(..), lGradStops, lGradTrans, lGradStart, lGradEnd
, lGradSpreadMethod, mkLinearGradient
, RGradient(..), rGradStops, rGradTrans
, rGradCenter0, rGradRadius0, rGradCenter1, rGradRadius1
, rGradSpreadMethod, mkRadialGradient
, LineTexture(..), _LineTexture, getLineTexture, lineTexture, lineTextureA
, mkLineTexture, _lineTexture
, lineColor, lc, lcA
, FillTexture(..), _FillTexture, getFillTexture, fillTexture
, mkFillTexture, _fillTexture, _fillTextureR
, fillColor, fc, fcA, recommendFillColor
, splitTextureFills
) where
import Control.Lens hiding (transform)
import Data.Colour hiding (AffineSpace, over)
import Data.Data
import Data.Default.Class
import Data.Monoid.Recommend
import Data.Semigroup
import Diagrams.Attributes
import Diagrams.Attributes.Compile
import Diagrams.Core
import Diagrams.Core.Types (RTree)
import Diagrams.Located (unLoc)
import Diagrams.Path (Path, pathTrails)
import Diagrams.Trail (isLoop)
import Diagrams.TwoD.Types
import Diagrams.Util
data GradientStop d = GradientStop
{ GradientStop d -> SomeColor
_stopColor :: SomeColor
, GradientStop d -> d
_stopFraction :: d
}
makeLensesWith (lensRules & generateSignatures .~ False) ''GradientStop
stopColor :: Lens' (GradientStop n) SomeColor
stopFraction :: Lens' (GradientStop n) n
data SpreadMethod = GradPad | GradReflect | GradRepeat
data LGradient n = LGradient
{ LGradient n -> [GradientStop n]
_lGradStops :: [GradientStop n]
, LGradient n -> Point V2 n
_lGradStart :: Point V2 n
, LGradient n -> Point V2 n
_lGradEnd :: Point V2 n
, LGradient n -> Transformation V2 n
_lGradTrans :: Transformation V2 n
, LGradient n -> SpreadMethod
_lGradSpreadMethod :: SpreadMethod }
type instance V (LGradient n) = V2
type instance N (LGradient n) = n
makeLensesWith (lensRules & generateSignatures .~ False) ''LGradient
instance Fractional n => Transformable (LGradient n) where
transform :: Transformation (V (LGradient n)) (N (LGradient n))
-> LGradient n -> LGradient n
transform = ASetter
(LGradient n)
(LGradient n)
(Transformation V2 n)
(Transformation V2 n)
-> (Transformation V2 n -> Transformation V2 n)
-> LGradient n
-> LGradient n
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over ASetter
(LGradient n)
(LGradient n)
(Transformation V2 n)
(Transformation V2 n)
forall n. Lens' (LGradient n) (Transformation V2 n)
lGradTrans ((Transformation V2 n -> Transformation V2 n)
-> LGradient n -> LGradient n)
-> (Transformation V2 n
-> Transformation V2 n -> Transformation V2 n)
-> Transformation V2 n
-> LGradient n
-> LGradient n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Transformation V2 n -> Transformation V2 n -> Transformation V2 n
forall t. Transformable t => Transformation (V t) (N t) -> t -> t
transform
lGradStops :: Lens' (LGradient n) [GradientStop n]
lGradTrans :: Lens' (LGradient n) (Transformation V2 n)
lGradStart :: Lens' (LGradient n) (Point V2 n)
lGradEnd :: Lens' (LGradient n) (Point V2 n)
lGradSpreadMethod :: Lens' (LGradient n) SpreadMethod
data RGradient n = RGradient
{ RGradient n -> [GradientStop n]
_rGradStops :: [GradientStop n]
, RGradient n -> Point V2 n
_rGradCenter0 :: Point V2 n
, RGradient n -> n
_rGradRadius0 :: n
, RGradient n -> Point V2 n
_rGradCenter1 :: Point V2 n
, RGradient n -> n
_rGradRadius1 :: n
, RGradient n -> Transformation V2 n
_rGradTrans :: Transformation V2 n
, RGradient n -> SpreadMethod
_rGradSpreadMethod :: SpreadMethod }
makeLensesWith (lensRules & generateSignatures .~ False) ''RGradient
type instance V (RGradient n) = V2
type instance N (RGradient n) = n
instance Fractional n => Transformable (RGradient n) where
transform :: Transformation (V (RGradient n)) (N (RGradient n))
-> RGradient n -> RGradient n
transform = ASetter
(RGradient n)
(RGradient n)
(Transformation V2 n)
(Transformation V2 n)
-> (Transformation V2 n -> Transformation V2 n)
-> RGradient n
-> RGradient n
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over ASetter
(RGradient n)
(RGradient n)
(Transformation V2 n)
(Transformation V2 n)
forall n. Lens' (RGradient n) (Transformation V2 n)
rGradTrans ((Transformation V2 n -> Transformation V2 n)
-> RGradient n -> RGradient n)
-> (Transformation V2 n
-> Transformation V2 n -> Transformation V2 n)
-> Transformation V2 n
-> RGradient n
-> RGradient n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Transformation V2 n -> Transformation V2 n -> Transformation V2 n
forall t. Transformable t => Transformation (V t) (N t) -> t -> t
transform
rGradStops :: Lens' (RGradient n) [GradientStop n]
rGradCenter0 :: Lens' (RGradient n) (Point V2 n)
rGradRadius0 :: Lens' (RGradient n) n
rGradCenter1 :: Lens' (RGradient n) (Point V2 n)
rGradRadius1 :: Lens' (RGradient n) n
rGradTrans :: Lens' (RGradient n) (Transformation V2 n)
rGradSpreadMethod :: Lens' (RGradient n) SpreadMethod
data Texture n = SC SomeColor | LG (LGradient n) | RG (RGradient n)
deriving Typeable
type instance V (Texture n) = V2
type instance N (Texture n) = n
makePrisms ''Texture
_AC :: Prism' (Texture n) (AlphaColour Double)
_AC :: p (AlphaColour Double) (f (AlphaColour Double))
-> p (Texture n) (f (Texture n))
_AC = p SomeColor (f SomeColor) -> p (Texture n) (f (Texture n))
forall n. Prism' (Texture n) SomeColor
_SC (p SomeColor (f SomeColor) -> p (Texture n) (f (Texture n)))
-> (p (AlphaColour Double) (f (AlphaColour Double))
-> p SomeColor (f SomeColor))
-> p (AlphaColour Double) (f (AlphaColour Double))
-> p (Texture n) (f (Texture n))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p (AlphaColour Double) (f (AlphaColour Double))
-> p SomeColor (f SomeColor)
Iso' SomeColor (AlphaColour Double)
_SomeColor
instance Floating n => Transformable (Texture n) where
transform :: Transformation (V (Texture n)) (N (Texture n))
-> Texture n -> Texture n
transform Transformation (V (Texture n)) (N (Texture n))
t (LG LGradient n
lg) = LGradient n -> Texture n
forall n. LGradient n -> Texture n
LG (LGradient n -> Texture n) -> LGradient n -> Texture n
forall a b. (a -> b) -> a -> b
$ Transformation (V (LGradient n)) (N (LGradient n))
-> LGradient n -> LGradient n
forall t. Transformable t => Transformation (V t) (N t) -> t -> t
transform Transformation (V (LGradient n)) (N (LGradient n))
Transformation (V (Texture n)) (N (Texture n))
t LGradient n
lg
transform Transformation (V (Texture n)) (N (Texture n))
t (RG RGradient n
rg) = RGradient n -> Texture n
forall n. RGradient n -> Texture n
RG (RGradient n -> Texture n) -> RGradient n -> Texture n
forall a b. (a -> b) -> a -> b
$ Transformation (V (RGradient n)) (N (RGradient n))
-> RGradient n -> RGradient n
forall t. Transformable t => Transformation (V t) (N t) -> t -> t
transform Transformation (V (RGradient n)) (N (RGradient n))
Transformation (V (Texture n)) (N (Texture n))
t RGradient n
rg
transform Transformation (V (Texture n)) (N (Texture n))
_ Texture n
sc = Texture n
sc
solid :: Color a => a -> Texture n
solid :: a -> Texture n
solid = SomeColor -> Texture n
forall n. SomeColor -> Texture n
SC (SomeColor -> Texture n) -> (a -> SomeColor) -> a -> Texture n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> SomeColor
forall c. Color c => c -> SomeColor
SomeColor
defaultLG :: Fractional n => Texture n
defaultLG :: Texture n
defaultLG = LGradient n -> Texture n
forall n. LGradient n -> Texture n
LG LGradient :: forall n.
[GradientStop n]
-> Point V2 n
-> Point V2 n
-> Transformation V2 n
-> SpreadMethod
-> LGradient n
LGradient
{ _lGradStops :: [GradientStop n]
_lGradStops = []
, _lGradStart :: Point V2 n
_lGradStart = n -> n -> Point V2 n
forall n. n -> n -> P2 n
mkP2 (-n
0.5) n
0
, _lGradEnd :: Point V2 n
_lGradEnd = n -> n -> Point V2 n
forall n. n -> n -> P2 n
mkP2 n
0.5 n
0
, _lGradTrans :: Transformation V2 n
_lGradTrans = Transformation V2 n
forall a. Monoid a => a
mempty
, _lGradSpreadMethod :: SpreadMethod
_lGradSpreadMethod = SpreadMethod
GradPad
}
defaultRG :: Fractional n => Texture n
defaultRG :: Texture n
defaultRG = RGradient n -> Texture n
forall n. RGradient n -> Texture n
RG RGradient :: forall n.
[GradientStop n]
-> Point V2 n
-> n
-> Point V2 n
-> n
-> Transformation V2 n
-> SpreadMethod
-> RGradient n
RGradient
{ _rGradStops :: [GradientStop n]
_rGradStops = []
, _rGradCenter0 :: Point V2 n
_rGradCenter0 = n -> n -> Point V2 n
forall n. n -> n -> P2 n
mkP2 n
0 n
0
, _rGradRadius0 :: n
_rGradRadius0 = n
0.0
, _rGradCenter1 :: Point V2 n
_rGradCenter1 = n -> n -> Point V2 n
forall n. n -> n -> P2 n
mkP2 n
0 n
0
, _rGradRadius1 :: n
_rGradRadius1 = n
0.5
, _rGradTrans :: Transformation V2 n
_rGradTrans = Transformation V2 n
forall a. Monoid a => a
mempty
, _rGradSpreadMethod :: SpreadMethod
_rGradSpreadMethod = SpreadMethod
GradPad
}
mkStops :: [(Colour Double, d, Double)] -> [GradientStop d]
mkStops :: [(Colour Double, d, Double)] -> [GradientStop d]
mkStops = ((Colour Double, d, Double) -> GradientStop d)
-> [(Colour Double, d, Double)] -> [GradientStop d]
forall a b. (a -> b) -> [a] -> [b]
map (\(Colour Double
x, d
y, Double
z) -> SomeColor -> d -> GradientStop d
forall d. SomeColor -> d -> GradientStop d
GradientStop (AlphaColour Double -> SomeColor
forall c. Color c => c -> SomeColor
SomeColor (Colour Double -> Double -> AlphaColour Double
forall a. Num a => Colour a -> a -> AlphaColour a
withOpacity Colour Double
x Double
z)) d
y)
mkLinearGradient :: Num n => [GradientStop n] -> Point V2 n -> Point V2 n -> SpreadMethod -> Texture n
mkLinearGradient :: [GradientStop n]
-> Point V2 n -> Point V2 n -> SpreadMethod -> Texture n
mkLinearGradient [GradientStop n]
stops Point V2 n
start Point V2 n
end SpreadMethod
spreadMethod
= LGradient n -> Texture n
forall n. LGradient n -> Texture n
LG ([GradientStop n]
-> Point V2 n
-> Point V2 n
-> Transformation V2 n
-> SpreadMethod
-> LGradient n
forall n.
[GradientStop n]
-> Point V2 n
-> Point V2 n
-> Transformation V2 n
-> SpreadMethod
-> LGradient n
LGradient [GradientStop n]
stops Point V2 n
start Point V2 n
end Transformation V2 n
forall a. Monoid a => a
mempty SpreadMethod
spreadMethod)
mkRadialGradient :: Num n => [GradientStop n] -> Point V2 n -> n
-> Point V2 n -> n -> SpreadMethod -> Texture n
mkRadialGradient :: [GradientStop n]
-> Point V2 n -> n -> Point V2 n -> n -> SpreadMethod -> Texture n
mkRadialGradient [GradientStop n]
stops Point V2 n
c0 n
r0 Point V2 n
c1 n
r1 SpreadMethod
spreadMethod
= RGradient n -> Texture n
forall n. RGradient n -> Texture n
RG ([GradientStop n]
-> Point V2 n
-> n
-> Point V2 n
-> n
-> Transformation V2 n
-> SpreadMethod
-> RGradient n
forall n.
[GradientStop n]
-> Point V2 n
-> n
-> Point V2 n
-> n
-> Transformation V2 n
-> SpreadMethod
-> RGradient n
RGradient [GradientStop n]
stops Point V2 n
c0 n
r0 Point V2 n
c1 n
r1 Transformation V2 n
forall a. Monoid a => a
mempty SpreadMethod
spreadMethod)
newtype LineTexture n = LineTexture (Last (Texture n))
deriving (Typeable, b -> LineTexture n -> LineTexture n
NonEmpty (LineTexture n) -> LineTexture n
LineTexture n -> LineTexture n -> LineTexture n
(LineTexture n -> LineTexture n -> LineTexture n)
-> (NonEmpty (LineTexture n) -> LineTexture n)
-> (forall b. Integral b => b -> LineTexture n -> LineTexture n)
-> Semigroup (LineTexture n)
forall b. Integral b => b -> LineTexture n -> LineTexture n
forall n. NonEmpty (LineTexture n) -> LineTexture n
forall n. LineTexture n -> LineTexture n -> LineTexture n
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
forall n b. Integral b => b -> LineTexture n -> LineTexture n
stimes :: b -> LineTexture n -> LineTexture n
$cstimes :: forall n b. Integral b => b -> LineTexture n -> LineTexture n
sconcat :: NonEmpty (LineTexture n) -> LineTexture n
$csconcat :: forall n. NonEmpty (LineTexture n) -> LineTexture n
<> :: LineTexture n -> LineTexture n -> LineTexture n
$c<> :: forall n. LineTexture n -> LineTexture n -> LineTexture n
Semigroup)
instance (Typeable n) => AttributeClass (LineTexture n)
type instance V (LineTexture n) = V2
type instance N (LineTexture n) = n
_LineTexture :: Iso (LineTexture n) (LineTexture n')
(Texture n) (Texture n')
_LineTexture :: p (Texture n) (f (Texture n'))
-> p (LineTexture n) (f (LineTexture n'))
_LineTexture = (LineTexture n -> Texture n)
-> (Texture n' -> LineTexture n')
-> Iso (LineTexture n) (LineTexture n') (Texture n) (Texture n')
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso LineTexture n -> Texture n
forall n. LineTexture n -> Texture n
getLineTexture (Last (Texture n') -> LineTexture n'
forall n. Last (Texture n) -> LineTexture n
LineTexture (Last (Texture n') -> LineTexture n')
-> (Texture n' -> Last (Texture n'))
-> Texture n'
-> LineTexture n'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Texture n' -> Last (Texture n')
forall a. a -> Last a
Last)
instance Floating n => Transformable (LineTexture n) where
transform :: Transformation (V (LineTexture n)) (N (LineTexture n))
-> LineTexture n -> LineTexture n
transform Transformation (V (LineTexture n)) (N (LineTexture n))
t (LineTexture (Last Texture n
tx)) = Last (Texture n) -> LineTexture n
forall n. Last (Texture n) -> LineTexture n
LineTexture (Texture n -> Last (Texture n)
forall a. a -> Last a
Last (Texture n -> Last (Texture n)) -> Texture n -> Last (Texture n)
forall a b. (a -> b) -> a -> b
$ Transformation (V (Texture n)) (N (Texture n))
-> Texture n -> Texture n
forall t. Transformable t => Transformation (V t) (N t) -> t -> t
transform Transformation (V (Texture n)) (N (Texture n))
Transformation (V (LineTexture n)) (N (LineTexture n))
t Texture n
tx)
instance Default (LineTexture n) where
def :: LineTexture n
def = Tagged (Texture n) (Identity (Texture n))
-> Tagged (LineTexture n) (Identity (LineTexture n))
forall n n'.
Iso (LineTexture n) (LineTexture n') (Texture n) (Texture n')
_LineTexture (Tagged (Texture n) (Identity (Texture n))
-> Tagged (LineTexture n) (Identity (LineTexture n)))
-> (Tagged SomeColor (Identity SomeColor)
-> Tagged (Texture n) (Identity (Texture n)))
-> Tagged SomeColor (Identity SomeColor)
-> Tagged (LineTexture n) (Identity (LineTexture n))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Tagged SomeColor (Identity SomeColor)
-> Tagged (Texture n) (Identity (Texture n))
forall n. Prism' (Texture n) SomeColor
_SC (Tagged SomeColor (Identity SomeColor)
-> Tagged (LineTexture n) (Identity (LineTexture n)))
-> SomeColor -> LineTexture n
forall t b. AReview t b -> b -> t
## Colour Double -> SomeColor
forall c. Color c => c -> SomeColor
SomeColor Colour Double
forall a. Num a => Colour a
black
mkLineTexture :: Texture n -> LineTexture n
mkLineTexture :: Texture n -> LineTexture n
mkLineTexture = Last (Texture n) -> LineTexture n
forall n. Last (Texture n) -> LineTexture n
LineTexture (Last (Texture n) -> LineTexture n)
-> (Texture n -> Last (Texture n)) -> Texture n -> LineTexture n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Texture n -> Last (Texture n)
forall a. a -> Last a
Last
getLineTexture :: LineTexture n -> Texture n
getLineTexture :: LineTexture n -> Texture n
getLineTexture (LineTexture (Last Texture n
t)) = Texture n
t
lineTexture :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => Texture n -> a -> a
lineTexture :: Texture n -> a -> a
lineTexture = LineTexture n -> a -> a
forall a d.
(AttributeClass a, Transformable a, V a ~ V d, N a ~ N d,
HasStyle d) =>
a -> d -> d
applyTAttr (LineTexture n -> a -> a)
-> (Texture n -> LineTexture n) -> Texture n -> a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Last (Texture n) -> LineTexture n
forall n. Last (Texture n) -> LineTexture n
LineTexture (Last (Texture n) -> LineTexture n)
-> (Texture n -> Last (Texture n)) -> Texture n -> LineTexture n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Texture n -> Last (Texture n)
forall a. a -> Last a
Last
lineTextureA :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => LineTexture n -> a -> a
lineTextureA :: LineTexture n -> a -> a
lineTextureA = LineTexture n -> a -> a
forall a d.
(AttributeClass a, Transformable a, V a ~ V d, N a ~ N d,
HasStyle d) =>
a -> d -> d
applyTAttr
_lineTexture :: (Floating n, Typeable n) => Lens' (Style V2 n) (Texture n)
_lineTexture :: Lens' (Style V2 n) (Texture n)
_lineTexture = (Maybe (LineTexture n) -> f (Maybe (LineTexture n)))
-> Style V2 n -> f (Style V2 n)
forall a (v :: * -> *) n.
(V a ~ v, N a ~ n, AttributeClass a, Transformable a) =>
Lens' (Style v n) (Maybe a)
atTAttr ((Maybe (LineTexture n) -> f (Maybe (LineTexture n)))
-> Style V2 n -> f (Style V2 n))
-> ((Texture n -> f (Texture n))
-> Maybe (LineTexture n) -> f (Maybe (LineTexture n)))
-> (Texture n -> f (Texture n))
-> Style V2 n
-> f (Style V2 n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LineTexture n
-> (LineTexture n -> Bool)
-> Iso' (Maybe (LineTexture n)) (LineTexture n)
forall a. a -> (a -> Bool) -> Iso' (Maybe a) a
anon LineTexture n
forall a. Default a => a
def LineTexture n -> Bool
forall n'. LineTexture n' -> Bool
isDef ((LineTexture n -> f (LineTexture n))
-> Maybe (LineTexture n) -> f (Maybe (LineTexture n)))
-> ((Texture n -> f (Texture n))
-> LineTexture n -> f (LineTexture n))
-> (Texture n -> f (Texture n))
-> Maybe (LineTexture n)
-> f (Maybe (LineTexture n))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Texture n -> f (Texture n)) -> LineTexture n -> f (LineTexture n)
forall n n'.
Iso (LineTexture n) (LineTexture n') (Texture n) (Texture n')
_LineTexture
where
isDef :: LineTexture n' -> Bool
isDef = Getting Any (LineTexture n') (AlphaColour Double)
-> (AlphaColour Double -> Bool) -> LineTexture n' -> Bool
forall s a. Getting Any s a -> (a -> Bool) -> s -> Bool
anyOf ((Texture n' -> Const Any (Texture n'))
-> LineTexture n' -> Const Any (LineTexture n')
forall n n'.
Iso (LineTexture n) (LineTexture n') (Texture n) (Texture n')
_LineTexture ((Texture n' -> Const Any (Texture n'))
-> LineTexture n' -> Const Any (LineTexture n'))
-> ((AlphaColour Double -> Const Any (AlphaColour Double))
-> Texture n' -> Const Any (Texture n'))
-> Getting Any (LineTexture n') (AlphaColour Double)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (AlphaColour Double -> Const Any (AlphaColour Double))
-> Texture n' -> Const Any (Texture n')
forall n. Prism' (Texture n) (AlphaColour Double)
_AC) (AlphaColour Double -> AlphaColour Double -> Bool
forall a. Eq a => a -> a -> Bool
== Colour Double -> AlphaColour Double
forall a. Num a => Colour a -> AlphaColour a
opaque Colour Double
forall a. Num a => Colour a
black)
lineColor :: (InSpace V2 n a, Color c, Typeable n, Floating n, HasStyle a) => c -> a -> a
lineColor :: c -> a -> a
lineColor = Texture n -> a -> a
forall n a.
(InSpace V2 n a, Typeable n, Floating n, HasStyle a) =>
Texture n -> a -> a
lineTexture (Texture n -> a -> a) -> (c -> Texture n) -> c -> a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SomeColor -> Texture n
forall n. SomeColor -> Texture n
SC (SomeColor -> Texture n) -> (c -> SomeColor) -> c -> Texture n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> SomeColor
forall c. Color c => c -> SomeColor
SomeColor
lc :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => Colour Double -> a -> a
lc :: Colour Double -> a -> a
lc = Colour Double -> a -> a
forall n a c.
(InSpace V2 n a, Color c, Typeable n, Floating n, HasStyle a) =>
c -> a -> a
lineColor
lcA :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => AlphaColour Double -> a -> a
lcA :: AlphaColour Double -> a -> a
lcA = AlphaColour Double -> a -> a
forall n a c.
(InSpace V2 n a, Color c, Typeable n, Floating n, HasStyle a) =>
c -> a -> a
lineColor
lineLGradient :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => LGradient n -> a -> a
lineLGradient :: LGradient n -> a -> a
lineLGradient LGradient n
g = Texture n -> a -> a
forall n a.
(InSpace V2 n a, Typeable n, Floating n, HasStyle a) =>
Texture n -> a -> a
lineTexture (LGradient n -> Texture n
forall n. LGradient n -> Texture n
LG LGradient n
g)
lineRGradient :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => RGradient n -> a -> a
lineRGradient :: RGradient n -> a -> a
lineRGradient RGradient n
g = Texture n -> a -> a
forall n a.
(InSpace V2 n a, Typeable n, Floating n, HasStyle a) =>
Texture n -> a -> a
lineTexture (RGradient n -> Texture n
forall n. RGradient n -> Texture n
RG RGradient n
g)
newtype FillTexture n = FillTexture (Recommend (Last (Texture n)))
deriving (Typeable, b -> FillTexture n -> FillTexture n
NonEmpty (FillTexture n) -> FillTexture n
FillTexture n -> FillTexture n -> FillTexture n
(FillTexture n -> FillTexture n -> FillTexture n)
-> (NonEmpty (FillTexture n) -> FillTexture n)
-> (forall b. Integral b => b -> FillTexture n -> FillTexture n)
-> Semigroup (FillTexture n)
forall b. Integral b => b -> FillTexture n -> FillTexture n
forall n. NonEmpty (FillTexture n) -> FillTexture n
forall n. FillTexture n -> FillTexture n -> FillTexture n
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
forall n b. Integral b => b -> FillTexture n -> FillTexture n
stimes :: b -> FillTexture n -> FillTexture n
$cstimes :: forall n b. Integral b => b -> FillTexture n -> FillTexture n
sconcat :: NonEmpty (FillTexture n) -> FillTexture n
$csconcat :: forall n. NonEmpty (FillTexture n) -> FillTexture n
<> :: FillTexture n -> FillTexture n -> FillTexture n
$c<> :: forall n. FillTexture n -> FillTexture n -> FillTexture n
Semigroup)
instance Typeable n => AttributeClass (FillTexture n)
_FillTexture :: Iso' (FillTexture n) (Recommend (Texture n))
_FillTexture :: p (Recommend (Texture n)) (f (Recommend (Texture n)))
-> p (FillTexture n) (f (FillTexture n))
_FillTexture = (FillTexture n -> Recommend (Texture n))
-> (Recommend (Texture n) -> FillTexture n)
-> Iso
(FillTexture n)
(FillTexture n)
(Recommend (Texture n))
(Recommend (Texture n))
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso FillTexture n -> Recommend (Texture n)
forall n. FillTexture n -> Recommend (Texture n)
getter Recommend (Texture n) -> FillTexture n
forall n. Recommend (Texture n) -> FillTexture n
setter
where
getter :: FillTexture n -> Recommend (Texture n)
getter (FillTexture (Recommend (Last Texture n
t))) = Texture n -> Recommend (Texture n)
forall a. a -> Recommend a
Recommend Texture n
t
getter (FillTexture (Commit (Last Texture n
t))) = Texture n -> Recommend (Texture n)
forall a. a -> Recommend a
Commit Texture n
t
setter :: Recommend (Texture n) -> FillTexture n
setter (Recommend Texture n
t) = Recommend (Last (Texture n)) -> FillTexture n
forall n. Recommend (Last (Texture n)) -> FillTexture n
FillTexture (Last (Texture n) -> Recommend (Last (Texture n))
forall a. a -> Recommend a
Recommend (Texture n -> Last (Texture n)
forall a. a -> Last a
Last Texture n
t))
setter (Commit Texture n
t) = Recommend (Last (Texture n)) -> FillTexture n
forall n. Recommend (Last (Texture n)) -> FillTexture n
FillTexture (Last (Texture n) -> Recommend (Last (Texture n))
forall a. a -> Recommend a
Commit (Texture n -> Last (Texture n)
forall a. a -> Last a
Last Texture n
t))
type instance V (FillTexture n) = V2
type instance N (FillTexture n) = n
instance Floating n => Transformable (FillTexture n) where
transform :: Transformation (V (FillTexture n)) (N (FillTexture n))
-> FillTexture n -> FillTexture n
transform = ASetter (FillTexture n) (FillTexture n) (Texture n) (Texture n)
-> (Texture n -> Texture n) -> FillTexture n -> FillTexture n
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over ((Recommend (Texture n) -> Identity (Recommend (Texture n)))
-> FillTexture n -> Identity (FillTexture n)
forall n. Iso' (FillTexture n) (Recommend (Texture n))
_FillTexture ((Recommend (Texture n) -> Identity (Recommend (Texture n)))
-> FillTexture n -> Identity (FillTexture n))
-> ((Texture n -> Identity (Texture n))
-> Recommend (Texture n) -> Identity (Recommend (Texture n)))
-> ASetter (FillTexture n) (FillTexture n) (Texture n) (Texture n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Texture n -> Identity (Texture n))
-> Recommend (Texture n) -> Identity (Recommend (Texture n))
forall a b. Lens (Recommend a) (Recommend b) a b
_recommend) ((Texture n -> Texture n) -> FillTexture n -> FillTexture n)
-> (Transformation V2 n -> Texture n -> Texture n)
-> Transformation V2 n
-> FillTexture n
-> FillTexture n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Transformation V2 n -> Texture n -> Texture n
forall t. Transformable t => Transformation (V t) (N t) -> t -> t
transform
instance Default (FillTexture n) where
def :: FillTexture n
def = Texture n -> FillTexture n
forall n. Texture n -> FillTexture n
mkFillTexture (Texture n -> FillTexture n) -> Texture n -> FillTexture n
forall a b. (a -> b) -> a -> b
$ Tagged (AlphaColour Double) (Identity (AlphaColour Double))
-> Tagged (Texture n) (Identity (Texture n))
forall n. Prism' (Texture n) (AlphaColour Double)
_AC (Tagged (AlphaColour Double) (Identity (AlphaColour Double))
-> Tagged (Texture n) (Identity (Texture n)))
-> AlphaColour Double -> Texture n
forall t b. AReview t b -> b -> t
## AlphaColour Double
forall a. Num a => AlphaColour a
transparent
getFillTexture :: FillTexture n -> Texture n
getFillTexture :: FillTexture n -> Texture n
getFillTexture (FillTexture Recommend (Last (Texture n))
tx) = Last (Texture n) -> Texture n
forall a. Last a -> a
getLast (Last (Texture n) -> Texture n)
-> (Recommend (Last (Texture n)) -> Last (Texture n))
-> Recommend (Last (Texture n))
-> Texture n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Recommend (Last (Texture n)) -> Last (Texture n)
forall a. Recommend a -> a
getRecommend (Recommend (Last (Texture n)) -> Texture n)
-> Recommend (Last (Texture n)) -> Texture n
forall a b. (a -> b) -> a -> b
$ Recommend (Last (Texture n))
tx
fillTexture :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => Texture n -> a -> a
fillTexture :: Texture n -> a -> a
fillTexture = FillTexture n -> a -> a
forall a d.
(AttributeClass a, Transformable a, V a ~ V d, N a ~ N d,
HasStyle d) =>
a -> d -> d
applyTAttr (FillTexture n -> a -> a)
-> (Texture n -> FillTexture n) -> Texture n -> a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Texture n -> FillTexture n
forall n. Texture n -> FillTexture n
mkFillTexture
mkFillTexture :: Texture n -> FillTexture n
mkFillTexture :: Texture n -> FillTexture n
mkFillTexture = Recommend (Last (Texture n)) -> FillTexture n
forall n. Recommend (Last (Texture n)) -> FillTexture n
FillTexture (Recommend (Last (Texture n)) -> FillTexture n)
-> (Texture n -> Recommend (Last (Texture n)))
-> Texture n
-> FillTexture n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Last (Texture n) -> Recommend (Last (Texture n))
forall a. a -> Recommend a
Commit (Last (Texture n) -> Recommend (Last (Texture n)))
-> (Texture n -> Last (Texture n))
-> Texture n
-> Recommend (Last (Texture n))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Texture n -> Last (Texture n)
forall a. a -> Last a
Last
_fillTextureR :: (Typeable n, Floating n) => Lens' (Style V2 n) (Recommend (Texture n))
_fillTextureR :: Lens' (Style V2 n) (Recommend (Texture n))
_fillTextureR = (Maybe (FillTexture n) -> f (Maybe (FillTexture n)))
-> Style V2 n -> f (Style V2 n)
forall a (v :: * -> *) n.
(V a ~ v, N a ~ n, AttributeClass a, Transformable a) =>
Lens' (Style v n) (Maybe a)
atTAttr ((Maybe (FillTexture n) -> f (Maybe (FillTexture n)))
-> Style V2 n -> f (Style V2 n))
-> ((Recommend (Texture n) -> f (Recommend (Texture n)))
-> Maybe (FillTexture n) -> f (Maybe (FillTexture n)))
-> (Recommend (Texture n) -> f (Recommend (Texture n)))
-> Style V2 n
-> f (Style V2 n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FillTexture n
-> (FillTexture n -> Bool)
-> Iso' (Maybe (FillTexture n)) (FillTexture n)
forall a. a -> (a -> Bool) -> Iso' (Maybe a) a
anon FillTexture n
forall a. Default a => a
def FillTexture n -> Bool
forall n. FillTexture n -> Bool
isDef ((FillTexture n -> f (FillTexture n))
-> Maybe (FillTexture n) -> f (Maybe (FillTexture n)))
-> ((Recommend (Texture n) -> f (Recommend (Texture n)))
-> FillTexture n -> f (FillTexture n))
-> (Recommend (Texture n) -> f (Recommend (Texture n)))
-> Maybe (FillTexture n)
-> f (Maybe (FillTexture n))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Recommend (Texture n) -> f (Recommend (Texture n)))
-> FillTexture n -> f (FillTexture n)
forall n. Iso' (FillTexture n) (Recommend (Texture n))
_FillTexture
where
isDef :: FillTexture n -> Bool
isDef = Getting Any (FillTexture n) (AlphaColour Double)
-> (AlphaColour Double -> Bool) -> FillTexture n -> Bool
forall s a. Getting Any s a -> (a -> Bool) -> s -> Bool
anyOf ((Recommend (Texture n) -> Const Any (Recommend (Texture n)))
-> FillTexture n -> Const Any (FillTexture n)
forall n. Iso' (FillTexture n) (Recommend (Texture n))
_FillTexture ((Recommend (Texture n) -> Const Any (Recommend (Texture n)))
-> FillTexture n -> Const Any (FillTexture n))
-> ((AlphaColour Double -> Const Any (AlphaColour Double))
-> Recommend (Texture n) -> Const Any (Recommend (Texture n)))
-> Getting Any (FillTexture n) (AlphaColour Double)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Texture n -> Const Any (Texture n))
-> Recommend (Texture n) -> Const Any (Recommend (Texture n))
forall a. Prism' (Recommend a) a
_Recommend ((Texture n -> Const Any (Texture n))
-> Recommend (Texture n) -> Const Any (Recommend (Texture n)))
-> ((AlphaColour Double -> Const Any (AlphaColour Double))
-> Texture n -> Const Any (Texture n))
-> (AlphaColour Double -> Const Any (AlphaColour Double))
-> Recommend (Texture n)
-> Const Any (Recommend (Texture n))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (AlphaColour Double -> Const Any (AlphaColour Double))
-> Texture n -> Const Any (Texture n)
forall n. Prism' (Texture n) (AlphaColour Double)
_AC) (AlphaColour Double -> AlphaColour Double -> Bool
forall a. Eq a => a -> a -> Bool
== AlphaColour Double
forall a. Num a => AlphaColour a
transparent)
_fillTexture :: (Typeable n, Floating n) => Lens' (Style V2 n) (Texture n)
_fillTexture :: Lens' (Style V2 n) (Texture n)
_fillTexture = (Recommend (Texture n) -> f (Recommend (Texture n)))
-> Style V2 n -> f (Style V2 n)
forall n.
(Typeable n, Floating n) =>
Lens' (Style V2 n) (Recommend (Texture n))
_fillTextureR ((Recommend (Texture n) -> f (Recommend (Texture n)))
-> Style V2 n -> f (Style V2 n))
-> ((Texture n -> f (Texture n))
-> Recommend (Texture n) -> f (Recommend (Texture n)))
-> (Texture n -> f (Texture n))
-> Style V2 n
-> f (Style V2 n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Texture n -> f (Texture n))
-> Recommend (Texture n) -> f (Recommend (Texture n))
forall a b. Iso (Recommend a) (Recommend b) a b
committed
fillColor :: (InSpace V2 n a, Color c, Typeable n, Floating n, HasStyle a) => c -> a -> a
fillColor :: c -> a -> a
fillColor = Texture n -> a -> a
forall n a.
(InSpace V2 n a, Typeable n, Floating n, HasStyle a) =>
Texture n -> a -> a
fillTexture (Texture n -> a -> a) -> (c -> Texture n) -> c -> a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SomeColor -> Texture n
forall n. SomeColor -> Texture n
SC (SomeColor -> Texture n) -> (c -> SomeColor) -> c -> Texture n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> SomeColor
forall c. Color c => c -> SomeColor
SomeColor
recommendFillColor :: (InSpace V2 n a, Color c, Typeable n, Floating n, HasStyle a) => c -> a -> a
recommendFillColor :: c -> a -> a
recommendFillColor =
FillTexture n -> a -> a
forall a d.
(AttributeClass a, Transformable a, V a ~ V d, N a ~ N d,
HasStyle d) =>
a -> d -> d
applyTAttr (FillTexture n -> a -> a) -> (c -> FillTexture n) -> c -> a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Recommend (Last (Texture n)) -> FillTexture n
forall n. Recommend (Last (Texture n)) -> FillTexture n
FillTexture (Recommend (Last (Texture n)) -> FillTexture n)
-> (c -> Recommend (Last (Texture n))) -> c -> FillTexture n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Last (Texture n) -> Recommend (Last (Texture n))
forall a. a -> Recommend a
Recommend (Last (Texture n) -> Recommend (Last (Texture n)))
-> (c -> Last (Texture n)) -> c -> Recommend (Last (Texture n))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Texture n -> Last (Texture n)
forall a. a -> Last a
Last (Texture n -> Last (Texture n))
-> (c -> Texture n) -> c -> Last (Texture n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SomeColor -> Texture n
forall n. SomeColor -> Texture n
SC (SomeColor -> Texture n) -> (c -> SomeColor) -> c -> Texture n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> SomeColor
forall c. Color c => c -> SomeColor
SomeColor
fc :: (InSpace V2 n a, Floating n, Typeable n, HasStyle a) => Colour Double -> a -> a
fc :: Colour Double -> a -> a
fc = Colour Double -> a -> a
forall n a c.
(InSpace V2 n a, Color c, Typeable n, Floating n, HasStyle a) =>
c -> a -> a
fillColor
fcA :: (InSpace V2 n a, Floating n, Typeable n, HasStyle a) => AlphaColour Double -> a -> a
fcA :: AlphaColour Double -> a -> a
fcA = AlphaColour Double -> a -> a
forall n a c.
(InSpace V2 n a, Color c, Typeable n, Floating n, HasStyle a) =>
c -> a -> a
fillColor
data FillTextureLoops n = FillTextureLoops
instance Typeable n => SplitAttribute (FillTextureLoops n) where
type AttrType (FillTextureLoops n) = FillTexture n
type PrimType (FillTextureLoops n) = Path V2 n
primOK :: FillTextureLoops n -> PrimType (FillTextureLoops n) -> Bool
primOK FillTextureLoops n
_ = (Located (Trail V2 n) -> Bool) -> [Located (Trail V2 n)] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (Trail V2 n -> Bool
forall (v :: * -> *) n. Trail v n -> Bool
isLoop (Trail V2 n -> Bool)
-> (Located (Trail V2 n) -> Trail V2 n)
-> Located (Trail V2 n)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Located (Trail V2 n) -> Trail V2 n
forall a. Located a -> a
unLoc) ([Located (Trail V2 n)] -> Bool)
-> (Path V2 n -> [Located (Trail V2 n)]) -> Path V2 n -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Path V2 n -> [Located (Trail V2 n)]
forall (v :: * -> *) n. Path v n -> [Located (Trail v n)]
pathTrails
splitTextureFills
:: forall b v n a. (
Typeable n) => RTree b v n a -> RTree b v n a
splitTextureFills :: RTree b v n a -> RTree b v n a
splitTextureFills = FillTextureLoops n -> RTree b v n a -> RTree b v n a
forall code b (v :: * -> *) n a.
SplitAttribute code =>
code -> RTree b v n a -> RTree b v n a
splitAttr (FillTextureLoops n
forall n. FillTextureLoops n
FillTextureLoops :: FillTextureLoops n)