Portability | GHC |
---|---|
Stability | highly unstable |
Maintainer | Stephen Tetley <stephen.tetley@gmail.com> |
Safe Haskell | Safe-Infered |
Customize drawing attributes. The functions here are
DrawingContext
modifiers to be run within a the scope of a
localize
block (cf. local
of the Reader monad).
By convention, underscore-separated names are used for DrawingContext modifiers in this module. This is because the modifiers defined here are expected to be used mostly as static "properties" resembling constants in drawings.
- snap_grid_factors :: Double -> Double -> DrawingContextF
- set_line_width :: Double -> DrawingContextF
- line_default :: DrawingContextF
- line_thin :: DrawingContextF
- line_thick :: DrawingContextF
- line_ultra_thick :: DrawingContextF
- contextual_line_width :: (FontSize -> Double) -> DrawingContextF
- relative_line_width :: (Double -> Double) -> DrawingContextF
- cap_default :: DrawingContextF
- cap_butt :: DrawingContextF
- cap_round :: DrawingContextF
- cap_square :: DrawingContextF
- join_default :: DrawingContextF
- join_miter :: DrawingContextF
- join_round :: DrawingContextF
- join_bevel :: DrawingContextF
- set_dash_pattern :: DashPattern -> DrawingContextF
- solid_line :: DrawingContextF
- dotted_line :: DrawingContextF
- packed_dotted :: DrawingContextF
- loose_dotted :: DrawingContextF
- dashed_line :: DrawingContextF
- packed_dashed :: DrawingContextF
- loose_dashed :: DrawingContextF
- font_attr :: FontDef -> Int -> DrawingContextF
- set_font :: FontDef -> DrawingContextF
- set_font_size :: Int -> DrawingContextF
- scale_point_size :: Double -> DrawingContextF
- double_point_size :: DrawingContextF
- half_point_size :: DrawingContextF
- text_margin :: Em -> Em -> DrawingContextF
- text_margin_none :: DrawingContextF
- text_margin_tight :: DrawingContextF
- text_margin_default :: DrawingContextF
- text_margin_loose :: DrawingContextF
- stroke_colour :: RGBi -> DrawingContextF
- fill_colour :: RGBi -> DrawingContextF
- text_colour :: RGBi -> DrawingContextF
- single_colour :: RGBi -> DrawingContextF
- swap_colours :: DrawingContextF
- fill_use_stroke_colour :: DrawingContextF
- stroke_use_fill_colour :: DrawingContextF
- fill_use_text_colour :: DrawingContextF
- stroke_use_text_colour :: DrawingContextF
- text_use_stroke_colour :: DrawingContextF
- text_use_fill_colour :: DrawingContextF
Globals
snap_grid_factors :: Double -> Double -> DrawingContextFSource
snap_grid_factors
: x_unit * y_unit -> DrawingContextF
Set the snap grid factors
- a snap grid is an alternative
coordinate space, it can be convenient for drawing
"box and arrow" diagrams.
Line widths
set_line_width :: Double -> DrawingContextFSource
set_line_width : width_in_points -> DrawingContextF
Set the line_width to the supplied point size.
Initially the line width is 1.0.
Constant variations of the function maybe be more convenient:
line_default, line_thin, line_thick, line_ultra_thick
line_default :: DrawingContextFSource
Set the line_width to default
- 1.0.
line_thin :: DrawingContextFSource
Set the line_width to thin
- 0.5.
line_thick :: DrawingContextFSource
Set the line_width to thick
- 2.0.
line_ultra_thick :: DrawingContextFSource
Set the line_width to ultra_thick
- 4.0.
contextual_line_width :: (FontSize -> Double) -> DrawingContextFSource
Set the line width to a size relative to the current font size. The size is calculated with the supplied function.
relative_line_width :: (Double -> Double) -> DrawingContextFSource
Scale the line width respective to its current value.
The size is calculated with the supplied function.
Line cap
cap_default :: DrawingContextFSource
Set the line_cap to the default which is butt
.
This is a synonym for cap_butt
.
cap_butt :: DrawingContextFSource
Set the line_cap to butt
.
Butt chamfers off the stroke, flush to the end point.
This is the default.
.-------. |=======| '-------'
cap_round :: DrawingContextFSource
Set the line_cap to round
.
This rounds the end of the stroke and the visually the rounding slightly extends the length of the line.
.-------. ( ======= ) '-------'
cap_square :: DrawingContextFSource
Set the line_cap to square
.
This squares off the end of the stroke, but visual extends the stroke by half the line width.
.---------. | ======= | '---------'
Line join
join_default :: DrawingContextFSource
Set the line_join to the default which is miter
.
This is a synonym for join_miter
.
join_miter :: DrawingContextFSource
Set the line_join to miter
.
This extends the joining line segments to form a sharp miter.
This is the default.
/\ /..\ /./\.\ /./ \.\ /./ \.\
join_round :: DrawingContextFSource
Set the line_join to round
.
This rounds off the corner of the joined line segments.
\.\ \.\ ,.) /./ /./
join_bevel :: DrawingContextFSource
Set the line_join to round
.
This bevels off the corner of the joined line segments with a notch.
__ /..\ /./\.\ /./ \.\ /./ \.\
Dash pattern
set_dash_pattern :: DashPattern -> DrawingContextFSource
Set the dash pattern.
Initially the dash pattern is Solid
.
solid_line :: DrawingContextFSource
Set the dash_pattern to solid
- i.e. no dash pattern.
This is the default.
dotted_line :: DrawingContextFSource
Set the dash pattern to draw a dotted line.
A dot is actually a square - side length is equal to the line width.
The spacing between dots is 2 times the dot width.
packed_dotted :: DrawingContextFSource
Set the dash pattern to draw a tightly packed dotted line.
A dot is actually a square - side length is equal to the line width.
The spacing between dots is equal to the dot width.
loose_dotted :: DrawingContextFSource
Set the dash pattern to draw a loosely dotted line.
A dot is actually a square - side length is equal to the line width.
The spacing between dots is 4 times the dot width.
dashed_line :: DrawingContextFSource
Set the dash pattern to draw a dashed line.
The dash length is 3 times the line width, the spacing is 2 times the line width.
packed_dashed :: DrawingContextFSource
Set the dash pattern to draw a tightly packed, dashed line.
The dash length is 3 times the line width, the spacing is equal to the line width.
loose_dashed :: DrawingContextFSource
Set the dash pattern to draw a loosely dashed line.
The dash length is 3 times the line width, the spacing is 4 times the line width.
Font properties
font_attr :: FontDef -> Int -> DrawingContextFSource
Set the font attributes, point size and font face.
set_font :: FontDef -> DrawingContextFSource
Set the font face.
set_font_size :: Int -> DrawingContextFSource
Set the point size.
This controls the drawing size of both text labels and marks (e.g. dots and arrowheads).
scale_point_size :: Double -> DrawingContextFSource
Scale the current point size by the supplied ratio.
Note - as fonts can only be drawn at integral sizes this operation is not exact - for instance scaling 15pt by (1%2) results in 7pt.
double_point_size :: DrawingContextFSource
Set the point size (font and mark size) to double the current size.
half_point_size :: DrawingContextFSource
Set the point size to half the current size, note the point size also controls the size of dots, arrowsheads etc.
Note - as fonts can only be drawn at integral sizes this operation is not exact - half size of 15pt type is 7pt.
Text margins
text_margin :: Em -> Em -> DrawingContextFSource
text_margin
: x_sep * y_sep -> DrawingContextF
Note - this is in Em
units.
text_margin_none :: DrawingContextFSource
Set the text margin to (0,0).
This produces a tight box around the text vertically measured to the cap-height and descender. Therefore some characters may extend outside the margin (e.g. accented capitals like A-grave).
text_margin_tight :: DrawingContextFSource
Set the text margin to (0.25 em, 0.25 em).
text_margin_default :: DrawingContextFSource
Set the text margin to (0.5 em, 0.5 em).
text_margin_loose :: DrawingContextFSource
Set the text margin to (1.0 em, 1.0 em).
Colour
stroke_colour :: RGBi -> DrawingContextFSource
Set the stroke colour.
fill_colour :: RGBi -> DrawingContextFSource
Set the fill colour.
text_colour :: RGBi -> DrawingContextFSource
Set the text colour.
single_colour :: RGBi -> DrawingContextFSource
Set the stroke, fill and text colours to a single colour.
swap_colours :: DrawingContextFSource
Swap the stroke colour and fill colours.
fill_use_stroke_colour :: DrawingContextFSource
Set the fill colour to use the current stroke colour.
stroke_use_fill_colour :: DrawingContextFSource
Set the stroke colour to use the current fill colour.
fill_use_text_colour :: DrawingContextFSource
Set the fill colour to use the current text colour.
stroke_use_text_colour :: DrawingContextFSource
Set the stroke colour to use the current fill colour.
text_use_stroke_colour :: DrawingContextFSource
Set the text colour to use the current stroke colour.
text_use_fill_colour :: DrawingContextFSource
Set the text colour to use the current fill colour.