Core Modules

@sutton-signwriting/core

Gitter version npm downloads

Core Package Mindmap

@sutton-signwriting/core is a javascript package for node and browsers that supports general processing of SignWriting text.

This package supports both Formal SignWriting in ASCII (FSW) and SignWriting in Unicode (SWU) character sets, along with the associated query languages and style string. See draft-slevinski-formal-signwriting for detailed specification.

Author: https://SteveSlevinski.me
Channel: https://www.youtube.com/channel/UCXu4AXlG0rXFtk_5SzumDow
Support: https://www.patreon.com/signwriting

Useful links

Types of files

The source is written in small ES Modules available in the src directory along with the associated tests.

The distribution is available in three flavors. 20 KB for the whole library minified. Individual modules as small as 3 KB.

  • .js - Universal Module Definition
  • .cjs - CommonJS
  • .mjs - ES Module

Installation

Download and Install with NPM

npm install @sutton-signwriting/core

Developer Installation

Download from GitHub and Install Development Dependencies

wget https://github.com/sutton-signwriting/core/archive/master.zip
unzip master.zip
cd core-master
npm install

Usage

Using in Node

// import entire library
const core = require('@sutton-signwriting/core');

// import individual module
const fsw = require('@sutton-signwriting/core/fsw');

Using in the Browser

Local files

// import entire library
// available as ssw.core
<script src="core.js"></script>

// import individual module
// available as ssw.fsw
<script src="fsw/fsw.js"></script>

Unpkg

// import entire library
// available as ssw.core
<script src="https://unpkg.com/@sutton-signwriting/core@1.2.0"></script>

// import individual module
// available as ssw.fsw
<script src="https://unpkg.com/@sutton-signwriting/core@1.2.0/fsw/fsw.js"></script>

License

MIT

SignWriting General Interest

fsw

The fsw module contains functions for handling Formal SignWriitng in ASCII (FSW) characters. FSW characters definition

fsw

fsw.re

Object of regular expressions for FSW strings

{ symbol, coord, sort, box, prefix, spatial, signbox, sign, sortable }

fsw.re

Type: object

fsw.parse.symbol

Function to parse an fsw symbol with optional coordinate and style string

fsw.parse.symbol(fswSym: string): object
Parameters
fswSym (string) an fsw symbol
Returns
object: elements of fsw symbol
Example
fsw.parse.symbol('S10000500x500-C')

return {
 'symbol': 'S10000',
 'coord': [500, 500],
 'style': '-C'
}

fsw.parse.sign

Function to parse an fsw sign with style string

fsw.parse.sign(fswSign: string): object
Parameters
fswSign (string) an fsw sign
Returns
object: elements of fsw sign
Example
fsw.parse.sign('AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475-C')

return {
 sequence: ['S10011', 'S10019', 'S2e704', 'S2e748'],
 box: 'M',
 max: [525, 535],
 spatials: [
   {
     symbol: 'S2e748',
     coord: [483, 510]
   },
   {
     symbol: 'S10011',
     coord: [501, 466]
   },
   {
     symbol: 'S2e704',
     coord: [510, 500]
   },
   {
     symbol: 'S10019',
     coord: [476, 475]
   }
 ],
 style: '-C'
}

fsw.compose.symbol

Function to compose an fsw symbol with optional coordinate and style string

fsw.compose.symbol(fswSymObject: object): string
Parameters
fswSymObject (object) an fsw symbol object
Name Description
fswSymObject.symbol string an fsw symbol key
fswSymObject.coord Array<number> top-left coordinate of symbol with 500,500 center
fswSymObject.style string a style string for custom appearance
Returns
string: an fsw symbol string
Example
fsw.compose.symbol({
 'symbol': 'S10000',
 'coord': [480, 480],
 'style': '-C'
})

return 'S10000480x480-C'

fsw.compose.sign

Function to compose an fsw sign with style string

fsw.compose.sign(): string
Returns
string: an fsw sign string
Example
fsw.compose.sign({
 sequence: ['S10011', 'S10019', 'S2e704', 'S2e748'],
 box: 'M',
 max: [525, 535],
 spatials: [
   {
     symbol: 'S2e748',
     coord: [483, 510]
   },
   {
     symbol: 'S10011',
     coord: [501, 466]
   },
   {
     symbol: 'S2e704',
     coord: [510, 500]
   },
   {
     symbol: 'S10019',
     coord: [476, 475]
   }
 ],
 style: '-C'
})

return 'AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475-C'

fsw.kind

Array of numbers for kinds of symbols: writing, location, and punctuation.

fsw.kind

Type: array

fsw.category

Array of numbers for categories of symbols: hand, movement, dynamics, head, trunk & limb, location, and punctuation.

fsw.category

Type: array

fsw.group

Array of numbers for the 30 symbol groups.

fsw.group

Type: array

fsw.ranges

Object of symbol ranges with starting and ending numbers.

{ all, writing, hand, movement, dynamic, head, hcenter, vcenter, trunk, limb, location, punctuation }

fsw.ranges

Type: object

fsw.isType

Function to test if symbol is of a certain type.

fsw.isType(key: string, type: string): boolean
Parameters
key (string) an FSW symbol key
type (string) the name of a symbol range
Returns
boolean: is symbol of specified type
Example
fsw.isType('S10000', 'hand')

return true

fsw.colors

Array of colors associated with the seven symbol categories.

fsw.colors

Type: array

fsw.colorize

Function that returns the standardized color for a symbol.

fsw.colorize(key: string): string
Parameters
key (string) an FSW symbol key
Returns
string: name of standardized color for symbol
Example
fsw.colorize('S10000')

return '#0000CC'

fswquery

The fswquery module contains functions for handling the FSW query language. Query Language definition

fswquery

fswquery.re

Object of regular expressions for FSW query strings

{ base, coord, var, symbol, range, prefix, signbox, full }

fswquery.re

Type: object

fswquery.parse

Function to parse FSW query string to object

fswquery.parse(fswQueryString: string): object
Parameters
fswQueryString (string) an FSW query string
Returns
object: elements of an FSW query string
Example
fswquery.parse('QAS10000R100t204S20500TS20000R100t105500x500V5-')

return {
 query: true,
 prefix: {
   required: true,
   parts: [
     'S10000',
     ['100', '204'],
     'S20500'
   ]
 },
 signbox: [
   { symbol: 'S20000' },
   {
     range: ['100', '105'],
     coord: [500, 500]
   }
 ],
 variance: 5,
 style: true
}

fswquery.compose

Function to compose FSW query string from object

fswquery.compose(fswQueryObject: object): string
Parameters
fswQueryObject (object) an object of style options
Name Description
fswQueryObject.query boolean required true for FSW query object
fswQueryObject.prefix object an object for prefix elements
fswQueryObject.prefix.required boolean true if sorting prefix is required
fswQueryObject.prefix.parts Array<(string | Array<string>)> array of symbol strings and range arrays
fswQueryObject.signbox Array<({symbol: string, coord: Array<number>} | {range: Array<string>, coord: Array<number>})> array of objects for symbols and ranges with optional coordinates
fswQueryObject.variance number amount that x or y coordinates can vary and find a match, defaults to 20
fswQueryObject.style boolean boolean value for including style string in matches
Returns
string: FSW query string
Example
fswquery.compose({
 query: true,
 prefix: {
   required: true,
   parts: [
     'S10000',
     ['100', '204'],
     'S20500'
   ]
 },
 signbox: [
   { symbol: 'S20000' },
   {
     range: ['100', '105'],
     coord: [500, 500]
   }
 ],
 variance: 5,
 style: true
})

return 'QAS10000R100t204S20500TS20000R100t105500x500V5-'

fswquery.fsw2query

Function to convert an FSW sign to a query string

For the flags parameter, use one or more of the following.

  • A: exact symbol in temporal prefix
  • a: general symbol in temporal prefix
  • S: exact symbol in spatial signbox
  • s: general symbol in spatial signbox
  • L: spatial signbox symbol at location
fswquery.fsw2query(fswSign: string, flags: string): string
Parameters
fswSign (string) FSW sign
flags (string) flags for query string creation
Returns
string: FSW query string
Example
fswquery.fsw2query('AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475', 'ASL')

return 'QAS10011S10019S2e704S2e748TS2e748483x510S10011501x466S2e704510x500S10019476x475'

fswquery.range

Function to transform a range to a regular expression

fswquery.range(min: (number | string), max: (number | string), hex: boolean?): string
Parameters
min ((number | string)) either a decimal number or hexidecimal string
max ((number | string)) either a decimal number or hexidecimal string
hex (boolean?) if true, the regular expression will match a hexidecimal range
Returns
string: a regular expression that matches a range
Example
fswquery.range(500,749)

return '(([56][0-9][0-9])|(7[0-4][0-9])|(750))'
fswquery.range('100','10e',true)

return '10[0-9a-e]'

fswquery.regex

Function to transform an FSW query string to one or more regular expressions

fswquery.regex(query: string): Array<string>
Parameters
query (string) an FSW query string
Returns
Array<string>: an array of one or more regular expressions
Example
fswquery.regex('QS100uuS20500480x520')

return [
  '(A(S[123][0-9a-f]{2}[0-5][0-9a-f])+)?[BLMR]([0-9]{3}x[0-9]{3})(S[123][0-9a-f]{2}[0-5][0-9a-f][0-9]{3}x[0-9]{3})*S100[0-5][0-9a-f][0-9]{3}x[0-9]{3}(S[123][0-9a-f]{2}[0-5][0-9a-f][0-9]{3}x[0-9]{3})*',
  '(A(S[123][0-9a-f]{2}[0-5][0-9a-f])+)?[BLMR]([0-9]{3}x[0-9]{3})(S[123][0-9a-f]{2}[0-5][0-9a-f][0-9]{3}x[0-9]{3})*S20500((4[6-9][0-9])|(500))x((5[0-3][0-9])|(540))(S[123][0-9a-f]{2}[0-5][0-9a-f][0-9]{3}x[0-9]{3})*'
]

fswquery.results

Function that uses a query string to match signs from a string of text.

fswquery.results(query: string, text: string): Array<string>
Parameters
query (string) an FSW query string
text (string) a string of text containing multiple signs
Returns
Array<string>: an array of FSW signs
Example
fswquery.results('QAS10011T','AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475 AS15a21S15a07S21100S2df04S2df14M521x538S15a07494x488S15a21498x489S2df04498x517S2df14497x461S21100479x486 AS1f010S10018S20600M519x524S10018485x494S1f010490x494S20600481x476')

return [
  'AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475'
]

fswquery.lines

Function that uses an FSW query string to match signs from multiple lines of text.

fswquery.lines(query: string, text: string): Array<string>
Parameters
query (string) an FSW query string
text (string) multiple lines of text, each starting with an FSW sign
Returns
Array<string>: an array of lines of text, each starting with an FSW sign
Example
fswquery.lines('QAS10011T',`AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475 line one
AS15a21S15a07S21100S2df04S2df14M521x538S15a07494x488S15a21498x489S2df04498x517S2df14497x461S21100479x486 line two
AS1f010S10018S20600M519x524S10018485x494S1f010490x494S20600481x476 line three`)

return [
  'AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475 line one'
]

swu

The swu module contains functions for handling SignWriitng in Unicode (SWu) characters. SWU characters definition

swu

swu.re

Object of regular expressions for SWU strings in UTF-16

{ symbol, coord, sort, box, prefix, spatial, signbox, sign, sortable }

swu.re

Type: object

swu.parse.symbol

Function to parse an swu symbol with optional coordinate and style string

swu.parse.symbol(swuSym: string): object
Parameters
swuSym (string) an swu symbol
Returns
object: elements of swu symbol
Example
swu.parse.symbol('񀀁𝤆𝤆-C')

return {
 'symbol': '񀀁',
 'coord': [500, 500],
 'style': '-C'
}

swu.parse.sign

Function to parse an swu sign with style string

swu.parse.sign(swuSign: string): object
Parameters
swuSign (string) an swu sign
Returns
object: elements of swu sign
Example
swu.parse.sign('𝠀񀀒񀀚񋚥񋛩𝠃𝤟𝤩񋛩𝣵𝤐񀀒𝤇𝣤񋚥𝤐𝤆񀀚𝣮𝣭-C')

return {
 sequence: ['񀀒','񀀚','񋚥','񋛩''],
 box: '𝠃',
 max: [525, 535],
 spatials: [
   {
     symbol: '񋛩',
     coord: [483, 510]
   },
   {
     symbol: '񀀒',
     coord: [501, 466]
   },
   {
     symbol: '񋚥',
     coord: [510, 500]
   },
   {
     symbol: '񀀚',
     coord: [476, 475]
   }
 ],
 style: '-C'
}

swu.encode

Function to encode SWU characters using the UTF-16 escape format.

swu.encode(swu: string): string
Parameters
swu (string) SWU characters
Returns
string: UTF-16 escape format
Example
swu.encode('񀀁𝤆𝤆')

return '\\uD8C0\\uDC01\\uD836\\uDD06\\uD836\\uDD06'

swu.decode

Function to decode UTF-16 escape format to SWU characters.

swu.decode(encoded: string): string
Parameters
encoded (string) UTF-16 escape format
Returns
string: SWU characters
Example
swu.decode('\\uD8C0\\uDC01\\uD836\\uDD06\\uD836\\uDD06')

return '񀀁𝤆𝤆'

swu.pair

Function to decompose an SWU character into UTF-16 surrogate pairs.

swu.pair(swuChar: string): Array<string>
Parameters
swuChar (string) an SWU character
Returns
Array<string>: an array of UTF-16 surrogate pairs
Example
swu.pair('񀀁')

return ['D8C0', 'DC01']

swu.compose.symbol

Function to compose an swu symbol with optional coordinate and style string

swu.compose.symbol(swuSymObject: object): string
Parameters
swuSymObject (object) an swu symbol object
Name Description
swuSymObject.symbol string an swu symbol key
swuSymObject.coord Array<number> top-left coordinate of symbol with 500,500 center
swuSymObject.style string a style string for custom appearance
Returns
string: an swu symbol string
Example
swu.compose.symbol({
 'symbol': '񀀁',
 'coord': [500, 500],
 'style': '-C'
})

return '񀀁𝤆𝤆-C'

swu.compose.sign

Function to compose an swu sign with style string

swu.compose.sign(): string
Returns
string: an swu sign string
Example
swu.compose.sign({
 sequence: ['񀀒','񀀚','񋚥','񋛩''],
 box: '𝠃',
 max: [525, 535],
 spatials: [
   {
     symbol: '񋛩',
     coord: [483, 510]
   },
   {
     symbol: '񀀒',
     coord: [501, 466]
   },
   {
     symbol: '񋚥',
     coord: [510, 500]
   },
   {
     symbol: '񀀚',
     coord: [476, 475]
   }
 ],
 style: '-C'
})

return '𝠀񀀒񀀚񋚥񋛩𝠃𝤟𝤩񋛩𝣵𝤐񀀒𝤇𝣤񋚥𝤐𝤆񀀚𝣮𝣭-C'

swu.kind

Array of plane 4 code points for kinds of symbols: writing, location, and punctuation.

swu.kind

Type: array

swu.category

Array of plane 4 code points for categories of symbols: hand, movement, dynamics, head, trunk & limb, location, and punctuation.

swu.category

Type: array

swu.group

Array of plane 4 code points for the 30 symbol groups.

swu.group

Type: array

swu.ranges

Object of symbol ranges with starting and ending code points on plane 4.

{ all, writing, hand, movement, dynamic, head, hcenter, vcenter, trunk, limb, location, punctuation }

swu.ranges

Type: object

swu.isType

Function to test if symbol is of a certain type.

swu.isType(swuSym: string, type: string): boolean
Parameters
swuSym (string) an SWU symbol character
type (string) the name of a symbol range
Returns
boolean: is symbol of specified type
Example
swu.isType('񀀁', 'hand')

return true

swu.colors

Array of colors associated with the seven symbol categories.

swu.colors

Type: array

swu.colorize

Function that returns the standardized color for a symbol.

swu.colorize(swuSym: string): string
Parameters
swuSym (string) an SWU symbol character
Returns
string: name of standardized color for symbol
Example
swu.colorize('񀀁')

return '#0000CC'

swuquery

The swuquery module contains functions for handling the SWU query language. Query Language definition

swuquery

swuquery.re

Object of regular expressions for SWU query strings

{ base, coord, var, symbol, range, prefix, signbox, full }

swuquery.re

Type: object

swuquery.parse

Function to parse SWU query string to object

swuquery.parse(swuQueryString: string): object
Parameters
swuQueryString (string) an SWU query string
Returns
object: elements of an SWU query string
Example
swuquery.parse('QA񀀁R񀀁񆆑񆇡T񆀁R񀀁񀇱𝤆𝤆V5-')

return { 
  query: true,
  prefix: {
    required: true,
    parts: [
      '񀀁',
      ['񀀁', '񆆑'],
      '񆇡'
    ]
  },
  signbox: [
    { symbol: '񆀁' },
    {
      range: ['񀀁', '񀇱'],
      coord: [500, 500]
    }
  ],
  variance: 5,
  style: true 
}

swuquery.compose

Function to compose SWU query string from object

swuquery.compose(swuQueryObject: object): string
Parameters
swuQueryObject (object) an object of style options
Name Description
swuQueryObject.query boolean required true for SWU query object
swuQueryObject.prefix object an object for prefix elements
swuQueryObject.prefix.required boolean true if sorting prefix is required
swuQueryObject.prefix.parts Array<(string | Array<string>)> array of symbol strings and range arrays
swuQueryObject.signbox Array<({symbol: string, coord: Array<number>} | {range: Array<string>, coord: Array<number>})> array of objects for symbols and ranges with optional coordinates
swuQueryObject.variance number amount that x or y coordinates can vary and find a match, defaults to 20
swuQueryObject.style boolean boolean value for including style string in matches
Returns
string: SWU query string
Example
swuquery.compose({ 
  query: true,
  prefix: {
    required: true,
    parts: [
      '񀀁',
      ['񀀁', '񆆑'],
      '񆇡'
    ]
  },
  signbox: [
    { symbol: '񆀁' },
    {
      range: ['񀀁', '񀇱'],
      coord: [500, 500]
    }
  ],
  variance: 5,
  style: true 
})

return 'QA񀀁R񀀁񆆑񆇡T񆀁R񀀁񀇱𝤆𝤆V5-'

swuquery.swu2query

Function to convert an SWU sign to a query string

For the flags parameter, use one or more of the following.

  • A: exact symbol in temporal prefix
  • a: general symbol in temporal prefix
  • S: exact symbol in spatial signbox
  • s: general symbol in spatial signbox
  • L: spatial signbox symbol at location
swuquery.swu2query(swuSign: string, flags: string): string
Parameters
swuSign (string) SWU sign
flags (string) flags for query string creation
Returns
string: SWU query string
Example
swuquery.swu2query('𝠀񀀒񀀚񋚥񋛩𝠃𝤟𝤩񋛩𝣵𝤐񀀒𝤇𝣤񋚥𝤐𝤆񀀚𝣮𝣭', 'ASL')

return 'QA񀀒񀀚񋚥񋛩T񋛩𝣵𝤐񀀒𝤇𝣤񋚥𝤐𝤆񀀚𝣮𝣭'

swuquery.range

Function to transform a range of SWU characters to a regular expression

swuquery.range(min: string, max: string): string
Parameters
min (string) an SWU character
max (string) an SWU character
Returns
string: a regular expression that matches a range of SWU characters
Example
swuquery.range('񀀁', '񀇡')

return '\uD8C0[\uDC01-\uDDE1]'
swuquery.range('𝣔', '𝤸')

return '\uD836[\uDCD4-\uDD38]'

swuquery.symbolRanges

Function to transform an SWU symbol with fill and rotation flags to a regular expression

swuquery.symbolRanges(symbolFR: string): string
Parameters
symbolFR (string) an SWU character with optional flags of 'f' for any fill and 'r' for any rotation
Returns
string: a regular expression that matches one or more ranges of SWU symbols
Example

Match an exact symbol

swuquery.symbolRanges('񀀁')

return '\uD8C0\uDC01');

Match a symbol with any fill

swuquery.symbolRanges('񀀁f')

return '(\uD8C0\uDC01|\uD8C0\uDC11|\uD8C0\uDC21|\uD8C0\uDC31|\uD8C0\uDC41|\uD8C0\uDC51)'

Match a symbol with any rotation

swuquery.symbolRanges('񀀁r')

return '\uD8C0[\uDC01-\uDC10]'

Match a symbol with any fill or rotation

swuquery.symbolRanges('񀀁fr')

return '\uD8C0[\uDC01-\uDC60]'

swuquery.regex

Function to transform an SWU query string to one or more regular expressions

swuquery.regex(query: string): Array<string>
Parameters
query (string) an SWU query string
Returns
Array<string>: an array of one or more regular expressions
Example
swuquery.regex('QA񀀒T')

return [
  '(\uD836\uDC00\uD8C0\uDC12((?:(?:\uD8C0[\uDC01-\uDFFF])|(?:[\uD8C1-\uD8FC][\uDC00-\uDFFF])|(?:\uD8FD[\uDC00-\uDC80])))*)\uD836[\uDC01-\uDC04](?:\uD836[\uDC0C-\uDDFF]){2}((?:(?:\uD8C0[\uDC01-\uDFFF])|(?:[\uD8C1-\uD8FC][\uDC00-\uDFFF])|(?:\uD8FD[\uDC00-\uDC80]))(?:\uD836[\uDC0C-\uDDFF]){2})*'
]

swuquery.results

Function that uses a query string to match signs from a string of text.

swuquery.results(query: string, text: string): Array<string>
Parameters
query (string) an SWU query string
text (string) a string of text containing multiple signs
Returns
Array<string>: an array of SWU signs
Example
swuquery.results('QA񀀒T','𝠀񀀒񀀚񋚥񋛩𝠃𝤟𝤩񋛩𝣵𝤐񀀒𝤇𝣤񋚥𝤐𝤆񀀚𝣮𝣭 𝠀񂇢񂇈񆙡񋎥񋎵𝠃𝤛𝤬񂇈𝤀𝣺񂇢𝤄𝣻񋎥𝤄𝤗񋎵𝤃𝣟񆙡𝣱𝣸 𝠀񅨑񀀙񆉁𝠃𝤙𝤞񀀙𝣷𝤀񅨑𝣼𝤀񆉁𝣳𝣮')

return [
  '𝠀񀀒񀀚񋚥񋛩𝠃𝤟𝤩񋛩𝣵𝤐񀀒𝤇𝣤񋚥𝤐𝤆񀀚𝣮𝣭'
]

swuquery.lines

Function that uses an SWU query string to match signs from multiple lines of text.

swuquery.lines(query: string, text: string): Array<string>
Parameters
query (string) an SWU query string
text (string) multiple lines of text, each starting with an SWU sign
Returns
Array<string>: an array of lines of text, each starting with an SWU sign
Example
swuquery.lines('QA񀀒T',`𝠀񀀒񀀚񋚥񋛩𝠃𝤟𝤩񋛩𝣵𝤐񀀒𝤇𝣤񋚥𝤐𝤆񀀚𝣮𝣭 line one
𝠀񂇢񂇈񆙡񋎥񋎵𝠃𝤛𝤬񂇈𝤀𝣺񂇢𝤄𝣻񋎥𝤄𝤗񋎵𝤃𝣟񆙡𝣱𝣸 line two
𝠀񅨑񀀙񆉁𝠃𝤙𝤞񀀙𝣷𝤀񅨑𝣼𝤀񆉁𝣳𝣮 line three`)

return [
  '𝠀񀀒񀀚񋚥񋛩𝠃𝤟𝤩񋛩𝣵𝤐񀀒𝤇𝣤񋚥𝤐𝤆񀀚𝣮𝣭 line one'
]

style

The style module contains regular expressions and functions for parsing and composing style strings. Style string definition

style

style.re

Object of regular expressions for style strings

{ colorize, colorhex, colorname, padding, zoom, zoomsym, classbase, id, colorbase, color, colors, background, detail, detailsym, classes, full }

style.re

Type: object

style.parse

Function to parse style string to object

style.parse(styleString: string): object
Parameters
styleString (string) a style string
Returns
object: elements of style string
Example
style.parse('-CP10G_blue_D_red,Cyan_')

return {
 'colorize': true,
 'padding': 10,
 'background': 'blue',
 'detail': ['red', 'Cyan']
}

style.compose

Function to compose style string from object

style.compose(styleObject: object): string
Parameters
styleObject (object) an object of style options
Name Description
styleObject.colorize boolean boolean to use standardized colors for symbol groups
styleObject.padding number integer value for padding around symbol or sign
styleObject.background string css name or hex color for background
styleObject.detail Array<string> css name or hex color for line and optional fill
styleObject.zoom number decimal value for zoom level
styleObject.detailsym Array<{index: number, detail: Array<string>}> array of symbol indexes and detail color array
styleObject.zoomsym Array<{index: number, zoom: number, offset: Array<number>}> array of symbol indexes and zoom levels with optional x,y offset
styleObject.classes string list of class names separated with spaces used for SVG
styleObject.id string id name used for SVG
Returns
string: style string
Example
style.compose({
 'colorize': true,
 'padding': 10,
 'background': 'blue',
 'detail': ['red', 'Cyan'],
 'zoom': 1.1,
 'detailsym': [
   {
     'index': 1,
     'detail': ['#ff00ff']
   },
   {
     'index': 2,
     'detail': ['yellow', 'green']
   }
 ],
 'zoomsym': [
   {
     'index': 1,
     'zoom': 10,
     'offset': [0, 0]
   },
   {
     'index': 2,
     'zoom': 5.5
   }
 ],
 'classes': 'primary blinking',
 'id': 'cursor'
})

return '-CP10G_blue_D_red,Cyan_Z1.1-D01_ff00ff_D02_yellow,green_Z01,10,500x500Z02,5.5-primary blinking!cursor!'

convert

The convert module contains functions to convert between Formal SignWriitng in ASCII (FSW) and SignWriting in Unicode (SWU) characters, along with other types of data. Characters set definitions

convert

convert.swu2mark

Function to convert an SWU structural marker to FSW equivalent

convert.swu2mark(swuMark: string): string
Parameters
swuMark (string) character for SWU structural marker
Returns
string: FSW structural marker
Example
convert.swu2mark('𝠀')

return 'A'

convert.mark2swu

Function to convert an FSW structural marker to SWU equivalent

convert.mark2swu(fswMark: string): string
Parameters
fswMark (string) character for FSW structural marker
Returns
string: SWU structural marker
Example
convert.mark2swu('A')

return '𝠀'

convert.swu2num

Function to convert an SWU number character to an integer

convert.swu2num(swuNum: string): number
Parameters
swuNum (string) SWU number character
Returns
number: Integer value for number
Example
convert.swu2num('𝤆')

return 500

convert.num2swu

Function to convert a number to an SWU number character

convert.num2swu(num: number): string
Parameters
num (number) Integer value for number
Returns
string: SWU number character
Example
convert.num2swu(500)

return '𝤆'

convert.swu2coord

Function to convert two SWU number characters to an array of x,y integers

convert.swu2coord(swuCoord: string): Array<number>
Parameters
swuCoord (string) Two SWU number character
Returns
Array<number>: Array of x,y integers
Example
convert.swu2coord('𝤆𝤆')

return [500, 500]

convert.coord2swu

Function to convert an array of x,y integers to two SWU number characters

convert.coord2swu(coord: Array<number>): string
Parameters
coord (Array<number>) Array of x,y integers
Returns
string: Two SWU number character
Example
convert.coord2swu([500, 500])

return '𝤆𝤆'

convert.fsw2coord

Function to convert an FSW coordinate string to an array of x,y integers

convert.fsw2coord(fswCoord: string): Array<number>
Parameters
fswCoord (string) An FSW coordinate string
Returns
Array<number>: Array of x,y integers
Example
convert.fsw2coord('500x500')

return [500, 500]

convert.coord2fsw

Function to convert an array of x,y integers to an FSW coordinate string

convert.coord2fsw(coord: Array<number>): string
Parameters
coord (Array<number>) Array of x,y integers
Returns
string: An FSW coordinate string
Example
convert.coord2fsw([500, 500])

return '500x500'

convert.swu2code

Function to convert an SWU symbol character to a code point on plane 4

convert.swu2code(swuSym: string): number
Parameters
swuSym (string) SWU symbol character
Returns
number: Code point on plane 4
Example
convert.swu2code('񀀁')

return 0x40001

convert.code2swu

Function to convert a code point on plane 4 to an SWU symbol character

convert.code2swu(code: number): string
Parameters
code (number) Code point on plane 4
Returns
string: SWU symbol character
Example
convert.code2swu(0x40001)

return '񀀁'

convert.swu2id

Function to convert an SWU symbol character to a 16-bit ID

convert.swu2id(swuSym: string): number
Parameters
swuSym (string) SWU symbol character
Returns
number: 16-bit ID
Example
convert.swu2id('񀀁')

return 1

convert.id2swu

Function to convert a 16-bit ID to an SWU symbol character

convert.id2swu(id: number): string
Parameters
id (number) 16-bit ID
Returns
string: SWU symbol character
Example
convert.id2swu(1)

return '񀀁'

convert.key2id

Function to convert an FSW symbol key to a 16-bit ID

convert.key2id(key: string): number
Parameters
key (string) FSW symbol key
Returns
number: 16-bit ID
Example
convert.key2id('S10000')

return 1

convert.id2key

Function to convert a 16-bit ID to an FSW symbol key

convert.id2key(id: number): string
Parameters
id (number) 16-bit ID
Returns
string: FSW symbol key
Example
convert.id2key(1)

return 'S10000'

convert.swu2key

Function to convert an SWU symbol character to an FSW symbol key

convert.swu2key(swuSym: string): string
Parameters
swuSym (string) SWU symbol character
Returns
string: FSW symbol key
Example
convert.swu2key('񀀁')

return 'S10000'

convert.key2swu

Function to convert an FSW symbol key to an SWU symbol character

convert.key2swu(key: string): string
Parameters
key (string) FSW symbol key
Returns
string: SWU symbol character
Example
convert.key2swu('S10000')

return '񀀁'

convert.swu2fsw

Function to convert SWU text to FSW text

convert.swu2fsw(swuText: string): string
Parameters
swuText (string) SWU text
Returns
string: FSW text
Example
convert.swu2fsw('𝠀񀀒񀀚񋚥񋛩𝠃𝤟𝤩񋛩𝣵𝤐񀀒𝤇𝣤񋚥𝤐𝤆񀀚𝣮𝣭')

return 'AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475'

convert.fsw2swu

Function to convert FSW text to SWU text

convert.fsw2swu(fswText: string): string
Parameters
fswText (string) FSW text
Returns
string: SWU text
Example
convert.fsw2swu('AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475')

return '𝠀񀀒񀀚񋚥񋛩𝠃𝤟𝤩񋛩𝣵𝤐񀀒𝤇𝣤񋚥𝤐𝤆񀀚𝣮𝣭'