1.6.0
@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
Donate: https://donate.sutton-signwriting.io
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. 28 KB for the whole library minified. Individual modules as small as 3 KB.
npm install @sutton-signwriting/core
wget https://github.com/sutton-signwriting/core/archive/master.zip
unzip master.zip
cd core-master
npm install
sudo apt install node-typescript
// import entire library
const core = require('@sutton-signwriting/core');
// import individual module
const fsw = require('@sutton-signwriting/core/fsw');
// 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>
// import entire library
// available as ssw.core
<script src="https://unpkg.com/@sutton-signwriting/core@1.6.0"></script>
// import individual module
// available as ssw.fsw
<script src="https://unpkg.com/@sutton-signwriting/core@1.6.0/fsw/fsw.js"></script>
MIT
The fsw module contains functions for handling Formal SignWriting in ASCII (FSW) characters. FSW characters definition
Object of regular expressions for FSW strings
(string)
: regular expressions for a symbol
(string)
: regular expressions for a coordinate
(string)
: regular expressions for the sorting marker
(string)
: regular expression for a signbox marker
(string)
: regular expression for a sorting marker followed by one or more symbols
(string)
: regular expression for a symbol followed by a coordinate
(string)
: regular expression for a signbox marker, max coordinate and zero or more spatial symbols
(string)
: regular expression for an optional prefix followed by a signbox
(string)
: regular expression for a mandatory prefix followed by a signbox
Function to parse an fsw symbol with optional coordinate and style string
(string)
an fsw symbol
SymbolObject
:
elements of fsw symbol
fsw.parse.symbol('S10000500x500-C')
return {
'symbol': 'S10000',
'coord': [500, 500],
'style': '-C'
}
Function to parse an fsw sign with style string
(string)
an fsw sign
SignObject
:
elements of fsw sign
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'
}
Function to parse an fsw text
(string)
an fsw text
Array<string>
:
fsw signs and punctuations
fsw.parse.text('AS14c20S27106M518x529S14c20481x471S27106503x489 AS18701S1870aS2e734S20500M518x533S1870a489x515S18701482x490S20500508x496S2e734500x468 S38800464x496')
return [
'AS14c20S27106M518x529S14c20481x471S27106503x489',
'AS18701S1870aS2e734S20500M518x533S1870a489x515S18701482x490S20500508x496S2e734500x468',
'S38800464x496'
]
Function to compose an fsw symbol with optional coordinate and style string
(SymbolObject)
an fsw symbol object
string
:
an fsw symbol string
fsw.compose.symbol({
'symbol': 'S10000',
'coord': [480, 480],
'style': '-C'
})
return 'S10000480x480-C'
Function to compose an fsw sign with style string
(SignObject)
an fsw symbol object
string
:
an fsw sign string
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'
Function to gather sizing information about an fsw sign or symbol
(string)
an fsw sign or symbol
SegmentInfo
:
information about the fsw string
fsw.info('AS14c20S27106L518x529S14c20481x471S27106503x489-P10Z2')
return {
minX: 481,
minY: 471,
width: 37,
height: 58,
lane: -1,
padding: 10,
segment: 'sign',
zoom: 2
}
Function to an object of column options with default values
(ColumnOptions)
object of column options
ColumnOptions
:
object of column options merged with column defaults
fsw.columnDefaultsMerge({height: 500,width:150})
return {
"height": 500,
"width": 150,
"offset": 50,
"pad": 20,
"margin": 5,
"dynamic": false,
"punctuation": {
"spacing": true,
"pad": 30,
"pull": true
},
"style": {
"detail": [
"black",
"white"
],
"zoom": 1
}
}
Function to transform an FSW text to an array of columns
(string)
FSW text of signs and punctuation
(ColumnOptions)
object of column options
{options: ColumnOptions, widths: Array<number>, columns: ColumnData}
:
object of column options, widths array, and column data
fsw.columns('AS14c20S27106M518x529S14c20481x471S27106503x489 AS18701S1870aS2e734S20500M518x533S1870a489x515S18701482x490S20500508x496S2e734500x468 S38800464x496', {height: 500,width:150})
return {
"options": {
"height": 500,
"width": 150,
"offset": 50,
"pad": 20,
"margin": 5,
"dynamic": false,
"punctuation": {
"spacing": true,
"pad": 30,
"pull": true
},
"style": {
"detail": [
"black",
"white"
],
"zoom": 1
}
},
"widths": [
150
],
"columns": [
[
{
"x": 56,
"y": 20,
"minX": 481,
"minY": 471,
"width": 37,
"height": 58,
"lane": 0,
"padding": 0,
"segment": "sign",
"text": "AS14c20S27106M518x529S14c20481x471S27106503x489",
"zoom": 1
},
{
"x": 57,
"y": 118,
"minX": 482,
"minY": 468,
"width": 36,
"height": 65,
"lane": 0,
"padding": 0,
"segment": "sign",
"text": "AS18701S1870aS2e734S20500M518x533S1870a489x515S18701482x490S20500508x496S2e734500x468",
"zoom": 1
},
{
"x": 39,
"y": 203,
"minX": 464,
"minY": 496,
"width": 72,
"height": 8,
"lane": 0,
"padding": 0,
"segment": "symbol",
"text": "S38800464x496",
"zoom": 1
}
]
]
}
Array of numbers for kinds of symbols: writing, location, and punctuation.
Array of numbers for categories of symbols: hand, movement, dynamics, head, trunk & limb, location, and punctuation.
Array of numbers for the 30 symbol groups.
Object of symbol ranges with starting and ending numbers.
{ all, writing, hand, movement, dynamic, head, hcenter, vcenter, trunk, limb, location, punctuation }
Type: object
Function to test if symbol is of a certain type.
boolean
:
is symbol of specified type
fsw.isType('S10000', 'hand')
return true
Array of colors associated with the seven symbol categories.
Function that returns the standardized color for a symbol.
(string)
an FSW symbol key
string
:
name of standardized color for symbol
fsw.colorize('S10000')
return '#0000CC'
The fswquery module contains functions for handling the FSW query language. Query Language definition
Object of regular expressions for FSW query strings
Type: object
(string)
: FSW symbol base with neither fill or rotation
(string)
: FSW coordinate of X and Y values separated by 'x'
(string)
: variance string for searching sign box
(string)
: FSW symbol key starting with 'S'
(string)
: FSW range starting with 'R'
(string)
: FSW symbol or range query string
(string)
: several FSW symbols and FSW ranges as a logical OR for searching
(string)
: a sequential list of FSW symbol keys starting with 'A'
(string)
: several groups of FSW lists, each group having a coordinate
(string)
: a query string to search prefix in order and the signbox with variance
Function to parse FSW query string to object
(string)
an FSW query string
QueryObject
:
elements of a of query string identified by regular expression
fswquery.parse('QAS10000S10500oS20500oR2fft304TS100uuR205t206oS207uu510x510V5-')
return {
"query": true,
"prefix": {
"required": true,
"parts": [
"S10000",
[
"or",
"S10500",
"S20500",
[
"2ff",
"304"
]
]
]
},
"signbox": [
{
"symbol": "S100uu"
},
{
"or": [
[
"205",
"206"
],
"S207uu"
],
"coord": [
510,
510
]
}
],
"variance": 5,
"style": true
}
Function to compose FSW query string from object
(QueryObject)
an object of query options
string
:
FSW query string
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-'
Function to convert an FSW sign to a query string
For the flags parameter, use one or more of the following.
string
:
FSW query string
fswquery.fsw2query('AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475', 'ASL')
return 'QAS10011S10019S2e704S2e748TS2e748483x510S10011501x466S2e704510x500S10019476x475'
Function to transform a range to a regular expression
(boolean?)
if true, the regular expression will match a hexidecimal range
string
:
a regular expression that matches a range
fswquery.range(500,750)
return '(([56][0-9][0-9])|(7[0-4][0-9])|(750))'
fswquery.range('100','10e',true)
return '10[0-9a-e]'
Function to transform an FSW query string to one or more regular expressions
(string)
an FSW query string
Array<string>
:
an array of one or more regular expressions
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})*'
]
Function that uses a query string to match signs from a string of text.
Array<string>
:
an array of FSW signs
fswquery.results('QAS10011T','AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475 AS15a21S15a07S21100S2df04S2df14M521x538S15a07494x488S15a21498x489S2df04498x517S2df14497x461S21100479x486 AS1f010S10018S20600M519x524S10018485x494S1f010490x494S20600481x476')
return [
'AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475'
]
Function that uses an FSW query string to match signs from multiple lines of text.
(string)
an FSW query string
(string)
multiple lines of text, each starting with an FSW sign
Array<string>
:
an array of lines of text, each starting with an FSW sign
fswquery.lines('QAS10011T',`AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475 line one
AS15a21S15a07S21100S2df04S2df14M521x538S15a07494x488S15a21498x489S2df04498x517S2df14497x461S21100479x486 line two
AS1f010S10018S20600M519x524S10018485x494S1f010490x494S20600481x476 line three`)
return [
'AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475 line one'
]
The swu module contains functions for handling SignWriting in Unicode (SWU) characters. SWU characters definition
Function to encode SWU characters using the UTF-16 escape format.
(string)
SWU characters
string
:
UTF-16 escape format
swu.encode('ņðĪðĪ')
return '\\uD8C0\\uDC01\\uD836\\uDD06\\uD836\\uDD06'
Function to decode UTF-16 escape format to SWU characters.
(string)
UTF-16 escape format
string
:
SWU characters
swu.decode('\\uD8C0\\uDC01\\uD836\\uDD06\\uD836\\uDD06')
return 'ņðĪðĪ'
Function to decompose an SWU character into UTF-16 surrogate pairs.
(string)
an SWU character
Array<string>
:
an array of UTF-16 surrogate pairs
swu.pair('ņ')
return ['D8C0', 'DC01']
Object of regular expressions for SWU strings in UTF-16
(string)
: regular expressions for a symbol
(string)
: regular expressions for a coordinate
(string)
: regular expressions for the sorting marker
(string)
: regular expression for a signbox marker
(string)
: regular expression for a sorting marker followed by one or more symbols
(string)
: regular expression for a symbol followed by a coordinate
(string)
: regular expression for a signbox marker, max coordinate and zero or more spatial symbols
(string)
: regular expression for an optional prefix followed by a signbox
(string)
: regular expression for a mandatory prefix followed by a signbox
Function to parse an swu symbol with optional coordinate and style string
(string)
an swu symbol
SymbolObject
:
elements of swu symbol
swu.parse.symbol('ņðĪðĪ-C')
return {
'symbol': 'ņ',
'coord': [500, 500],
'style': '-C'
}
Function to parse an swu sign with style string
(string)
an swu sign
SignObject
:
elements of swu sign
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'
}
Function to parse an swu text
(string)
an swu text
Array<string>
:
swu signs and punctuations
swu.parse.text('ð ņēĄņЧð ðĪðĪĢņēĄðĢģðĢĐņЧðĪðĢŧ ð ņĒņŦņņĄð ðĪðĪ§ņŦðĢŧðĪņĒðĢīðĢžņĄðĪðĪņðĪðĢĶ ņðĢĒðĪ')
return [
'ð ņēĄņЧð ðĪðĪĢņēĄðĢģðĢĐņЧðĪðĢŧ',
'ð ņĒņŦņņĄð ðĪðĪ§ņŦðĢŧðĪņĒðĢīðĢžņĄðĪðĪņðĪðĢĶ',
'ņðĢĒðĪ'
]
Function to compose an swu symbol with optional coordinate and style string
(SymbolObject)
an swu symbol object
string
:
an swu symbol string
swu.compose.symbol({
'symbol': 'ņ',
'coord': [500, 500],
'style': '-C'
})
return 'ņðĪðĪ-C'
Function to compose an swu sign with style string
(SignObject)
an swu sign object
string
:
an swu sign string
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'
Function to gather sizing information about an swu sign or symbol
(string)
an swu sign or symbol
SegmentInfo
:
information about the swu string
swu.info('ð ņēĄņЧð ðĪðĪĢņēĄðĢģðĢĐņЧðĪðĢŧ-P10Z2')
return {
minX: 481,
minY: 471,
width: 37,
height: 58,
lane: -1,
padding: 10,
segment: 'sign',
zoom: 2
}
Function to an object of column options with default values
(ColumnOptions)
object of column options
ColumnOptions
:
object of column options merged with column defaults
swu.columnDefaultsMerge({height: 500,width:150})
return {
"height": 500,
"width": 150,
"offset": 50,
"pad": 20,
"margin": 5,
"dynamic": false,
"punctuation": {
"spacing": true,
"pad": 30,
"pull": true
},
"style": {
"detail": [
"black",
"white"
],
"zoom": 1
}
}
Function to transform an SWU text to an array of columns
(string)
SWU text of signs and punctuation
(ColumnOptions)
object of column options
{options: ColumnOptions, widths: Array<number>, columns: ColumnData}
:
object of column options, widths array, and column data
swu.columns('ð ņēĄņЧð ðĪðĪĢņēĄðĢģðĢĐņЧðĪðĢŧ ð ņĒņŦņņĄð ðĪðĪ§ņŦðĢŧðĪņĒðĢīðĢžņĄðĪðĪņðĪðĢĶ ņðĢĒðĪ', {height: 500,width:150})
return {
"options": {
"height": 500,
"width": 150,
"offset": 50,
"pad": 20,
"margin": 5,
"dynamic": false,
"punctuation": {
"spacing": true,
"pad": 30,
"pull": true
},
"style": {
"detail": [
"black",
"white"
],
"zoom": 1
}
},
"widths": [
150
],
"columns": [
[
{
"x": 56,
"y": 20,
"minX": 481,
"minY": 471,
"width": 37,
"height": 58,
"lane": 0,
"padding": 0,
"segment": "sign",
"text": "ð ņēĄņЧð ðĪðĪĢņēĄðĢģðĢĐņЧðĪðĢŧ",
"zoom": 1
},
{
"x": 57,
"y": 118,
"minX": 482,
"minY": 468,
"width": 36,
"height": 65,
"lane": 0,
"padding": 0,
"segment": "sign",
"text": "ð ņĒņŦņņĄð ðĪðĪ§ņŦðĢŧðĪņĒðĢīðĢžņĄðĪðĪņðĪðĢĶ",
"zoom": 1
},
{
"x": 39,
"y": 203,
"minX": 464,
"minY": 496,
"width": 72,
"height": 8,
"lane": 0,
"padding": 0,
"segment": "symbol",
"text": "ņðĢĒðĪ",
"zoom": 1
}
]
]
}
Array of plane 4 code points for kinds of symbols: writing, location, and punctuation.
Type: array
Array of plane 4 code points for categories of symbols: hand, movement, dynamics, head, trunk & limb, location, and punctuation.
Type: array
Array of plane 4 code points for the 30 symbol groups.
Type: array
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 }
Type: object
Function to test if symbol is of a certain type.
boolean
:
is symbol of specified type
swu.isType('ņ', 'hand')
return true
Array of colors associated with the seven symbol categories.
Type: array
Function that returns the standardized color for a symbol.
(string)
an SWU symbol character
string
:
name of standardized color for symbol
swu.colorize('ņ')
return '#0000CC'
The swuquery module contains functions for handling the SWU query language. Query Language definition
Object of regular expressions for SWU query strings
Type: object
(string)
: SWU symbol
(string)
: SWU coordinate of X and Y number characters
(string)
: variance string for searching sign box
(string)
: SWU symbol character with ignore fill and rotation flags
(string)
: SWU range starting with 'R'
(string)
: SWU symbol or range query string
(string)
: several SWU symbols and SWU ranges as a logical OR for searching
(string)
: a sequential list of SWU symbol characters starting with SWU 'A' character
(string)
: several groups of SWU lists, each group having a coordinate
(string)
: a query string to search prefix in order and the signbox with variance
Function to parse SWU query string to object
(string)
an SWU query string
QueryObject
:
elements of an SWU query string
swuquery.parse('QAņRņņņĄTņRņņąðĪðĪV5-')
return {
query: true,
prefix: {
required: true,
parts: [
'ņ',
['ņ', 'ņ'],
'ņĄ'
]
},
signbox: [
{ symbol: 'ņ' },
{
range: ['ņ', 'ņą'],
coord: [500, 500]
}
],
variance: 5,
style: true
}
Function to compose SWU query string from object
(QueryObject)
an object of query options
string
:
SWU query string
swuquery.compose({
query: true,
prefix: {
required: true,
parts: [
'ņ',
['ņ', 'ņ'],
'ņĄ'
]
},
signbox: [
{ symbol: 'ņ' },
{
range: ['ņ', 'ņą'],
coord: [500, 500]
}
],
variance: 5,
style: true
})
return 'QAņRņņņĄTņRņņąðĪðĪV5-'
Function to convert an SWU sign to a query string
For the flags parameter, use one or more of the following.
string
:
SWU query string
swuquery.swu2query('ð ņņņĨņĐð ðĪðĪĐņĐðĢĩðĪņðĪðĢĪņĨðĪðĪņðĢŪðĢ', 'ASL')
return 'QAņņņĨņĐTņĐðĢĩðĪņðĪðĢĪņĨðĪðĪņðĢŪðĢ'
Function to transform a range of SWU characters to a regular expression
string
:
a regular expression that matches a range of SWU characters
swuquery.range('ņ', 'ņĄ')
return '\uD8C0[\uDC01-\uDDE1]'
swuquery.range('ðĢ', 'ðĪļ')
return '\uD836[\uDCD4-\uDD38]'
Function to transform an SWU symbol with fill and rotation flags to a regular expression
(string)
an SWU character with optional flags of 'f' for any fill and 'r' for any rotation
string
:
a regular expression that matches one or more ranges of SWU symbols
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]'
Function to transform an SWU query string to one or more regular expressions
(string)
an SWU query string
Array<string>
:
an array of one or more regular expressions
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})*'
]
Function that uses a query string to match signs from a string of text.
Array<string>
:
an array of SWU signs
swuquery.results('QAņT','ð ņņņĨņĐð ðĪðĪĐņĐðĢĩðĪņðĪðĢĪņĨðĪðĪņðĢŪðĢ ð ņĒņņĄņĨņĩð ðĪðĪŽņðĪðĢšņĒðĪðĢŧņĨðĪðĪņĩðĪðĢņĄðĢąðĢļ ð ņ
Ļņņð ðĪðĪņðĢ·ðĪņ
ĻðĢžðĪņðĢģðĢŪ')
return [
'ð ņņņĨņĐð ðĪðĪĐņĐðĢĩðĪņðĪðĢĪņĨðĪðĪņðĢŪðĢ'
]
Function that uses an SWU query string to match signs from multiple lines of text.
(string)
an SWU query string
(string)
multiple lines of text, each starting with an SWU sign
Array<string>
:
an array of lines of text, each starting with an SWU sign
swuquery.lines('QAņT',`ð ņņņĨņĐð ðĪðĪĐņĐðĢĩðĪņðĪðĢĪņĨðĪðĪņðĢŪðĢ line one
ð ņĒņņĄņĨņĩð ðĪðĪŽņðĪðĢšņĒðĪðĢŧņĨðĪðĪņĩðĪðĢņĄðĢąðĢļ line two
ð ņ
Ļņņð ðĪðĪņðĢ·ðĪņ
ĻðĢžðĪņðĢģðĢŪ line three`)
return [
'ð ņņņĨņĐð ðĪðĪĐņĐðĢĩðĪņðĪðĢĪņĨðĪðĪņðĢŪðĢ line one'
]
The style module contains regular expressions and functions for parsing and composing style strings. Style string definition
The elements of a style string
Type: object
(boolean?)
: boolean to use standardized colors for symbol groups
(number?)
: integer value for padding around symbol or sign
(string?)
: css name or hex color for background
(number?)
: decimal value for zoom level
(string?)
: list of class names separated with spaces used for SVG
(string?)
: id name used for SVG
Object of regular expressions for style strings
Type: object
(string)
: regular expression for colorize section
(string)
: regular expression for color hex values with 3 or 6 characters
(string)
: regular expression for css color name
(string)
: regular expression for padding section
(string)
: regular expression for zoom section
(string)
: regular expression for class name definition
(string)
: regular expression for id definition
(string)
: regular expression for color hex or color name
(string)
: regular expression for single color entry
(string)
: regular expression for double color entry
(string)
: regular expression for background section
(string)
: regular expression for color details for line and optional fill
(string)
: regular expression for color details for individual symbols
(string)
: regular expression for one or more class names
(string)
: full regular expression for style string
Function to parse style string to object
(string)
a style string
StyleObject
:
elements of style string
style.parse('-CP10G_blue_D_red,Cyan_')
return {
'colorize': true,
'padding': 10,
'background': 'blue',
'detail': ['red', 'Cyan']
}
Function to compose style string from object
(StyleObject)
an object of style options
string
:
style string
style.compose({
'colorize': true,
'padding': 10,
'background': 'blue',
'detail': ['red', 'Cyan'],
'zoom': 1.1,
'detailsym': [
{
'index': 1,
'detail': ['#ff00ff']
},
{
'index': 2,
'detail': ['yellow', 'green']
}
],
'classes': 'primary blinking',
'id': 'cursor'
})
return '-CP10G_blue_D_red,Cyan_Z1.1-D01_ff00ff_D02_yellow,green_-primary blinking!cursor!'
Function to merge style objects
(StyleObject)
a style object
(StyleObject)
a style object
StyleObject
:
a style object
style.merge({'colorize': true},{zoom:2})
return {
'colorize': true,
'zoom': 2
}
Function to convert rgb color to hex or "transparent" if below tolerance
string
:
a hex color or "transparent"
style.rgb2hex("rgb(255,255,255)")
return "ffffff"
style.rgb2hex("rgba(255,255,255,0.5)",0.5)
return "transparent"
Function to merge color with background based on alpha transparency
string
:
a hex color or "transparent"
style.rgba2hex("rgba(255,255,255,0.5)","rgb(0,0,0)")
return "7f7f7f"
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
Function to convert an SWU structural marker to FSW equivalent
(string)
character for SWU structural marker
string
:
FSW structural marker
convert.swu2mark('ð ')
return 'A'
Function to convert an FSW structural marker to SWU equivalent
(string)
character for FSW structural marker
string
:
SWU structural marker
convert.mark2swu('A')
return 'ð '
Function to convert an SWU number character to an integer
(string)
SWU number character
number
:
Integer value for number
convert.swu2num('ðĪ')
return 500
Function to convert a number to an SWU number character
(number)
Integer value for number
string
:
SWU number character
convert.num2swu(500)
return 'ðĪ'
Function to convert two SWU number characters to an array of x,y integers
(string)
Two SWU number character
Array<number>
:
Array of x,y integers
convert.swu2coord('ðĪðĪ')
return [500, 500]
Function to convert an array of x,y integers to two SWU number characters
string
:
Two SWU number character
convert.coord2swu([500, 500])
return 'ðĪðĪ'
Function to convert an FSW coordinate string to an array of x,y integers
(string)
An FSW coordinate string
Array<number>
:
Array of x,y integers
convert.fsw2coord('500x500')
return [500, 500]
Function to convert an array of x,y integers to an FSW coordinate string
string
:
An FSW coordinate string
convert.coord2fsw([500, 500])
return '500x500'
Function to convert an SWU symbol character to a code point on plane 4
(string)
SWU symbol character
number
:
Code point on plane 4
convert.swu2code('ņ')
return 0x40001
Function to convert a code point on plane 4 to an SWU symbol character
(number)
Code point on plane 4
string
:
SWU symbol character
convert.code2swu(0x40001)
return 'ņ'
Function to convert an SWU symbol character to a 16-bit ID
(string)
SWU symbol character
number
:
16-bit ID
convert.swu2id('ņ')
return 1
Function to convert a 16-bit ID to an SWU symbol character
(number)
16-bit ID
string
:
SWU symbol character
convert.id2swu(1)
return 'ņ'
Function to convert an FSW symbol key to a 16-bit ID
(string)
FSW symbol key
number
:
16-bit ID
convert.key2id('S10000')
return 1
Function to convert a 16-bit ID to an FSW symbol key
(number)
16-bit ID
string
:
FSW symbol key
convert.id2key(1)
return 'S10000'
Function to convert an SWU symbol character to an FSW symbol key
(string)
SWU symbol character
string
:
FSW symbol key
convert.swu2key('ņ')
return 'S10000'
Function to convert an FSW symbol key to an SWU symbol character
(string)
FSW symbol key
string
:
SWU symbol character
convert.key2swu('S10000')
return 'ņ'
Function to convert SWU text to FSW text
(string)
SWU text
string
:
FSW text
convert.swu2fsw('ð ņņņĨņĐð ðĪðĪĐņĐðĢĩðĪņðĪðĢĪņĨðĪðĪņðĢŪðĢ')
return 'AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475'
Function to convert FSW text to SWU text
(string)
FSW text
string
:
SWU text
convert.fsw2swu('AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475')
return 'ð ņņņĨņĐð ðĪðĪĐņĐðĢĩðĪņðĪðĢĪņĨðĪðĪņðĢŪðĢ'
An array of symbol IDs in minimized format such as "101011"
Function to convert base or full symid Min to symid Max
(string)
Symbol ID minimized
string
:
Symbol ID maximized
convert.symidMax('101011')
return '01-01-001-01'
convert.symidMax('101011616')
return '01-01-001-01-06-16'
Function to convert base or full symid Max to symid Min
(string)
Symbol ID maximized
string
:
Symbol ID minimized
convert.symidMin('01-01-001-01')
return '101011'
convert.symidMin('01-01-001-01-06-16')
return '101011616'
Function to convert base or full symid to key
(string)
Symbol ID
string
:
Symbol key
convert.symid2key('01-01-001-01')
return 'S100'
convert.symid2key('01-01-001-01-06-16')
return 'S1005f'
Function to convert base or full key to symid
(string)
Symbol key
string
:
Symbol ID
convert.key2symid('S100')
return '01-01-001-01'
convert.key2symid('S1005f')
return '01-01-001-01-06-16'
Object of query elements with regular expression identification.
Type: object
(boolean)
: required true for query object
(object?)
: an object for prefix elements
(Array<(QuerySignboxSymbol | QuerySignboxRange | QuerySignboxOr)>?)
: array of objects for symbols, ranges, and list of symbols or ranges, with optional coordinates
(number?)
: amount that x or y coordinates can vary and find a match, defaults to 20
(boolean?)
: boolean value for including style string in matches
Type: object
Type: object
Type: object
Type: object
(number?)
: the height of the columns
(number?)
: the widths of the columns
(number?)
: the lane offset for left and right lanes
(number?)
: amount of padding before and after signs as well as at top, left, and right of columns
(number?)
: amount of space at bottom of column that is not available
(boolean?)
: enables variable width columns
(string?)
: background color for columns
(StyleObject?)
: an object of style options
(object?)
: an object of punctuation options
punctuation.spacing
boolean?
enables special spacing for punctuation with no space above and custom space below
punctuation.pad
number?
the amount of spacing after a punctuation if punctuation spacing is enabled
punctuation.pull
boolean?
prevents line breaks before punctuation by reducing spacing between signs in a column
Type: Array<ColumnSegment>
Type: object
(number)
: the x position in the column
(number)
: the y position in the column
(number)
: the min x value within the segment
(number)
: the min y value within the segment
(number)
: the width of the text segment
(number)
: the height of the text segment
(number)
: Left as -1, Middle as 0, Right as 1
(number)
: the padding of the text segment affects colored background
(string)
: "sign" or "symbol"
(string)
: the text of the sign or symbol with optional style string
(number)
: the zoom size of the segment
The elements of a symbol string
Type: object
The elements of a sign string
Type: object
Type: object
(number)
: the min x value within the segment
(number)
: the min y value within the segment
(number)
: the width of the text segment
(number)
: the height of the text segment
(number)
: Left as -1, Middle as 0, Right as 1
(number)
: the padding of the text segment affects colored background
(string)
: "sign" or "symbol"
(number)
: the zoom size of the segment