From d9bdc9010ee2a707515b9691d6a7be987de69c84 Mon Sep 17 00:00:00 2001 From: Jeffrey Rosenbluth Date: Sun, 30 Mar 2014 09:28:29 -0400 Subject: [PATCH] add lwG, hsG, ... --- src/Diagrams/TwoD.hs | 8 ++++---- src/Diagrams/TwoD/Arrow.hs | 20 ++++++++++++++------ src/Diagrams/TwoD/Attributes.hs | 20 ++++++++++++++------ src/Diagrams/TwoD/Text.hs | 2 +- 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/Diagrams/TwoD.hs b/src/Diagrams/TwoD.hs index 71db53d6..a618833e 100644 --- a/src/Diagrams/TwoD.hs +++ b/src/Diagrams/TwoD.hs @@ -154,9 +154,9 @@ module Diagrams.TwoD , shaftColor , shaftStyle , HeadSize, headSize, headSizeA, getHeadSize - , hs, hsO, hsL, hsN + , hs, hsO, hsL, hsN, hsG , TailSize, tailSize, tailSizeA, getTailSize - , ts, tsO, tsL, tsN + , ts, tsO, tsL, tsN, tsG -- * Text , text, topLeftText, alignedText, baselineText @@ -233,12 +233,12 @@ module Diagrams.TwoD , sized, sizedAs -- ** Width - , LineWidth, getLineWidth, lineWidth, lineWidthA, lw, lwN, lwO, lwL + , LineWidth, getLineWidth, lineWidth, lineWidthA, lw, lwN, lwO, lwL, lwG , ultraThin, veryThin, thin, medium, thick, veryThick -- ** Dashing , Dashing(..), DashingA, getDashing - , dashing, dashingO, dashingL, dashingN + , dashing, dashingO, dashingL, dashingN, dashingG -- * Visual aids for understanding the internal model , showOrigin diff --git a/src/Diagrams/TwoD/Arrow.hs b/src/Diagrams/TwoD/Arrow.hs index 3577247e..54eca691 100644 --- a/src/Diagrams/TwoD/Arrow.hs +++ b/src/Diagrams/TwoD/Arrow.hs @@ -73,9 +73,9 @@ module Diagrams.TwoD.Arrow -- * Attributes , HeadSize, headSize, headSizeA, getHeadSize - , hs, hsO, hsL, hsN + , hs, hsO, hsL, hsN, hsG , TailSize, tailSize, tailSizeA, getTailSize - , ts, tsO, tsL, tsN + , ts, tsO, tsL, tsN, tsG -- * Options , ArrowOpts(..) @@ -308,9 +308,13 @@ headSizeA = applyGTAttr getHeadSize :: HeadSize -> Measure R2 getHeadSize (HeadSize (Last s)) = s --- | A convenient synonym for 'headSize (Global w)'. +-- | Default for 'headSize'. hs :: (HasStyle a, V a ~ R2) => Double -> a -> a -hs w = headSize (Global w) +hs = hsG + +-- | A convenient synonym for 'headSize (Global w)'. +hsG :: (HasStyle a, V a ~ R2) => Double -> a -> a +hsG w = headSize (Global w) -- | A convenient synonym for 'headSize (Normalized w)'. hsN :: (HasStyle a, V a ~ R2) => Double -> a -> a @@ -346,9 +350,13 @@ tailSizeA = applyGTAttr getTailSize :: TailSize -> Measure R2 getTailSize (TailSize (Last s)) = s --- | A convenient synonym for 'tailSize (Global w)'. +-- | Default for 'tailSize' ts :: (HasStyle a, V a ~ R2) => Double -> a -> a -ts w = tailSize (Global w) +ts = tsG + +-- | A convenient synonym for 'tailSize (Global w)'. +tsG :: (HasStyle a, V a ~ R2) => Double -> a -> a +tsG w = tailSize (Global w) -- | A convenient synonym for 'tailSize (Normalized w)'. tsN :: (HasStyle a, V a ~ R2) => Double -> a -> a diff --git a/src/Diagrams/TwoD/Attributes.hs b/src/Diagrams/TwoD/Attributes.hs index 0f0262ef..45e7f1d5 100644 --- a/src/Diagrams/TwoD/Attributes.hs +++ b/src/Diagrams/TwoD/Attributes.hs @@ -23,12 +23,12 @@ module Diagrams.TwoD.Attributes ( -- ** Width LineWidth, getLineWidth, lineWidth, lineWidthA - , lw, lwN, lwO, lwL + , lw, lwN, lwO, lwL, lwG , ultraThin, veryThin, thin, medium, thick, veryThick -- ** Dashing , Dashing(..), DashingA, getDashing, setDashing - , dashing, dashingN, dashingO, dashingL + , dashing, dashingN, dashingO, dashingL, dashingG ) where @@ -70,9 +70,13 @@ lineWidth = applyGTAttr . LineWidth . Last lineWidthA :: (HasStyle a, V a ~ R2) => LineWidth -> a -> a lineWidthA = applyGTAttr --- | A convenient synonym for 'lineWidth (Global w)'. +-- | Default for 'lineWidth'. lw :: (HasStyle a, V a ~ R2) => Double -> a -> a -lw w = lineWidth (Global w) +lw = lwG + +-- | A convenient synonym for 'lineWidth (Global w)'. +lwG :: (HasStyle a, V a ~ R2) => Double -> a -> a +lwG w = lineWidth (Global w) -- | A convenient synonym for 'lineWidth (Normalized w)'. lwN :: (HasStyle a, V a ~ R2) => Double -> a -> a @@ -130,9 +134,13 @@ setDashing :: (HasStyle a, V a ~ R2) => -> a -> a setDashing ds offs = applyGTAttr (DashingA (Last (Dashing ds offs))) --- | A convenient synonym for 'setDashing (Global w)'. +-- | Default for 'setDashing'. dashing :: (HasStyle a, V a ~ R2) => [Double] -> Double -> a -> a -dashing w v = setDashing (map Global w) (Global v) +dashing = dashingG + +-- | A convenient synonym for 'setDashing (Global w)'. +dashingG :: (HasStyle a, V a ~ R2) => [Double] -> Double -> a -> a +dashingG w v = setDashing (map Global w) (Global v) -- | A convenient synonym for 'setDashing (Normalized w)'. dashingN :: (HasStyle a, V a ~ R2) => [Double] -> Double -> a -> a diff --git a/src/Diagrams/TwoD/Text.hs b/src/Diagrams/TwoD/Text.hs index 8e188c03..01f2a786 100644 --- a/src/Diagrams/TwoD/Text.hs +++ b/src/Diagrams/TwoD/Text.hs @@ -169,7 +169,7 @@ instance AttributeClass FontSize type instance V FontSize = R2 instance Default FontSize where - def = FontSize (Last (Local 1)) + def = FontSize (Last (Output 1)) instance Transformable FontSize where transform t (FontSize (Last s)) =