Skip to content

Commit

Permalink
Export more style lenses in TwoD.
Browse files Browse the repository at this point in the history
  • Loading branch information
cchalmers committed Feb 28, 2015
1 parent b41d398 commit 73d0676
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
6 changes: 4 additions & 2 deletions src/Diagrams/Attributes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ getLineCap (LineCapA (Last c)) = c
lineCap :: HasStyle a => LineCap -> a -> a
lineCap = applyAttr . LineCapA . Last

-- | Lens onto the line cap in a style
-- | Lens onto the line cap in a style.
_lineCap :: Lens' (Style v n) LineCap
_lineCap = atAttr . mapping _LineCap . non def

Expand Down Expand Up @@ -382,6 +382,7 @@ getLineJoin (LineJoinA (Last j)) = j
lineJoin :: HasStyle a => LineJoin -> a -> a
lineJoin = applyAttr . LineJoinA . Last

-- | Lens onto the line join type in a style.
_lineJoin :: Lens' (Style v n) LineJoin
_lineJoin = atAttr . mapping _LineJoin . non def

Expand Down Expand Up @@ -410,6 +411,7 @@ lineMiterLimit = applyAttr . LineMiterLimit . Last
lineMiterLimitA :: HasStyle a => LineMiterLimit -> a -> a
lineMiterLimitA = applyAttr

-- | Lens onto the line miter limit in a style.
_lineMiterLimit :: Lens' (Style v n) Double
_lineMiterLimit = atAttr . mapping _LineMiterLimit . non 10

Expand All @@ -431,7 +433,7 @@ _recommend :: Lens (Recommend a) (Recommend b) a b
_recommend f (Recommend a) = Recommend <$> f a
_recommend f (Commit a) = Commit <$> f a

-- | Lens onto weather something is committed or not.
-- | Lens onto whether something is committed or not.
isCommitted :: Lens' (Recommend a) Bool
isCommitted f r@(Recommend a) = f False <&> \b -> if b then Commit a else r
isCommitted f r@(Commit a) = f True <&> \b -> if b then r else Recommend a
Expand Down
18 changes: 10 additions & 8 deletions src/Diagrams/TwoD.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
-----------------------------------------------------------------------------
-- |
-- Module : Diagrams.TwoD
-- Copyright : (c) 2011 diagrams-lib team (see LICENSE)
-- Copyright : (c) 2011-2015 diagrams-lib team (see LICENSE)
-- License : BSD-style (see LICENSE)
-- Maintainer : diagrams-discuss@googlegroups.com
--
Expand Down Expand Up @@ -162,6 +162,7 @@ module Diagrams.TwoD
-- * Text
, text, topLeftText, alignedText, baselineText
, font, italic, oblique, bold, fontSize
, _font, _fontSizeR, _fontSize
, fontSizeO, fontSizeL, fontSizeN, fontSizeG

-- * Images
Expand Down Expand Up @@ -242,20 +243,21 @@ module Diagrams.TwoD

-- * Textures
, Texture(..), solid
, SpreadMethod(..), GradientStop(..), mkStops, getFillTexture
, fillTexture, getLineTexture, lineTexture, lineTextureA
, stopFraction, stopColor
, SpreadMethod(..), GradientStop(..)
, _FillTexture, fillTexture, _fillTexture, getFillTexture
, _LineTexture, lineTexture, _lineTexture, lineTextureA, getLineTexture
, stopFraction, stopColor, mkStops

, LGradient(..), lGradStops, lGradTrans, lGradStart, lGradEnd
, lGradSpreadMethod, defaultLG, _LG, mkLinearGradient
, LGradient(..), _LG, lGradStops, lGradTrans, lGradStart, lGradEnd
, lGradSpreadMethod, defaultLG, mkLinearGradient

, RGradient(..)
, rGradStops, rGradCenter0, rGradRadius0, rGradCenter1, rGradRadius1
, rGradTrans, rGradSpreadMethod, defaultRG, _RG, mkRadialGradient

-- ** Colors
, fillColor, fc, fcA, recommendFillColor
, lineColor, lc, lcA, _SC
, fillColor, _SC, fc, fcA, recommendFillColor
, lineColor, lc, lcA

-- * Visual aids for understanding the internal model
, showOrigin
Expand Down
5 changes: 3 additions & 2 deletions src/Diagrams/TwoD/Text.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
-----------------------------------------------------------------------------
-- |
-- Module : Diagrams.TwoD.Text
-- Copyright : (c) 2011 diagrams-lib team (see LICENSE)
-- Copyright : (c) 2011-2015 diagrams-lib team (see LICENSE)
-- License : BSD-style (see LICENSE)
-- Maintainer : diagrams-discuss@googlegroups.com
--
Expand All @@ -20,7 +20,7 @@
module Diagrams.TwoD.Text (
-- * Creating text diagrams
Text(..), TextAlignment(..)
, text, topLeftText, alignedText, baselineText
, text, topLeftText, alignedText, baselineText, mkText

-- * Text attributes
-- ** Font family
Expand Down Expand Up @@ -186,6 +186,7 @@ getFont (Font (Last f)) = f
font :: HasStyle a => String -> a -> a
font = applyAttr . Font . Last

-- | Lens onto the font name of a style.
_font :: (Typeable n, OrderedField n) => Lens' (Style v n) (Maybe String)
_font = atAttr . mapping _Font

Expand Down

0 comments on commit 73d0676

Please sign in to comment.