Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New scaleInvPrim function #71

Merged
merged 9 commits into from
Apr 17, 2013
13 changes: 11 additions & 2 deletions src/Diagrams/TwoD/Transform.hs
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ module Diagrams.TwoD.Transform
, shearingY, shearY

-- * Scale invariance
, ScaleInv(..), scaleInv
, ScaleInv(..), scaleInv, scaleInvPrim

) where

@@ -311,4 +311,13 @@ instance (V t ~ R2, Transformable t) => Transformable (ScaleInv t) where
trans = translate (l' .-. l)

instance (Renderable t b, V t ~ R2) => Renderable (ScaleInv t) b where
render b = render b . unScaleInv
render b = render b . unScaleInv

-- | Create a diagram from a single scale-invariant primitive, which
-- will have an /empty/ envelope, trace, and query. The reason is
-- that the envelope, trace, and query cannot be cached---applying a
-- transformation would cause the cached envelope, etc. to get "out
-- of sync" with the scale-invariant object.
scaleInvPrim :: (Transformable t, Renderable t b, V t ~ R2, Monoid m)
=> t -> R2 -> QDiagram b R2 m
scaleInvPrim t d = mkQD (Prim $ scaleInv t d) mempty mempty mempty mempty