- module Graphics.Curves.Math
- module Graphics.Curves.Colour
- data Image
- point :: Point -> Image
- line :: Point -> Point -> Image
- lineStrip :: [Point] -> Image
- poly :: [Point] -> Image
- circle :: Point -> Scalar -> Image
- circleSegment :: Point -> Scalar -> Scalar -> Scalar -> Image
- curve :: Scalar -> Scalar -> (Scalar -> Point) -> Image
- curve_ :: (Scalar -> Point) -> Image
- curve' :: Transformable a => Scalar -> Scalar -> (Scalar -> a) -> (Scalar -> a -> Point) -> Image
- bSpline :: [Point] -> Image
- bSpline' :: [Point] -> Image
- closedBSpline :: [Point] -> Image
- bezier :: [Point] -> Image
- bezierSegment :: [Point] -> Image
- reverseImage :: Image -> Image
- (+++) :: Image -> Image -> Image
- (+.+) :: Image -> Image -> Image
- (<++) :: Point -> Image -> Image
- (++>) :: Image -> Point -> Image
- differentiate :: Image -> Image
- mapImage :: (Scalar -> Point -> Point) -> Image -> Image
- zipImage :: (Scalar -> Point -> Point -> Point) -> Image -> Image -> Image
- transformImage :: (forall a. Transformable a => Scalar -> a -> a) -> Image -> Image
- curveLength :: Scalar -> Image -> Scalar
- freezeImageSize :: Point -> Image -> Image
- freezeImageOrientation :: Point -> Image -> Image
- freezeImage :: Point -> Image -> Image
- freezeImageStyle :: Image -> Image
- unfreezeImage :: Image -> Image
- type BlendFunc = Maybe Colour -> Maybe Colour -> Maybe Colour
- combine :: BlendFunc -> Image -> Image -> Image
- mapColour :: (Colour -> Colour) -> Image -> Image
- unionBlend :: BlendFunc
- intersectBlend :: BlendFunc
- diffBlend :: BlendFunc
- (<>) :: Monoid m => m -> m -> m
- (><) :: Image -> Image -> Image
- (<->) :: Image -> Image -> Image
- imageBounds :: Image -> Segment
- sampleImage :: Image -> Scalar -> [[Point]]
- module Graphics.Curves.Attribute
- module Graphics.Curves.Style
- autoFit :: Point -> Point -> Image -> Image
- autoStretch :: Point -> Point -> Image -> Image
- renderImage :: FilePath -> Int -> Int -> Colour -> Image -> IO ()
- version :: String
The image type.
A connected sequence of straight lines. The list must have at least two elements.
A circle segment. The third and fourth arguments are the start and end
angle of the segment. If the start angle is bigger than the end angle it's
the clockwise segment, otherwise the counterclockwise segment. For instance,
circleSegment 0 1 0 pi is the top half circle starting in
circleSegment 0 1 0 (-pi) is the bottow
half circle with the same start and end points.
A simple curve whose points are given by the function argument. The first two arguments specify the range of the function. The function must be continuous on this interval.
For example, a straight line between points
q can be implemented as
curve 0 1 (
The most general form of curve. The curve function is split in two, one
function from the parameter to an arbitrary
Transformable object, and a
second function from this object (and the parameter value) to a point on
the curve. The power of this combinator comes from the fact that
rotate) of the curve apply
only to the (result of the) first function. This means that the points
computed by the second function are measured in pixels of the final image.
For an example, see the
which uses a line
Segment as the intermediate type and computes the
arrow head in the second function, to ensure that the arrow head has the
same dimensions regardless of how the arrow is scaled.
A B-spline which starts in the first control point and ends in the last control point. This is achieved by adding two extra copies of the first and last points.
A closed B-spline.
closedBSpline ps = bSpline (ps ++ take 3 ps)
A Bézier curve of degree n with the given control points
[p0 .. pn].
Operating on curves
Reverse the direction of all curves in an image. Useful in conjunction
Join the right-most curve of the first image to the left-most curve of the
second image. The
Style is inherited from the
curve of the first image. If the end point of the first curve does not
coincide with the starting point of the second curve a straight line is
added to connect the two. This combinator is useful when using
parameterized line styles (such as
Apply a function to all points of an image. The function also gets the
curve parameter (between 0 and 1) of the given point. This applies after
all transformations so the points are measured in pixels, unless the image
is later unfrozen with
Apply a transformation to an image. Unlike
mapImage the transformation
is applied immediately.
Compute the length of the curves of an image by approximating it by a series of straight-line segments, each no longer than specified by the first argument.
Advanced image manipulation
Freeze the size of an image around the given point. Scaling the image will only affect the position of the image, not the size. Translation and rotation affect the image normally.
Scaling with non-uniform scale factors will still distort the image, however.
Freeze image orientation. Rotations of the image will only affect the position of the image, not its orientation. Translation and scaling affect the image normally.
rotateAroundp a (freezeImageOrientation p i) == freezeImageOrientation p i
Freeze the line style of an image. This means that the pixel parameters (distance along the curve and pixel position) are given as they are at this moment, and won't be affected by later transformations.
Unfreeze an image. After unfreezing any frozen features will be affected by transformations again.
A blend function is used to compute the resulting colour when
Combine two images using the specified blend function.
The alpha value of the result is the product of the alpha values of the two inputs.
Multiplies the alpha value of the first colour by 1 - the alpha value of the second colour.
Subtract the second image from the first.
(<->) = combine diffBlend
Compute the bounds of an image, returning a line segment from the bottom
left corner to the top right corner of the bounding box. This function
ignores line widths. Note that using pixel based features (for instance,
freezeImageSize) means that the bounds may become invalid if
the image is scaled.
Image attributes control things like the colour and width of curves.
Scale the an image to fit inside the the box given by the two points (bottom-left and top-right corners).
Scale the an image to fit inside the the box given by the two points (bottom-left and top-right corners). Does not preserve aspect ratio.
File in which to store the image
Image to render
|-> IO ()|
Render an image as a PNG file with a 1-bit alpha channel. Semi-transparent pixels in the image are blended with the given background colour to produce opaque pixels.