HaTeX-3.6.0.1: The Haskell LaTeX library.

Safe HaskellSafe-Inferred

Text.LaTeX.Packages.TikZ.Syntax

Contents

Description

This module defines the syntax of a TikZ script.

To generate a TikZ script, first create a TPath using data constructors, or alternatively, use a PathBuilder from the Text.LaTeX.Packages.TikZ.PathBuilder module.

Once a TPath is created, use path to render a picture from it. Use scope to apply some parameters to your picture, such line width or color.

Synopsis

Points

data TPoint Source

A point in TikZ.

Instances

relPoint :: TPoint -> TPointSource

Makes a point relative to the previous one.

Paths

Types

data TPath Source

Type for TikZ paths. Every TPath has two fundamental points: the starting point and the last point. The starting point is set using the Start constructor. The last point then is modified by the other constructors. Below a explanation of each one of them. Note that both starting point and last point may coincide. You can use the functions startingPoint and lastPoint to calculate them. After creating a TPath, use path to do something useful with it.

Constructors

Start TPoint

Let y = Start p.

Operation: Set the starting point of a path.

Last point: The last point of y is p.

Cycle TPath

Let y = Cycle x.

Operation: Close a path with a line from the last point of x to the starting point of x.

Last point: The last point of y is the starting point of x.

Line TPath TPoint

Let y = Line x p.

Operation: Extend the current path from the last point of x in a straight line to p.

Last point: The last point of y is p.

Rectangle TPath TPoint

Let y = Rectangle x p.

Operation: Define a rectangle using the last point of x as one corner and p as the another corner.

Last point: The last point of y is p.

Circle TPath Double

Let y = Circle x r.

Operation: Define a circle with center at the last point of x and radius r.

Last point: The last point of y is the same as the last point of x.

Ellipse TPath Double Double

Let y = Ellipse x r1 r2.

Operation: Define a ellipse with center at the last point of x, width the double of r1 and height the double of r2.

Last point: The last point of y is the same as the last point of x.

Grid TPath [GridOption] TPoint 

Instances

Critical points

startingPoint :: TPath -> TPointSource

Calculate the starting point of a TPath.

lastPoint :: TPath -> TPointSource

Calculate the last point of a TPath.

Functions

(->-) :: TPath -> TPoint -> TPathSource

Alias of Line.

Parameters

data Parameter Source

Parameters to use in a scope to change how things are rendered within that scope.

data Color Source

Basic colors.

Constructors

Red 
Green 
Blue 
Yellow 
Cyan 
Magenta 
Black 
White 

Instances

TikZ

data TikZ Source

A TikZ script.

Instances

emptytikz :: TikZSource

Just an empty script.

path :: [ActionType] -> TPath -> TikZSource

A path can be used in different ways.

  • Draw: Just draw the path.
  • Fill: Fill the area inside the path.
  • Clip: Clean everything outside the path.
  • Shade: Shade the area inside the path.

It is possible to stack different effects in the list.

Example of usage:

 path [Draw] $ Start (pointAtXY 0 0) ->- pointAtXY 1 1

Most common usages are exported as functions. See draw, fill, clip, shade, filldraw and shadedraw.

scope :: [Parameter] -> TikZ -> TikZSource

Applies a scope to a TikZ script.

data ActionType Source

Different types of actions that can be performed with a TPath. See path for more information.

Constructors

Draw 
Fill 
Clip 
Shade 

(->>) :: TikZ -> TikZ -> TikZSource

Sequence two TikZ scripts.

Sugar

draw :: TPath -> TikZSource

Equivalent to path [Draw].

fill :: TPath -> TikZSource

Equivalent to path [Fill].

clip :: TPath -> TikZSource

Equivalent to path [Clip].

shade :: TPath -> TikZSource

Equivalent to path [Shade].

filldraw :: TPath -> TikZSource

Equivalent to path [Fill,Draw].

shadedraw :: TPath -> TikZSource

Equivalent to path [Shade,Draw].