Skip to content
Christopher Nikkel edited this page Dec 23, 2018 · 9 revisions

Text

Definition

type TextAnchor =
    | Start
    | Middle
    | End
    | Inherit

type Text =
    {
        Position: Point
        Body: string
        FontFamily: string option
        FontSize: int option
        Anchor: TextAnchor option
    }

Description

Text is used to create a SVG text block.

Functions

Function Signature Description
Text.create Point -> Length -> Text create a text block at a specified Point for the upper left corner and a string for the body
Text.withFont string -> int -> Text -> Text add a string font family and a integer font size to a text block
Text.withFontFamily string -> Text -> Text add a string font family to a text block
Text.withFontSize string -> Text -> Text add a integer font size to a text block
Text.withAnchor TextAnchor -> Text -> Text add a text anchor to a text block
Text.toString Text -> string convert a text block to a string

Usage

Example

let position =  Point.ofInts (55, 45)

let style = Style.create (Name Colors.White) (Name Colors.Black) (Length.ofInt 1) 1.0 1.0

Text.create position "Hello World!"
  |> Element.createWithStyle style
  |> printf "%O"

Output

<text stroke="black" stroke-width="1" fill="white" opacity="1" x="55" y="45">Hello World!</text>

Table of Contents

Getting Started

Fundamentals

Basic SVG Elements

Advanced Elements

Experimental

Clone this wiki locally