Portability | GHC |
---|---|
Stability | highly unstable |
Maintainer | Stephen Tetley <stephen.tetley@gmail.com> |
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
- 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
- source_space :: (Ord u, InterpretUnit u) => u -> DrawingContextF
- dest_space :: (Ord u, InterpretUnit u) => u -> DrawingContextF
- source_offset :: (Ord u, InterpretUnit u) => u -> DrawingContextF
- dest_offset :: (Ord u, InterpretUnit u) => u -> DrawingContextF
- uniform_conn_space :: (Ord u, InterpretUnit u) => u -> DrawingContextF
- conn_arc_angle :: Radian -> DrawingContextF
- source_arm_len :: InterpretUnit u => u -> DrawingContextF
- dest_arm_len :: InterpretUnit u => u -> DrawingContextF
- uniform_arm_len :: InterpretUnit u => u -> DrawingContextF
- conn_loop_size :: InterpretUnit u => u -> DrawingContextF
- conn_box_halfsize :: InterpretUnit u => u -> DrawingContextF
Modifiers
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.
Line caps
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 squares of the stroke at 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, visually extending the stroke by half the line width.
Line joins
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).
Font / mark drawing size
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_margin :: Em -> Em -> DrawingContextFSource
text_margin
: x_sep * y_sep -> DrawingContextF
NOTE - ideally this would use Em or En rather thn Double...
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.
Connector Props
source_space :: (Ord u, InterpretUnit u) => u -> DrawingContextFSource
Set the connector source spacing.
The spacing is used as a projection along the line formed between connector points making the connection looser if required.
The default value is 0. Negative values are not allowed, they are normalized to 0.
dest_space :: (Ord u, InterpretUnit u) => u -> DrawingContextFSource
Set the connector destination spacing.
The spacing is used as a projection along the line formed between connector points making the connection looser if required.
The default value is 0. Negative values are not allowed, they are normalized to 0.
source_offset :: (Ord u, InterpretUnit u) => u -> DrawingContextFSource
Set the connector source offset.
The offset is used to shift the start point upwards perpendicular to its true origin (negative values are downwards). This can be used to draw a connector with two parallel lines, for example.
Upwards and downwards in this description are dependent on the direction of the line, of course. Generally the documentations consider lines are left-to-right unless specifically noted.
dest_offset :: (Ord u, InterpretUnit u) => u -> DrawingContextFSource
Set the connector destination offset.
See source_offset
for an explanation.
uniform_conn_space :: (Ord u, InterpretUnit u) => u -> DrawingContextFSource
Set the connector source and destination spacings to the same length.
conn_arc_angle :: Radian -> DrawingContextFSource
Set the connector arc angle.
source_arm_len :: InterpretUnit u => u -> DrawingContextFSource
Set the connector source arm length.
dest_arm_len :: InterpretUnit u => u -> DrawingContextFSource
Set the connector destination arm length.
uniform_arm_len :: InterpretUnit u => u -> DrawingContextFSource
Set the connector source and destination arms to the same length.
conn_loop_size :: InterpretUnit u => u -> DrawingContextFSource
Set the connector loop size.
conn_box_halfsize :: InterpretUnit u => u -> DrawingContextFSource
Set the connector box halfsize.