Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
A simple interface to create TikZ graphics. Just build pictures using
the Figure
data constructors, and get the TikZ script using the function
figuretikz
. Use the function tikzpicture
to insert the TikZ script in
the LaTeX document. And do not forget to import the tikz
package in the
preamble.
Please, note that this module is not intended to be imported in the same module than Text.LaTeX.Packages.TikZ. This module is itself a self-contained alternative of that module. If you still want to use both modules, please, use qualified imports to avoid name clashes.
In the Examples directory of the source distribution, the file tikzsimple.hs
contains a complete example of usage of this module with several pictures.
Below you can see a picture along with the code it came from.
myFigure :: Figure myFigure = Scale 2 $ Figures [ RectangleFilled (0,0) 1 1 , Colored (BasicColor Green) $ RectangleFilled (-1,1) 1 1 , Colored (BasicColor Red) $ RectangleFilled ( 0,2) 1 1 , Colored (BasicColor Blue) $ RectangleFilled ( 1,1) 1 1 ]
Synopsis
- tikz :: PackageName
- data Figure
- = Line [Point]
- | Polygon [Point]
- | PolygonFilled [Point]
- | Rectangle Point Double Double
- | RectangleFilled Point Double Double
- | Circle Point Double
- | CircleFilled Point Double
- | Ellipse Point Double Double
- | EllipseFilled Point Double Double
- | Text Point LaTeX
- | Colored TikZColor Figure
- | LineWidth Measure Figure
- | Scale Double Figure
- | Rotate Double Figure
- | Figures [Figure]
- type Point = (Double, Double)
- data TikZColor
- data Color
- data Word8
- pathImage :: Double -> (Double, Double) -> (Double -> Point) -> Figure
- figuretikz :: Figure -> TikZ
- (->>) :: TikZ -> TikZ -> TikZ
- tikzpicture :: LaTeXC l => TikZ -> l
Documentation
tikz :: PackageName Source #
Import the tikz
package to use the functions exported
by this module. For example, adding this line to your
document preamble:
usepackage [] tikz
Figures
A figure in the plane.
Line [Point] | Line along a list of points. |
Polygon [Point] | Line along a list of points, but the last point will be joined with the first one. |
PolygonFilled [Point] | Same as |
Rectangle Point Double Double | Rectangle with top-right corner at the given point and width and height given by the other parameters. |
RectangleFilled Point Double Double | Same as |
Circle Point Double | Circle centered at the given point with the given radius. |
CircleFilled Point Double | As in |
Ellipse Point Double Double | Ellipse centered at the given point with width and height given by the other parameters. |
EllipseFilled Point Double Double | Same as |
Text Point LaTeX | Insert some |
Colored TikZColor Figure | Color for the given |
LineWidth Measure Figure | Line width for the given |
Scale Double Figure | Scaling of the given |
Rotate Double Figure | Rotate a |
Figures [Figure] | A figure composed by a list of figures. |
Basic colors.
8-bit unsigned integer type
Instances
Render Word8 Source # | |
Arbitrary Word8 | |
CoArbitrary Word8 | |
Defined in Test.QuickCheck.Arbitrary coarbitrary :: Word8 -> Gen b -> Gen b # | |
Function Word8 | |
Data Word8 | Since: base-4.0.0.0 |
Defined in Data.Data gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Word8 -> c Word8 # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Word8 # dataTypeOf :: Word8 -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Word8) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Word8) # gmapT :: (forall b. Data b => b -> b) -> Word8 -> Word8 # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Word8 -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Word8 -> r # gmapQ :: (forall d. Data d => d -> u) -> Word8 -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Word8 -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Word8 -> m Word8 # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Word8 -> m Word8 # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Word8 -> m Word8 # | |
Bits Word8 | Since: base-2.1 |
Defined in GHC.Word (.&.) :: Word8 -> Word8 -> Word8 # (.|.) :: Word8 -> Word8 -> Word8 # xor :: Word8 -> Word8 -> Word8 # complement :: Word8 -> Word8 # shift :: Word8 -> Int -> Word8 # rotate :: Word8 -> Int -> Word8 # setBit :: Word8 -> Int -> Word8 # clearBit :: Word8 -> Int -> Word8 # complementBit :: Word8 -> Int -> Word8 # testBit :: Word8 -> Int -> Bool # bitSizeMaybe :: Word8 -> Maybe Int # shiftL :: Word8 -> Int -> Word8 # unsafeShiftL :: Word8 -> Int -> Word8 # shiftR :: Word8 -> Int -> Word8 # unsafeShiftR :: Word8 -> Int -> Word8 # rotateL :: Word8 -> Int -> Word8 # | |
FiniteBits Word8 | Since: base-4.6.0.0 |
Defined in GHC.Word finiteBitSize :: Word8 -> Int # countLeadingZeros :: Word8 -> Int # countTrailingZeros :: Word8 -> Int # | |
Bounded Word8 | Since: base-2.1 |
Enum Word8 | Since: base-2.1 |
Ix Word8 | Since: base-2.1 |
Num Word8 | Since: base-2.1 |
Read Word8 | Since: base-2.1 |
Integral Word8 | Since: base-2.1 |
Real Word8 | Since: base-2.1 |
Defined in GHC.Word toRational :: Word8 -> Rational # | |
Show Word8 | Since: base-2.1 |
NFData Word8 | |
Defined in Control.DeepSeq | |
Eq Word8 | Since: base-2.1 |
Ord Word8 | Since: base-2.1 |
Hashable Word8 | |
Defined in Data.Hashable.Class | |
Pretty Word8 | |
Defined in Prettyprinter.Internal | |
Random Word8 | |
Uniform Word8 | |
Defined in System.Random.Internal uniformM :: StatefulGen g m => g -> m Word8 # | |
UniformRange Word8 | |
Defined in System.Random.Internal | |
Lift Word8 | |
Additional functions
:: Double | Precision argument, ε. |
-> (Double, Double) | Interval, (a,b). |
-> (Double -> Point) | Path function, f. |
-> Figure | Output figure. |
The figure of a path. A path (in this context) means a function from an interval to
the plane. The image of such a function is what this function returns as a Figure
.
An additional argument is needed to set the precision of the curve.
The actual implementation builds a spline of degree one joining different points of the image. Given that the interval is (a,b) and the precision argument is ε, the points in the spline will be f(a), f(a+ε), f(a+2ε), and so on, until reaching f(b). The smaller is ε, the closer is the figure to the original image.
Here is an example with a logarithmic spiral.
spiral :: Figure spiral = LineWidth (Pt 2) $ pathImage 0.01 (0,4) $ \t -> ( a * exp t * cos (b*t) , a * exp t * sin (b*t) ) where a = 0.1 ; b = 4