Copyright | (c) 2014 diagrams-lib team (see LICENSE) |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | diagrams-discuss@googlegroups.com |
Safe Haskell | None |
Language | Haskell2010 |
Utilities for working with sizes of objects.
- data SizeSpec v n
- mkSizeSpec :: (Functor v, Num n) => v (Maybe n) -> SizeSpec v n
- dims :: v n -> SizeSpec v n
- absolute :: (Additive v, Num n) => SizeSpec v n
- getSpec :: (Functor v, Num n, Ord n) => SizeSpec v n -> v (Maybe n)
- specToSize :: (Foldable v, Functor v, Num n, Ord n) => n -> SizeSpec v n -> v n
- requiredScale :: (Additive v, Foldable v, Fractional n, Ord n) => SizeSpec v n -> v n -> n
- requiredScaling :: (Additive v, Foldable v, Fractional n, Ord n) => SizeSpec v n -> v n -> Transformation v n
- sized :: (InSpace v n a, HasLinearMap v, Transformable a, Enveloped a) => SizeSpec v n -> a -> a
- sizedAs :: (InSpace v n a, SameSpace a b, HasLinearMap v, Transformable a, Enveloped a, Enveloped b) => b -> a -> a
- sizeAdjustment :: (Additive v, Foldable v, OrderedField n) => SizeSpec v n -> BoundingBox v n -> (v n, Transformation v n)
Size spec
A SizeSpec
is a way of specifying a size without needed lengths for all
the dimensions.
Making size spec
mkSizeSpec :: (Functor v, Num n) => v (Maybe n) -> SizeSpec v n #
Make a SizeSpec
from a vector of maybe values. Any negative values will
be ignored. For 2D SizeSpec
s see mkWidth
and mkHeight
from
Diagrams.TwoD.Size.
Extracting size specs
getSpec :: (Functor v, Num n, Ord n) => SizeSpec v n -> v (Maybe n) #
Retrieve a size spec as a vector of maybe values. Only positive sizes are returned.
Functions on size specs
requiredScale :: (Additive v, Foldable v, Fractional n, Ord n) => SizeSpec v n -> v n -> n #
requiredScale spec sz
returns the largest scaling factor to make
something of size sz
fit the requested size spec
without changing the
aspect ratio. sz
should be non-zero (otherwise a scale of 1 is
returned). For non-uniform scaling see boxFit
.
requiredScaling :: (Additive v, Foldable v, Fractional n, Ord n) => SizeSpec v n -> v n -> Transformation v n #
Return the Transformation
calcuated from requiredScale
.
sized :: (InSpace v n a, HasLinearMap v, Transformable a, Enveloped a) => SizeSpec v n -> a -> a #
Uniformly scale any enveloped object so that it fits within the
given size. For non-uniform scaling see boxFit
.
sizedAs :: (InSpace v n a, SameSpace a b, HasLinearMap v, Transformable a, Enveloped a, Enveloped b) => b -> a -> a #
Uniformly scale an enveloped object so that it "has the same size as" (fits within the width and height of) some other object.
sizeAdjustment :: (Additive v, Foldable v, OrderedField n) => SizeSpec v n -> BoundingBox v n -> (v n, Transformation v n) #
Get the adjustment to fit a BoundingBox
in the given SizeSpec
. The
vector is the new size and the transformation to position the lower
corner at the origin and scale to the size spec.