Skip to content

Commit

Permalink
Fix up so it compiles
Browse files Browse the repository at this point in the history
* revert using MeasureX
* various R2 -> R2Ish changes
  • Loading branch information
Mathnerd314 committed Jun 19, 2014
1 parent 8c35f53 commit f257330
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/Diagrams/ThreeD/Transform.hs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ pointAt' :: (R3Ish v) => v -> v -> v -> Transformation v
pointAt' about initial final = pointAtUnit (normalized about) (normalized initial) (normalized final)

-- | pointAtUnit has the same behavior as @pointAt@, but takes unit vectors.
pointAtUnit :: R3 -> R3 -> R3 -> T3
pointAtUnit :: (R3Ish v) => v -> v -> v -> Transformation v
pointAtUnit about initial final = tilt <> pan where
-- rotating u by (signedAngle rel u v) about rel gives a vector in the direction of v
signedAngle rel u v = signum (cross3 u v <.> rel) *^ angleBetween u v
Expand Down
8 changes: 5 additions & 3 deletions src/Diagrams/TwoD/Arrow.hs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ import Control.Lens (Lens', Setter', Traversal',
makeLensesWith, view, (%~), (&),
(.~), (^.))
import Data.AffineSpace
import Data.Data (Data)
import Data.Default.Class
import Data.Functor ((<$>))
import Data.Maybe (fromMaybe)
Expand Down Expand Up @@ -251,7 +250,7 @@ headSty opts = fc black (opts^.headStyle)
tailSty :: (R2Ish v) => ArrowOpts v -> Style v
tailSty opts = fc black (opts^.tailStyle)

fromMeasure :: (Data d, Ord d, Fractional d) => d -> d -> MeasureX d -> d
fromMeasure :: (R2Ish v) => Scalar v -> Scalar v -> Measure v -> Scalar v
fromMeasure g n m = u
where Output u = toOutput g n m

Expand All @@ -278,7 +277,10 @@ colorJoint sStyle =

-- | Get line width from a style.
widthOfJoint :: forall v. (R2Ish v) => Style v -> Scalar v -> Scalar v -> Scalar v
widthOfJoint sStyle gToO nToO = maybe (fromMeasure gToO nToO (Output 1)) (fromMeasure gToO nToO) (fmap getLineWidth . (getAttr :: Style v -> Maybe (LineWidth v)) $ sStyle)
widthOfJoint sStyle gToO nToO =
maybe (fromMeasure gToO nToO (Output 1 :: Measure v)) -- Should be same as default line width
(fromMeasure gToO nToO)
(fmap getLineWidth . getAttr $ sStyle :: Maybe (Measure v))

-- | Combine the head and its joint into a single scale invariant diagram
-- and move the origin to the attachment point. Return the diagram
Expand Down
2 changes: 1 addition & 1 deletion src/Diagrams/TwoD/Attributes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ import Data.VectorSpace

-- | Standard 'Measures'.
none, ultraThin, veryThin, thin, medium, thick, veryThick, ultraThick,
tiny, verySmall, small, normal, large, veryLarge, huge :: (Floating d) => MeasureX d
tiny, verySmall, small, normal, large, veryLarge, huge :: (Floating (Scalar v)) => Measure v
none = Output 0
ultraThin = Normalized 0.0005 `atLeast` Output 0.5
veryThin = Normalized 0.001 `atLeast` Output 0.5
Expand Down
12 changes: 6 additions & 6 deletions src/Diagrams/TwoD/Combinators.hs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ hcat' = cat' unitX

-- | A convenient synonym for horizontal concatenation with
-- separation: @hsep s === hcat' (with & sep .~ s)@.
hsep :: (Juxtaposable a, HasOrigin a, Monoid' a, V a ~ R2)
=> Scalar R2 -> [a] -> a
hsep :: (Juxtaposable a, HasOrigin a, Monoid' a, V a ~ v, R2Ish v)
=> Scalar v -> [a] -> a
hsep s = hcat' (def & sep .~ s)

-- | Lay out a list of juxtaposable objects in a column from top to
Expand Down Expand Up @@ -146,8 +146,8 @@ vcat' = cat' (negateV unitY)

-- | A convenient synonym for vertical concatenation with
-- separation: @vsep s === vcat' (with & sep .~ s)@.
vsep :: (Juxtaposable a, HasOrigin a, Monoid' a, V a ~ R2)
=> Scalar R2 -> [a] -> a
vsep :: (Juxtaposable a, HasOrigin a, Monoid' a, V a ~ v, R2Ish v)
=> Scalar v -> [a] -> a
vsep s = vcat' (def & sep .~ s)

-- | @strutR2 v@ is a two-dimensional diagram which produces no
Expand Down Expand Up @@ -260,6 +260,6 @@ bg c d = d <> boundingRect d # lineWidth (Output 0) # fc c
-- | Similar to 'bg' but makes the colored background rectangle larger than
-- the diagram. The first parameter is used to set how far the background
-- extends beyond the diagram.
bgFrame :: (Renderable (Path R2) b, Backend b R2)
=> Double -> Colour Double -> Diagram b R2 -> Diagram b R2
bgFrame :: (R2Ish v, Renderable (Path v) b, Backend b v)
=> Scalar v -> Colour Double -> Diagram b v -> Diagram b v
bgFrame f c d = d <> boundingRect (frame f d) # lineWidth (Output 0) # fc c
3 changes: 1 addition & 2 deletions src/Diagrams/TwoD/Image.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ import Data.Colour (AlphaColour)
import Diagrams.Core

import Diagrams.Attributes (colorToSRGBA)
import Diagrams.Path (Path)
import Diagrams.TwoD.Path (isInsideEvenOdd)
import Diagrams.TwoD.Shapes (rect)
import Diagrams.TwoD.Types (R2, T2)
import Diagrams.TwoD.Types (R2Ish)

import Data.AffineSpace ((.-.))
import Data.Semigroup
Expand Down
3 changes: 2 additions & 1 deletion src/Diagrams/TwoD/Offset.hs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,8 @@ capArc r c a b = trailLike . moveTo c $ fs

-- Arc helpers
-- always picks the shorter arc (< τ/2)
arcV :: (R2Ish v) => (TrailLike t, V t ~ v) => v -> v -> tarcV u v = arc (direction u) (angleBetween v u)
arcV :: (R2Ish v) => (TrailLike t, V t ~ v) => v -> v -> t
arcV u v = arc (direction u) (angleBetween v u)

arcVCW :: (R2Ish v) => (TrailLike t, V t ~ v) => v -> v -> t
arcVCW u v = arc (direction u) (negateV $ angleBetween v u)
Expand Down

0 comments on commit f257330

Please sign in to comment.