diagrams-lib-0.5: Embedded domain-specific language for declarative graphics

Maintainer diagrams-discuss@googlegroups.com None

Diagrams.TwoD.Types

Contents

Description

Basic types for two-dimensional Euclidean space.

Synopsis

# 2D Euclidean space

data R2 Source

The two-dimensional Euclidean vector space R^2. This type is intentionally abstract.

• To construct a vector, use `r2`.
• To construct the vector from the origin to a point `p`, use `p .-. origin`.
• To convert a vector `v` into the point obtained by following `v` from the origin, use `origin .+^ v`.
• To convert a vector back into a pair of components, use `unv2`.

Instances

 Eq R2 Fractional R2 Num R2 Ord R2 Read R2 Show R2 Typeable R2 Transformable R2 HasBasis R2 VectorSpace R2 InnerSpace R2 AdditiveGroup R2 Newtype R2 (Double, Double) Renderable (Path R2) b => PathLike (QDiagram b R2 Any)

r2 :: (Double, Double) -> R2Source

Construct a 2D vector from a pair of components.

unr2 :: R2 -> (Double, Double)Source

Convert a 2D vector back into a pair of components.

type P2 = Point R2Source

Points in R^2. This type is intentionally abstract.

• To construct a point, use `p2`.
• To construct a point from a vector `v`, use `origin .+^ v`.
• To convert a point `p` into the vector from the origin to `p`, use `p .-. origin`.
• To convert a point back into a pair of coordinates, use `unp2`.

p2 :: (Double, Double) -> P2Source

Construct a 2D point from a pair of coordinates.

unp2 :: P2 -> (Double, Double)Source

Convert a 2D point back into a pair of coordinates.

Transformations in R^2.

# Angles

class Num a => Angle a whereSource

Type class for types that measure angles.

Methods

toCircleFrac :: a -> CircleFracSource

Convert to a fraction of a circle.

Convert from a fraction of a circle.

Instances

 Angle Deg 360 degrees = 1 full circle. Angle Rad tau radians = 1 full circle. Angle CircleFrac

newtype CircleFrac Source

Newtype wrapper used to represent angles as fractions of a circle. For example, 13 = tau3 radians = 120 degrees.

Constructors

 CircleFrac FieldsgetCircleFrac :: Double

newtype Rad Source

Newtype wrapper for representing angles in radians.

Constructors

 Rad FieldsgetRad :: Double

Instances

 Enum Rad Eq Rad Floating Rad Fractional Rad Num Rad Ord Rad Read Rad Real Rad RealFloat Rad RealFrac Rad Show Rad Angle Rad tau radians = 1 full circle.

newtype Deg Source

Newtype wrapper for representing angles in degrees.

Constructors

 Deg FieldsgetDeg :: Double

Instances

 Enum Deg Eq Deg Floating Deg Fractional Deg Num Deg Ord Deg Read Deg Real Deg RealFloat Deg RealFrac Deg Show Deg Angle Deg 360 degrees = 1 full circle.

fullCircle :: Angle a => aSource

An angle representing a full circle.

convertAngle :: (Angle a, Angle b) => a -> bSource

Convert between two angle representations.