Rasterific-0.6.1: A pure haskell drawing engine.

Safe HaskellNone
LanguageHaskell2010

Graphics.Rasterific.Outline

Description

This module provide helper functions to create outline of shapes.

Synopsis

Documentation

type StrokeWidth = Float

Type alias just to get more meaningful type signatures

strokize

Arguments

:: Geometry geom 
=> StrokeWidth

Stroke width

-> Join

Which kind of join will be used

-> (Cap, Cap)

Start and end capping.

-> geom

List of elements to strokize

-> [Primitive] 

This function will create the outline of a given geometry given a path. You can then stroke it.

stroke 3 (JoinMiter 0) (CapStraight 0, CapStraight 0) $
    strokize 40 JoinRound (CapRound, CapRound) $
        CubicBezier (V2  40 160) (V2 40   40)
                    (V2 160  40) (V2 160 160)

dashedStrokize

Arguments

:: Geometry geom 
=> Float

Starting offset

-> DashPattern

Dashing pattern to use for stroking

-> StrokeWidth

Stroke width

-> Join

Which kind of join will be used

-> (Cap, Cap)

Start and end capping.

-> geom

Elements to transform

-> [[Primitive]] 

Create a list of outlines corresponding to all the dashed elements. They can be then stroked

mapM_ (stroke 3 (JoinMiter 0) (CapStraight 0, CapStraight 0)) $
    dashedStrokize 0 [10, 5]
                   40 JoinRound (CapStraight 0, CapStraight 0) $
        CubicBezier (V2  40 160) (V2 40   40) (V2 160  40) (V2 160 160)

approximatePathLength :: Path -> Float

Return an approximation of the length of a given path. It's results is not precise but should be enough for rough calculations