packages feed

plot-light 0.1.0.2 → 0.1.0.3

raw patch · 5 files changed

+14/−30 lines, 5 files

Files

plot-light.cabal view
@@ -1,5 +1,5 @@ name:                plot-light-version:             0.1.0.2+version:             0.1.0.3 synopsis:            A lightweight plotting library, exporting to SVG description:         A lightweight plotting library, exporting to SVG homepage:            https://github.com/ocramz/plot-light
src/Graphics/Rendering/Plot/Light.hs view
@@ -1,21 +1,21 @@ {-# LANGUAGE OverloadedStrings #-}-module Graphics.Rendering.Plot.Light where+module Graphics.Rendering.Plot.Light (module Plot) where  -- import Data.Foldable import qualified Data.Text as T  import Text.Blaze.Svg-import Text.Blaze.Svg11 ((!), mkPath, rotate, translate, l, m)-import qualified Text.Blaze.Svg11 as S-import qualified Text.Blaze.Svg11.Attributes as A+-- import Text.Blaze.Svg11 ((!), mkPath, rotate, translate, l, m)+-- import qualified Text.Blaze.Svg11 as S+-- import qualified Text.Blaze.Svg11.Attributes as A import Text.Blaze.Svg.Renderer.String (renderSvg)  import qualified Data.Colour as C import qualified Data.Colour.Names as C import qualified Data.Colour.SRGB as C --- data BoundingBox a = BBox { _x0 :: a, _y0 :: a, _width :: a, _height :: a} deriving (Eq, Show) +import Graphics.Rendering.Plot.Light.Internal as Plot   
src/Graphics/Rendering/Plot/Light/Internal.hs view
@@ -1,5 +1,5 @@ {-# LANGUAGE OverloadedStrings #-}-module Graphics.Rendering.Plot.Light.Internal where+module Graphics.Rendering.Plot.Light.Internal (FigureData(..), Point(..), LabeledPoint(..), Axis(..), mkFigureData, figure, rectCentered, line, tick, ticks, axis, text, polyline, V2(..), Mat2, DiagMat2, diagMat2, AdditiveGroup(..), VectorSpace(..), Hermitian(..), LinearMap(..), MultiplicativeSemigroup(..), MatrixGroup(..), norm2, normalize2, mkV2fromEndpoints, v2fromPoint, origin, movePoint, moveLabeledPointV2, fromUnitSquare, toUnitSquare, e1, e2) where  import Data.Monoid ((<>)) import Control.Arrow ((&&&), (***))@@ -155,23 +155,10 @@    -- * Helpers ---- | Given a point `x` in a range [x1min, x1max], map it by affine transformation onto the interval [x2min, x2max]--- More precisely, first it maps `x` onto the unit interval and from this onto the interval of interest-affine :: Fractional t => t -> t -> t -> t -> t -> t-affine = withAffine id---- | Applies a function to the values in the unit interval-withAffine :: Fractional t => (t -> t) -> t -> t -> t -> t -> t -> t-withAffine f x2min x2max x1min x1max x = (f (x - x1min)/d1)*d2 + x2min where-  d1 = x1max - x1min-  d2 = x2max - x2min-  ----- Render a Colour from `colour` into a `blaze` Attribute+-- | Render a Colour from `colour` into a `blaze` Attribute colourAttr :: C.Colour Double -> S.AttributeValue colourAttr = S.toValue . C.sRGB24show +  -- ** Conversion from primitive numerical types to AttributeValue vi :: Int -> S.AttributeValue
src/Graphics/Rendering/Plot/Light/Internal/Geometry.hs view
@@ -85,16 +85,13 @@ instance Num a => LinearMap (Mat2 a) (V2 a) where   (Mat2 a00 a01 a10 a11) #> (V2 vx vy) = V2 (a00 * vx + a01 * vy) (a10 * vx + a11 * vy) --- | A diagonal matrix+-- | Create a diagonal matrix diagMat2 :: Num a => a -> a -> Mat2 a diagMat2 rx ry = Mat2 rx 0 0 ry  -- | Diagonal matrices in R2 behave as scaling transformations data DiagMat2 a = DMat2 a a deriving (Eq, Show) --- | Create a diagonal matrix-mkDMat2 :: a -> a -> DiagMat2 a-mkDMat2 = DMat2  -- | The class of invertible linear transformations class LinearMap m v => MatrixGroup m v where@@ -125,10 +122,11 @@ -- | The vector translation from a `Point` contained in a `Frame` onto the unit square -- -- NB: we do not check that `p` is actually contained within the frame. This has to be supplied correctly by the user-toUnitSquare :: Fractional a => Frame a -> Point a -> Point a+toUnitSquare :: (Fractional a, MatrixGroup (Mat2 a) (V2 a)) =>+    Frame a -> Point a -> Point a toUnitSquare from p = movePoint vmove p   where-    mm = mkDMat2 (width from) (height from)+    mm = diagMat2 (width from) (height from)     o1 = _fpmin from     vmove = mm <\> (p -. o1) @@ -138,7 +136,7 @@ fromUnitSquare :: Num a => Frame a -> Point a -> Point a fromUnitSquare to p = movePoint vmove p   where-    mm = mkDMat2 (width to) (height to)+    mm = diagMat2 (width to) (height to)     vo = v2fromPoint (_fpmin to)     vmove = (mm #> v2fromPoint p) ^+^ vo 
src/Graphics/Rendering/Plot/Light/Internal/Types.hs view
@@ -1,6 +1,5 @@ module Graphics.Rendering.Plot.Light.Internal.Types  where - data FigureData a =   FigData {     _width :: a