Rasterific-0.4: 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 Source

Type alias just to get more meaningful type signatures

strokize Source

Arguments

:: StrokeWidth

Stroke width

-> Join

Which kind of join will be used

-> (Cap, Cap)

Start and end capping.

-> [Primitive]

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)
      [CubicBezierPrim $
           CubicBezier (V2  40 160) (V2 40   40)
                       (V2 160  40) (V2 160 160)]

dashedStrokize Source

Arguments

:: 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.

-> [Primitive]

List of 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)

      [CubicBezierPrim $

           CubicBezier (V2  40 160) (V2 40   40)

                       (V2 160  40) (V2 160 160)]

approximatePathLength :: Path -> Float Source

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