Modulelucid-svg-0.7.2.0Haskell2010
Lucid.Svg
DSL for creating SVG.
Synopsis
- type Svg
- value prettyText
- value accent_height_
- value accumulate_
- value additive_
- value alignment_baseline_
- value alphabetic_
- value amplitude_
- value arabic_form_
- value ascent_
- value attributeName_
- value attributeType_
- value azimuth_
- value baseFrequency_
- value baseline_shift_
- value baseprofile_
- value bbox_
- value begin_
- value bias_
- value by_
- value calcMode_
- value cap_height_
- value class_
- value clipPathUnits_
- value clip_
- value clip_path_
- value clip_rule_
- value color_
- value color_interpolation_
- value color_interpolation_filters_
- value color_profile_
- value color_rendering_
- value contentScriptType_
- value contentStyleType_
- value cx_
- value cy_
- value d_
- value descent_
- value diffuseConstant_
- value direction_
- value display_
- value divisor_
- value dominant_baseline_
- value dur_
- value dx_
- value dy_
- value edgeMode_
- value elevation_
- value enable_background_
- value end_
- value exponent_
- value externalResourcesRequired_
- value fill_
- value fill_opacity_
- value fill_rule_
- value filterRes_
- value filterUnits_
- value flood_color_
- value flood_opacity_
- value font_family_
- value font_size_
- value font_size_adjust_
- value font_stretch_
- value font_style_
- value font_variant_
- value font_weight_
- value format_
- value from_
- value fx_
- value fy_
- value g1_
- value g2_
- value glyph_name_
- value glyph_orientation_horizontal_
- value glyph_orientation_vertical_
- value gradientTransform_
- value gradientUnits_
- value hanging_
- value height_
- value horiz_adv_x_
- value horiz_origin_x_
- value horiz_origin_y_
- value id_
- value ideographic_
- value image_rendering_
- value in2_
- value in_
- value intercept_
- value k1_
- value k2_
- value k3_
- value k4_
- value k_
- value kernelMatrix_
- value kernelUnitLength_
- value kerning_
- value keyPoints_
- value keySplines_
- value keyTimes_
- value lang_
- value lengthAdjust_
- value letter_spacing_
- value lighting_color_
- value limitingConeAngle_
- value local_
- value markerHeight_
- value markerUnits_
- value markerWidth_
- value marker_end_
- value marker_mid_
- value marker_start_
- value maskContentUnits_
- value maskUnits_
- value mathematical_
- value max_
- value media_
- value method_
- value min_
- value mode_
- value name_
- value numOctaves_
- value offset_
- value onabort_
- value onactivate_
- value onbegin_
- value onclick_
- value onend_
- value onerror_
- value onfocusin_
- value onfocusout_
- value onload_
- value onmousedown_
- value onmousemove_
- value onmouseout_
- value onmouseover_
- value onmouseup_
- value onrepeat_
- value onresize_
- value onscroll_
- value onunload_
- value onzoom_
- value opacity_
- value operator_
- value order_
- value orient_
- value orientation_
- value origin_
- value overflow_
- value overline_position_
- value overline_thickness_
- value paint_order_
- value panose_1_
- value pathLength_
- value patternContentUnits_
- value patternTransform_
- value patternUnits_
- value pointer_events_
- value pointsAtX_
- value pointsAtY_
- value pointsAtZ_
- value points_
- value preserveAlpha_
- value preserveAspectRatio_
- value primitiveUnits_
- value r_
- value radius_
- value refX_
- value refY_
- value rendering_intent_
- value repeatCount_
- value repeatDur_
- value requiredExtensions_
- value requiredFeatures_
- value restart_
- value result_
- value rotate_
- value rx_
- value ry_
- value scale_
- value seed_
- value shape_rendering_
- value slope_
- value spacing_
- value specularConstant_
- value specularExponent_
- value spreadMethod_
- value startOffset_
- value stdDeviation_
- value stemh_
- value stemv_
- value stitchTiles_
- value stop_color_
- value stop_opacity_
- value strikethrough_position_
- value strikethrough_thickness_
- value string_
- value stroke_
- value stroke_dasharray_
- value stroke_dashoffset_
- value stroke_linecap_
- value stroke_linejoin_
- value stroke_miterlimit_
- value stroke_opacity_
- value stroke_width_
- value surfaceScale_
- value systemLanguage_
- value tableValues_
- value targetX_
- value targetY_
- value target_
- value textLength_
- value text_anchor_
- value text_decoration_
- value text_rendering_
- value to_
- value transform_
- value type_
- value u1_
- value u2_
- value underline_position_
- value underline_thickness_
- value unicode_
- value unicode_bidi_
- value unicode_range_
- value units_per_em_
- value v_alphabetic_
- value v_hanging_
- value v_ideographic_
- value v_mathematical_
- value values_
- value version_
- value vert_adv_y_
- value vert_origin_x_
- value vert_origin_y_
- value viewBox_
- value viewTarget_
- value visibility_
- value width_
- value widths_
- value word_spacing_
- value writing_mode_
- value x1_
- value x2_
- value xChannelSelector_
- value x_
- value x_height_
- value xlinkActuate_
- value xlinkArcrole_
- value xlinkHref_
- value xlinkRole_
- value xlinkShow_
- value xlinkTitle_
- value xlinkType_
- value xmlBase_
- value xmlLang_
- value xmlSpace_
- value y1_
- value y2_
- value yChannelselector_
- value y_
- value z_
- value zoomAndPan_
- value renderText
- value renderBS
- value renderTextT
- value renderBST
- value renderToFile
- value execHtmlT
- value evalHtmlT
- value runHtmlT
- data Attribute
- class Term
- class ToHtml
- class With
- Packagelucid-svg-0.7.2.0
- Exports274
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceSvg.hs
Intro
SVG elements and attributes in Lucid-Svg are written with a postfix ‘_’.
Some examples:
path_, circle_, color_, scale_
Note: If you're testing in the REPL you need to add a type annotation to indicate that you want SVG. In normal code your top-level declaration signatures handle that.
Plain text is written using the OverloadedStrings and
ExtendedDefaultRules extensions, and is automatically escaped:
As in Lucid, elements nest by function application:
g_ (text_ "Hello SVG") :: Svg ()<g><text>Hello SVG</text></g>
and elements are juxtaposed via monoidal append or monadic sequencing:
text_ "Hello" <> text_ "SVG" :: Svg ()<text>Hello</text><text>SVG</text>
do text_ "Hello"; text_ "SVG" :: Svg ()<text>Hello</text><text>SVG</text>
Attributes are set by providing an argument list. In contrast to HTML many SVG elements have no content, only attributes.
rect_ [width_ "100%", height_ "100%", fill_ "red"] :: Svg ()<rect height="100%" width="100%" fill="red"></rect>
Attributes and elements that share the same name are not conflicting unless they appear on the list in the note below:
mask_ [mask_ "attribute"] "element" :: Svg ()<mask mask="attribute">element</mask>
Note: The following element and attribute names overlap and cannot be
handled polymorphically since doing so would create conflicting functional
dependencies. The unqualifed name refers to the element.
We qualify the attribute name as A. For example, path_ and path_.
colorProfile_, cursor_, filter_, path_, and style_
Path data can be constructed using the functions in Lucid.Svg.Path
and combined monoidally:
path_ (
[ d_ (mA 10 80 <> qA 52.5 10 95 80 <> tA 180 80 <> z)
, stroke_ "blue"
, fill_ "orange"
])
<path d="M 10,80 Q 52.5,10 95,80 T 180,80 Z" stroke="blue" fill="orange"></path>A slightly longer example:
import Lucid.Svg
svg :: Svg () -> Svg ()
svg content = do
doctype_
with (svg11_ content) [version_ "1.1", width_ "300" , height_ "200"]
contents :: Svg ()
contents = do
rect_ [width_ "100%", height_ "100%", fill_ "red"]
circle_ [cx_ "150", cy_ "100", r_ "80", fill_ "green"]
text_ [x_ "150", y_ "125", fontSize_ "60", textAnchor_ "middle", fill_ "white"] "SVG"
main :: IO ()
main = do
print $ svg contentsRendering
Re-exports
module Lucid.Svg.Path
module Lucid.Svg.Elements
The accentHeight attribute.
The accumulate attribute.
The additive attribute.
The alignmentBaseline attribute.
The alphabetic attribute.
The amplitude attribute.
The arabicForm attribute.
The ascent attribute.
The attributename attribute.
The attributetype attribute.
The azimuth attribute.
The basefrequency attribute.
The baselineShift attribute.
The baseprofile attribute.
The bbox attribute.
The begin attribute.
The bias attribute.
The by attribute.
The calcmode attribute.
The capHeight attribute.
The class attribute.
The clippathunits attribute.
The clip attribute.
The clip-path attribute.
The clipRule attribute.
The color attribute.
The colorInterpolation attribute.
The colorInterpolationFilters attribute.
The colorProfile attribute.
The colorRendering attribute.
The contentscripttype attribute.
The contentstyletype attribute.
The cx attribute.
The cy attribute.
The d attribute.
The descent attribute.
The diffuseconstant attribute.
The direction attribute.
The display attribute.
The divisor attribute.
The dominantBaseline attribute.
The dur attribute.
The dx attribute.
The dy attribute.
The edgemode attribute.
The elevation attribute.
The enableBackground attribute.
The end attribute.
The exponent attribute.
The externalresourcesrequired attribute.
The fill attribute.
The fillOpacity attribute.
The fillRule attribute.
The filterres attribute.
The filterunits attribute.
The floodColor attribute.
The floodOpacity attribute.
The fontFamily attribute.
The fontSize attribute.
The fontSizeAdjust attribute.
The fontStretch attribute.
The fontStyle attribute.
The fontVariant attribute.
The fontWeight attribute.
The format attribute.
The from attribute.
The fx attribute.
The fy attribute.
The g1 attribute.
The g2 attribute.
The glyphName attribute.
The glyphOrientationHorizontal attribute.
The glyphOrientationVertical attribute.
The -- | The gradienttransform@ attribute.
The gradientunits attribute.
The hanging attribute.
The height attribute.
The horizAdvX attribute.
The horizOriginX attribute.
The horizOriginY attribute.
The id attribute.
The ideographic attribute.
The imageRendering attribute.
The in2 attribute.
The in attribute.
The intercept attribute.
The k1 attribute.
The k2 attribute.
The k3 attribute.
The k4 attribute.
The k attribute.
The kernelmatrix attribute.
The kernelunitlength attribute.
The kerning attribute.
The keypoints attribute.
The keysplines attribute.
The keytimes attribute.
The lang attribute.
The lengthadjust attribute.
The letterSpacing attribute.
The lightingColor attribute.
The limitingconeangle attribute.
The local attribute.
The markerheight attribute.
The markerunits attribute.
The markerwidth attribute.
The markerEnd attribute.
The markerMid attribute.
The markerStart attribute.
The maskcontentunits attribute.
The maskunits attribute.
The mathematical attribute.
The max attribute.
The media attribute.
The method attribute.
The min attribute.
The mode attribute.
The name attribute.
The numoctaves attribute.
The offset attribute.
The onabort attribute.
The onactivate attribute.
The onbegin attribute.
The onclick attribute.
The onend attribute.
The onerror attribute.
The onfocusin attribute.
The onfocusout attribute.
The onload attribute.
The onmousedown attribute.
The onmousemove attribute.
The onmouseout attribute.
The onmouseover attribute.
The onmouseup attribute.
The onrepeat attribute.
The onresize attribute.
The onscroll attribute.
The onunload attribute.
The onzoom attribute.
The opacity attribute.
The operator attribute.
The order attribute.
The orient attribute.
The orientation attribute.
The origin attribute.
The overflow attribute.
The overlinePosition attribute.
The overlineThickness attribute.
The paint-order attribute.
The panose1 attribute.
The pathlength attribute.
The patterncontentunits attribute.
The patterntransform attribute.
The patternunits attribute.
The pointerEvents attribute.
The pointsatx attribute.
The pointsaty attribute.
The pointsatz attribute.
The points attribute.
The preservealpha attribute.
The preserveaspectratio attribute.
The primitiveunits attribute.
The r attribute.
The radius attribute.
The refx attribute.
The refy attribute.
The renderingIntent attribute.
The repeatcount attribute.
The repeatdur attribute.
The requiredextensions attribute.
The requiredfeatures attribute.
The restart attribute.
The result attribute.
The rotate attribute.
The rx attribute.
The ry attribute.
The scale attribute.
The seed attribute.
The shapeRendering attribute.
The slope attribute.
The spacing attribute.
The specularconstant attribute.
The specularexponent attribute.
The spreadmethod attribute.
The startoffset attribute.
The stddeviation attribute.
The stemh attribute.
The stemv attribute.
The stitchtiles attribute.
The stopColor attribute.
The stopOpacity attribute.
The strikethroughPosition attribute.
The strikethroughThickness attribute.
The string attribute.
The stroke attribute.
The strokeDasharray attribute.
The strokeDashoffset attribute.
The strokeLinecap attribute.
The strokeLinejoin attribute.
The strokeMiterlimit attribute.
The strokeOpacity attribute.
The strokeWidth attribute.
The surfacescale attribute.
The systemlanguage attribute.
The tablevalues attribute.
The targetx attribute.
The targety attribute.
The target attribute.
The textlength attribute.
The textAnchor attribute.
The textDecoration attribute.
The textRendering attribute.
The to attribute.
The transform attribute.
The type attribute.
The u1 attribute.
The u2 attribute.
The underlinePosition attribute.
The underlineThickness attribute.
The unicode attribute.
The unicodeBidi attribute.
The unicodeRange attribute.
The unitsPerEm attribute.
The vAlphabetic attribute.
The vHanging attribute.
The vIdeographic attribute.
The vMathematical attribute.
The values attribute.
The version attribute.
The vertAdvY attribute.
The vertOriginX attribute.
The vertOriginY attribute.
The viewbox attribute.
The viewtarget attribute.
The visibility attribute.
The width attribute.
The widths attribute.
The wordSpacing attribute.
The writingMode attribute.
The x1 attribute.
The x2 attribute.
The xchannelselector attribute.
The x attribute.
The xHeight attribute.
The xlinkActuate attribute.
The xlinkArcrole attribute.
The xlinkHref attribute.
The xlinkRole attribute.
The xlinkShow attribute.
The xlinkTitle attribute.
The xlinkType attribute.
The xmlBase attribute.
The xmlLang attribute.
The xmlSpace attribute.
The y1 attribute.
The y2 attribute.
The ychannelselector attribute.
The y attribute.
The z attribute.
The zoomandpan attribute.
From Lucid.Base
Render the HTML to a lazy Text.
This is a convenience function defined in terms of execHtmlT, runIdentity and toLazyByteString, and decodeUtf8. Check the source if you're interested in the lower-level behaviour.
Render the HTML to a lazy ByteString.
This is a convenience function defined in terms of execHtmlT, runIdentity and toLazyByteString. Check the source if you're interested in the lower-level behaviour.
Render the HTML to a lazy Text, but in a monad.
This is a convenience function defined in terms of execHtmlT and toLazyByteString, and decodeUtf8. Check the source if you're interested in the lower-level behaviour.
Render the HTML to a lazy ByteString, but in a monad.
This is a convenience function defined in terms of execHtmlT and toLazyByteString. Check the source if you're interested in the lower-level behaviour.
Render the HTML to a lazy ByteString.
This is a convenience function defined in terms of execHtmlT, runIdentity and toLazyByteString. Check the source if you're interested in the lower-level behaviour.
Running
Build the HTML. Analogous to execState.
You might want to use this is if you want to do something with the raw Builder. Otherwise for simple cases you can just use renderText or renderBS.
evalHtmlT Evaluate the HTML to its return value. Analogous to evalState.
Use this if you want to ignore the HTML output of an action completely and just get the result.
For using with the Html type, you'll need runIdentity e.g.
runIdentity (evalHtmlT (p_ "Hello!"))()
Types
A simple attribute. Don't use the constructor, use makeAttribute. Attributes are case sensitive, so if you want attributes to be merged properly, use a single case representation.
Instances7Eq, Show, Hashable, Term, TermRaw, …
Eq AttributeDefined in lucid-2.11.20260427 · Lucid.BaseShow AttributeDefined in lucid-2.11.20260427 · Lucid.BaseHashable AttributeDefined in lucid-2.11.20260427 · Lucid.BaseTerm Text AttributeDefined in lucid-2.11.20260427 · Lucid.BaseTermRaw Text AttributeDefined in lucid-2.11.20260427 · Lucid.Base(Applicative m, f ~ HtmlT m a) => Term [Attribute] (f -> HtmlT m a)Defined in lucid-2.11.20260427 · Lucid.BaseGiven attributes, expect more child input.
(Monad m, ToHtml f, a ~ ()) => TermRaw [Attribute] (f -> HtmlT m a)Defined in lucid-2.11.20260427 · Lucid.BaseGiven attributes, expect more child input.
Classes
Used to construct HTML terms.
Simplest use: p_ = term "p" yields p_.
Very overloaded for three cases:
The first case is the basic
argof[(Text,Text)]which will return a function that wants children.The second is an
argwhich isHtmlT m (), in which case the term accepts no attributes and just the children are used for the element.Finally, this is also used for overloaded attributes, like style_ or title_. If a return type of
(Text,Text)is inferred then an attribute will be made.
The instances look intimidating but actually the constraints make
it very general so that type inference works well even in the
presence of things like OverloadedLists and such.
Instances3Term
Term Text AttributeDefined in lucid-2.11.20260427 · Lucid.Base(Applicative m, f ~ HtmlT m a) => Term [Attribute] (f -> HtmlT m a)Defined in lucid-2.11.20260427 · Lucid.BaseGiven attributes, expect more child input.
Applicative m => Term (HtmlT m a) (HtmlT m a)Defined in lucid-2.11.20260427 · Lucid.BaseGiven children immediately, just use that and expect no attributes.
Can be converted to HTML.
Instances6ToHtml
ToHtml ByteStringDefined in lucid-2.11.20260427 · Lucid.BaseToHtml ByteStringDefined in lucid-2.11.20260427 · Lucid.BaseToHtml StringDefined in lucid-2.11.20260427 · Lucid.BaseToHtml TextDefined in lucid-2.11.20260427 · Lucid.BaseToHtml TextDefined in lucid-2.11.20260427 · Lucid.Base(a ~ (), m ~ Identity) => ToHtml (HtmlT m a)Defined in lucid-2.11.20260427 · Lucid.Base
With an element use these attributes. An overloaded way of adding attributes either to an element accepting attributes-and-children or one that just accepts attributes. See the two instances.