-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A lightweight plotting library, exporting to SVG -- -- A lightweight plotting library, exporting to SVG @package plot-light @version 0.1.0.9 -- | `plot-light` provides functionality for rendering vector graphics in -- SVG format. It is geared in particular towards scientific plotting, -- and it is termed "light" because it only requires a few common Haskell -- dependencies and no external libraries. -- --

Usage

-- -- To use this project you just need import -- Graphics.Rendering.Plot.Light. If GHC complains of name clashes -- you can import the module in "qualified" form. -- -- If you wish to try out the examples in this page, you will need to -- have these additional import statements: -- --
--   import Text.Blaze.Svg.Renderer.String (renderSvg)
--   
-- --
--   import qualified Data.Colour.Names as C
--   
module Graphics.Rendering.Plot.Light -- | A rectangle, defined by its center coordinates and side lengths -- --
--   > putStrLn $ renderSvg $ rectCentered (Point 20 30) 15 30 (Just C.blue) (Just C.red)
--   <g transform="translate(12.5 15.0)"><rect width="15.0" height="30.0" fill="#ff0000" stroke="#0000ff" /></g>
--   
rectCentered :: (Show a, RealFrac a) => Point a -> a -> a -> Maybe (Colour Double) -> Maybe (Colour Double) -> Svg -- | A circle -- --
--   > putStrLn $ renderSvg $ circle (Point 20 30) 15 (Just C.blue) (Just C.red)
--   <circle cx="20.0" cy="30.0" r="15.0" fill="#ff0000" stroke="#0000ff" />
--   
circle :: (Real a1, Real a) => Point a1 -> a -> Maybe (Colour Double) -> Maybe (Colour Double) -> Svg -- | Line segment between two Points -- --
--   > putStrLn $ renderSvg $ line (Point 0 0) (Point 1 1) 0.1 Continuous C.blueviolet
--   <line x1="0.0" y1="0.0" x2="1.0" y2="1.0" stroke="#8a2be2" stroke-width="0.1" />
--   
-- --
--   > putStrLn $ renderSvg (line (Point 0 0) (Point 1 1) 0.1 (Dashed [0.2, 0.3]) C.blueviolet)
--   <line x1="0.0" y1="0.0" x2="1.0" y2="1.0" stroke="#8a2be2" stroke-width="0.1" stroke-dasharray="0.2, 0.3" />
--   
line :: (Show a, RealFrac a) => Point a -> Point a -> a -> LineStroke_ a -> Colour Double -> Svg -- | A plot axis with labeled tickmarks -- --
--   > putStrLn $ renderSvg $ axis (Point 0 50) X 200 2 C.red 0.05 Continuous 15 (-45) TAEnd T.pack (V2 (-10) 0) [LabeledPoint (Point 50 1) "bla", LabeledPoint (Point 60 1) "asdf"]
--   <line x1="0.0" y1="50.0" x2="200.0" y2="50.0" stroke="#ff0000" stroke-width="2.0" /><line x1="50.0" y1="45.0" x2="50.0" y2="55.0" stroke="#ff0000" stroke-width="2.0" /><text x="-10.0" y="0.0" transform="translate(50.0 50.0)rotate(-45.0)" font-size="15" fill="#ff0000" text-anchor="end">bla</text><line x1="60.0" y1="45.0" x2="60.0" y2="55.0" stroke="#ff0000" stroke-width="2.0" /><text x="-10.0" y="0.0" transform="translate(60.0 50.0)rotate(-45.0)" font-size="15" fill="#ff0000" text-anchor="end">asdf</text>
--   
axis :: (Functor t, Foldable t, Show a, RealFrac a) => Point a -> Axis -> a -> a -> Colour Double -> a -> LineStroke_ a -> Int -> a -> TextAnchor_ -> (l -> Text) -> V2 a -> t (LabeledPoint l a) -> Svg -- | text renders text onto the SVG canvas -- --

Conventions

-- -- The Point argument p refers to the lower-left -- corner of the text box. -- -- The text box can be rotated by rot degrees around p -- and then anchored at either its beginning, middle or end to p -- with the TextAnchor_ flag. -- -- The user can supply an additional V2 displacement which will be -- applied after rotation and anchoring and refers to the rotated -- text box frame. -- --
--   > putStrLn $ renderSvg $ text (-45) C.green TAEnd "blah" (V2 (- 10) 0) (Point 250 0)
--   <text x="-10.0" y="0.0" transform="translate(250.0 0.0)rotate(-45.0)" fill="#008000" text-anchor="end">blah</text>
--   
text :: (Show a, Real a) => a -> Int -> Colour Double -> TextAnchor_ -> Text -> V2 a -> Point a -> Svg -- | Polyline (piecewise straight line) -- --
--   > putStrLn $ renderSvg (polyline [Point 100 50, Point 120 20, Point 230 50] 4 (Dashed [3, 5]) Round C.blueviolet)
--   <polyline points="100.0,50.0 120.0,20.0 230.0,50.0" fill="none" stroke="#8a2be2" stroke-width="4.0" stroke-linejoin="round" stroke-dasharray="3.0, 5.0" />
--   
polyline :: (Foldable t, Show a1, Show a, RealFrac a, RealFrac a1) => t (Point a) -> a1 -> LineStroke_ a -> StrokeLineJoin_ -> Colour Double -> Svg -- | Specify a continuous or dashed stroke data LineStroke_ a Continuous :: LineStroke_ a Dashed :: [a] -> LineStroke_ a -- | Specify the type of connection between line segments data StrokeLineJoin_ Miter :: StrokeLineJoin_ Round :: StrokeLineJoin_ Bevel :: StrokeLineJoin_ Inherit :: StrokeLineJoin_ -- | Specify at which end should the text be anchored to its current point data TextAnchor_ TAStart :: TextAnchor_ TAMiddle :: TextAnchor_ TAEnd :: TextAnchor_ -- | Create the SVG header from a Frame svgHeader :: Real a => Frame a -> Svg -> Svg -- | A frame, i.e. a bounding box for objects data Frame a Frame :: Point a -> Point a -> Frame a [_fpmin] :: Frame a -> Point a [_fpmax] :: Frame a -> Point a -- | A Point defines a point in R2 data Point a Point :: a -> a -> Point a [_px] :: Point a -> a [_py] :: Point a -> a -- | A LabeledPoint carries a "label" (i.e. any additional -- information such as a text tag, or any other data structure), in -- addition to position information. Data points on a plot are -- LabeledPoints. data LabeledPoint l a LabeledPoint :: Point a -> l -> LabeledPoint l a [_lp] :: LabeledPoint l a -> Point a [_lplabel] :: LabeledPoint l a -> l data Axis X :: Axis Y :: Axis -- | V2 is a vector in R^2 data V2 a V2 :: a -> a -> V2 a -- | A Mat2 can be seen as a linear operator that acts on points in the -- plane data Mat2 a Mat2 :: a -> a -> a -> a -> Mat2 a -- | Diagonal matrices in R2 behave as scaling transformations data DiagMat2 a DMat2 :: a -> a -> DiagMat2 a -- | Create a diagonal matrix diagMat2 :: Num a => a -> a -> DiagMat2 a -- | The origin of the axes, point (0, 0) origin :: Num a => Point a -- | X-aligned unit vector e1 :: Num a => V2 a -- | Y-aligned unit vector e2 :: Num a => V2 a -- | Euclidean (L^2) norm norm2 :: (Hermitian v, Floating n, n ~ (InnerProduct v)) => v -> n -- | Normalize a V2 w.r.t. its Euclidean norm normalize2 :: (InnerProduct v ~ Scalar v, Floating (Scalar v), Hermitian v) => v -> v -- | Create a V2 v from two endpoints p1, p2. That is v -- can be seen as pointing from p1 to p2 v2fromEndpoints :: Num a => Point a -> Point a -> V2 a -- | Build a V2 from a Point p (i.e. assuming the V2 points from the -- origin (0,0) to p) v2fromPoint :: Num a => Point a -> V2 a -- | Move a point along a vector movePoint :: Num a => V2 a -> Point a -> Point a -- | Move a LabeledPoint along a vector moveLabeledPointV2 :: Num a => V2 a -> LabeledPoint l a -> LabeledPoint l a -- | Create a V2 v from two endpoints p1, p2. That is v -- can be seen as pointing from p1 to p2 (-.) :: Num a => Point a -> Point a -> V2 a -- | Given two frames F1 and F2, returns a function -- f that maps an arbitrary vector v that points within -- F1 to one contained within F2. -- --
    --
  1. map v into a unit square vector v01 with an -- affine transformation
  2. --
  3. (optional) map v01 into another point in the unit square -- via a linear rescaling
  4. --
  5. map v01' onto F2 with a second affine -- transformation
  6. --
-- -- NB: we do not check that v is actually contained within the -- F1. This has to be supplied correctly by the user. frameToFrame :: (Fractional a, LinearMap m (V2 a)) => Frame a -> Frame a -> m -> V2 a -> V2 a -> V2 a -- | Additive group : -- --
--   v ^+^ zero == zero ^+^ v == v
--   
-- --
--   v ^-^ v == zero
--   
class AdditiveGroup v -- | Identity element zero :: AdditiveGroup v => v -- | Group action ("sum") (^+^) :: AdditiveGroup v => v -> v -> v -- | Inverse group action ("subtraction") (^-^) :: AdditiveGroup v => v -> v -> v -- | Vector space : multiplication by a scalar quantity class AdditiveGroup v => VectorSpace v where type Scalar v :: * where { type family Scalar v :: *; } -- | Scalar multiplication (.*) :: VectorSpace v => Scalar v -> v -> v -- | Hermitian space : inner product class VectorSpace v => Hermitian v where type InnerProduct v :: * where { type family InnerProduct v :: *; } -- | Inner product (<.>) :: Hermitian v => v -> v -> InnerProduct v -- | Linear maps, i.e. linear transformations of vectors class Hermitian v => LinearMap m v -- | Matrix action, i.e. linear transformation of a vector (#>) :: LinearMap m v => m -> v -> v -- | Multiplicative matrix semigroup ("multiplying" two matrices together) class MultiplicativeSemigroup m -- | Matrix product (##) :: MultiplicativeSemigroup m => m -> m -> m -- | The class of invertible linear transformations class LinearMap m v => MatrixGroup m v -- | Inverse matrix action on a vector (<\>) :: MatrixGroup m v => m -> v -> v -- | Numerical equality class Eps a -- | Comparison within numerical precision (~=) :: Eps a => a -> a -> Bool