1
0

Move column-level attributes to key-level

This commit is contained in:
Bán Dénes 2021-12-18 18:37:26 +01:00
parent 86c00eb62d
commit 73045e4754
19 changed files with 1290 additions and 306 deletions

View File

@ -0,0 +1,13 @@
points.zones:
preprocessor:
anchor:
shift: [u, 0]
rows:
row1: {}
row2: {}
columns:
col1: {}
col2:
rows:
row1: {}
row2: $unset

View File

@ -24,7 +24,7 @@ const render_zone = exports._render_zone = (zone_name, zone, anchor, global_key,
const cols = a.sane(zone.columns || {}, `points.zones.${zone_name}.columns`, 'object')()
const zone_wide_rows = a.sane(zone.rows || {}, `points.zones.${zone_name}.rows`, 'object')()
for (const [key, val] of Object.entries(zone_wide_rows)) {
zone_wide_rows[key] = a.sane(val || {}, `points.zones.${zone_name}.rows.${key}`, 'object')()
zone_wide_rows[key] = val || {} // no check yet, as it will be extended later
}
const zone_wide_key = a.sane(zone.key || {}, `points.zones.${zone_name}.key`, 'object')()
@ -32,11 +32,14 @@ const render_zone = exports._render_zone = (zone_name, zone, anchor, global_key,
const points = {}
const rotations = []
const zone_anchor = anchor.clone()
// transferring the anchor rotation to "real" rotations
rotations.push({
angle: anchor.r,
origin: anchor.p
angle: zone_anchor.r,
origin: zone_anchor.p
})
// and now clear it from the anchor so that we don't apply it twice
zone_anchor.r = 0
// column layout
@ -53,47 +56,15 @@ const render_zone = exports._render_zone = (zone_name, zone, anchor, global_key,
a.unexpected(
col,
`points.zones.${zone_name}.columns.${col_name}`,
['stagger', 'spread', 'rotate', 'origin', 'rows', 'row_overrides', 'key']
['rows', 'key']
)
col.stagger = a.sane(
col.stagger || 0,
`points.zones.${zone_name}.columns.${col_name}.stagger`,
'number'
)(units)
col.spread = a.sane(
col.spread !== undefined ? col.spread : (first_col ? 0 : 'u'),
`points.zones.${zone_name}.columns.${col_name}.spread`,
'number'
)(units)
col.rotate = a.sane(
col.rotate || 0,
`points.zones.${zone_name}.columns.${col_name}.rotate`,
'number'
)(units)
col.origin = a.xy(
col.origin || [0, 0],
`points.zones.${zone_name}.columns.${col_name}.origin`
)(units)
let override = false
col.rows = a.sane(
col.rows || {},
`points.zones.${zone_name}.columns.${col_name}.rows`,
'object'
)()
if (col.row_overrides) {
override = true
col.rows = a.sane(
col.row_overrides,
`points.zones.${zone_name}.columns.${col_name}.row_overrides`,
'object'
)()
}
for (const [key, val] of Object.entries(col.rows)) {
col.rows[key] = a.sane(
val || {},
`points.zones.${zone_name}.columns.${col_name}.rows.${key}`,
'object'
)()
col.rows[key] = val || {} // again, no check yet, as it will be extended later
}
col.key = a.sane(
col.key || {},
@ -106,42 +77,25 @@ const render_zone = exports._render_zone = (zone_name, zone, anchor, global_key,
col.name = col_name
// combining row data from zone-wide defs and col-specific defs
// (while also handling potential overrides)
const actual_rows = override ? Object.keys(col.rows)
: Object.keys(prep.extend(zone_wide_rows, col.rows))
const actual_rows = Object.keys(prep.extend(zone_wide_rows, col.rows))
if (!actual_rows.length) {
actual_rows.push('default')
}
// setting up column-level anchor
anchor.x += col.spread
anchor.y += col.stagger
const col_anchor = anchor.clone()
// clear potential rotations, as they will get re-applied anyway
// and we don't want to apply them twice...
col_anchor.r = 0
// applying col-level rotation (cumulatively, for the next columns as well)
if (col.rotate) {
push_rotation(
rotations,
col.rotate,
col_anchor.clone().shift(col.origin, false).p
)
}
// getting key config through the 5-level extension
const keys = []
const default_key = {
stagger: units.$default_stagger,
spread: first_col ? 0 : units.$default_spread,
splay: units.$default_splay,
origin: [0, 0],
shift: [0, 0],
rotate: 0,
padding: 'u',
width: 1,
height: 1,
width: units.$default_width,
height: units.$default_height,
padding: units.$default_padding,
skip: false,
asym: 'both'
}
@ -156,7 +110,14 @@ const render_zone = exports._render_zone = (zone_name, zone, anchor, global_key,
)
key.name = key.name || `${zone_name}_${col_name}_${row}`
key.col = col
key.row = row
key.colrow = `${col_name}_${row}`
key.stagger = a.sane(key.stagger, `${key.name}.shift`, 'number')(units)
key.spread = a.sane(key.spread, `${key.name}.spread`, 'number')(units)
key.splay = a.sane(key.splay, `${key.name}.splay`, 'number')(units)
key.origin = a.xy(key.origin, `${key.name}.origin`)(units)
key.shift = a.xy(key.shift, `${key.name}.shift`)(units)
key.rotate = a.sane(key.rotate, `${key.name}.rotate`, 'number')(units)
key.width = a.sane(key.width, `${key.name}.width`, 'number')(units)
@ -164,11 +125,25 @@ const render_zone = exports._render_zone = (zone_name, zone, anchor, global_key,
key.padding = a.sane(key.padding, `${key.name}.padding`, 'number')(units)
key.skip = a.sane(key.skip, `${key.name}.skip`, 'boolean')()
key.asym = a.in(key.asym, `${key.name}.asym`, ['left', 'right', 'both'])
key.col = col
key.row = row
keys.push(key)
}
// setting up column-level anchor
zone_anchor.x += keys[0].spread
zone_anchor.y += keys[0].stagger
const col_anchor = zone_anchor.clone()
// applying col-level rotation (cumulatively, for the next columns as well)
if (keys[0].splay) {
push_rotation(
rotations,
keys[0].splay,
col_anchor.clone().shift(keys[0].origin, false).p
)
}
// actually laying out keys
for (const key of keys) {
@ -227,15 +202,12 @@ exports.parse = (config, units) => {
const global_rotate = a.sane(config.rotate || 0, 'points.rotate', 'number')(units)
const global_mirror = config.mirror
let points = {}
let mirrored_points = {}
let all_points = {}
// rendering zones
for (let [zone_name, zone] of Object.entries(zones)) {
// extracting keys that are handled here, not at the zone render level
const anchor = anchor_lib.parse(zone.anchor || {}, `points.zones.${zone_name}.anchor`, all_points)(units)
const anchor = anchor_lib.parse(zone.anchor || {}, `points.zones.${zone_name}.anchor`, points)(units)
const rotate = a.sane(zone.rotate || 0, `points.zones.${zone_name}.rotate`, 'number')(units)
const mirror = zone.mirror
delete zone.anchor
@ -261,24 +233,21 @@ exports.parse = (config, units) => {
// adding new points so that they can be referenced from now on
points = Object.assign(points, new_points)
all_points = Object.assign(all_points, points)
// per-zone mirroring for the new keys
const axis = parse_axis(mirror, `points.zones.${zone_name}.mirror`, all_points, units)
const axis = parse_axis(mirror, `points.zones.${zone_name}.mirror`, points, units)
if (axis) {
const mirrored_points = {}
for (const new_point of Object.values(new_points)) {
const [mname, mp] = perform_mirror(new_point, axis)
if (mp) {
mirrored_points[mname] = mp
all_points[mname] = mp
}
}
points = Object.assign(points, mirrored_points)
}
}
// merging regular and early-mirrored points
points = Object.assign(points, mirrored_points)
// applying global rotation
for (const point of Object.values(points)) {
if (global_rotate) {
@ -297,8 +266,6 @@ exports.parse = (config, units) => {
}
}
}
// merging the global-mirrored points as well
points = Object.assign(points, global_mirrored_points)
// removing temporary points
@ -314,11 +281,9 @@ exports.parse = (config, units) => {
exports.visualize = (points, units) => {
const models = {}
const x_unit = units.visual_x || (units.u - 1)
const y_unit = units.visual_y || (units.u - 1)
for (const [pname, p] of Object.entries(points)) {
const w = p.meta.width * x_unit
const h = p.meta.height * y_unit
const w = p.meta.width
const h = p.meta.height
const rect = u.rect(w, h, [-w/2, -h/2])
models[pname] = p.position(rect)
}

View File

@ -5,7 +5,13 @@ const default_units = {
U: 19.05,
u: 19,
cx: 18,
cy: 17
cy: 17,
$default_stagger: 0,
$default_spread: 'u',
$default_splay: 0,
$default_height: 'u-1',
$default_width: 'u-1',
$default_padding: 'u'
}
exports.parse = (config = {}) => {

View File

@ -3,25 +3,25 @@ matrix_col_row:
'y': 0
r: 0
meta:
stagger: 0
spread: 0
splay: 0
origin:
- 0
- 0
shift:
- 0
- 0
rotate: 0
width: 18
height: 18
padding: 19
width: 1
height: 1
skip: false
asym: both
name: matrix_col_row
colrow: col_row
col:
stagger: 0
spread: 0
rotate: 0
origin:
- 0
- 0
rows: {}
key: {}
name: col
row: row
colrow: col_row

View File

@ -2,4 +2,10 @@ U: 19.05
u: 19
cx: 18
cy: 17
$default_stagger: 0
$default_spread: 19
$default_splay: 0
$default_height: 18
$default_width: 18
$default_padding: 19
a: 47

View File

@ -3,25 +3,25 @@ matrix_col_row:
'y': 0
r: 0
meta:
stagger: 0
spread: 0
splay: 0
origin:
- 0
- 0
shift:
- 0
- 0
rotate: 0
width: 18
height: 18
padding: 19
width: 1
height: 1
skip: false
asym: both
name: matrix_col_row
colrow: col_row
col:
stagger: 0
spread: 0
rotate: 0
origin:
- 0
- 0
rows: {}
key: {}
name: col
row: row
colrow: col_row

View File

@ -2,3 +2,9 @@ U: 19.05
u: 19
cx: 18
cy: 17
$default_stagger: 0
$default_spread: 19
$default_splay: 0
$default_height: 18
$default_width: 18
$default_padding: 19

View File

@ -3,10 +3,10 @@ points:
matrix:
columns:
left:
right:
right.key:
stagger: 5
spread: 25
rotate: 5
splay: 5
origin: [-9, -9]
rows:
bottom:

View File

@ -0,0 +1,242 @@
0
SECTION
2
HEADER
9
$INSUNITS
70
4
0
ENDSEC
0
SECTION
2
TABLES
0
TABLE
2
LTYPE
0
LTYPE
72
65
70
64
2
CONTINUOUS
3
______
73
0
40
0
0
ENDTAB
0
TABLE
2
LAYER
0
ENDTAB
0
ENDSEC
0
SECTION
2
ENTITIES
0
LINE
8
0
10
-9
20
9
11
9
21
9
0
LINE
8
0
10
9
20
9
11
9
21
-9
0
LINE
8
0
10
9
20
-9
11
-9
21
-9
0
LINE
8
0
10
-9
20
-9
11
-9
21
9
0
LINE
8
0
10
-9
20
28
11
9
21
28
0
LINE
8
0
10
9
20
28
11
9
21
10
0
LINE
8
0
10
9
20
10
11
-9
21
10
0
LINE
8
0
10
-9
20
10
11
-9
21
28
0
LINE
8
0
10
14.4311966
20
13.9315046
11
32.3627012
21
15.500308
0
LINE
8
0
10
32.3627012
20
15.500308
11
33.9315046
21
-2.4311966
0
LINE
8
0
10
33.9315046
20
-2.4311966
11
16
21
-4
0
LINE
8
0
10
16
20
-4
11
14.4311966
21
13.9315046
0
LINE
8
0
10
12.7752375
20
32.8592038
11
30.7067421
21
34.4280072
0
LINE
8
0
10
30.7067421
20
34.4280072
11
32.2755455
21
16.4965026
0
LINE
8
0
10
32.2755455
20
16.4965026
11
14.3440409
21
14.9276992
0
LINE
8
0
10
14.3440409
20
14.9276992
11
12.7752375
21
32.8592038
0
ENDSEC
0
EOF

View File

@ -4,31 +4,31 @@
"y": 0,
"r": 0,
"meta": {
"stagger": 0,
"spread": 0,
"splay": 0,
"origin": [
0,
0
],
"shift": [
0,
0
],
"rotate": 0,
"width": 18,
"height": 18,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_left_bottom",
"colrow": "left_bottom",
"col": {
"stagger": 0,
"spread": 0,
"rotate": 0,
"origin": [
0,
0
],
"rows": {},
"key": {},
"name": "left"
},
"row": "bottom"
"row": "bottom",
"colrow": "left_bottom"
}
},
"matrix_left_top": {
@ -36,31 +36,31 @@
"y": 19,
"r": 0,
"meta": {
"stagger": 0,
"spread": 0,
"splay": 0,
"origin": [
0,
0
],
"shift": [
0,
0
],
"rotate": 0,
"width": 18,
"height": 18,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_left_top",
"colrow": "left_top",
"col": {
"stagger": 0,
"spread": 0,
"rotate": 0,
"origin": [
0,
0
],
"rows": {},
"key": {},
"name": "left"
},
"row": "top"
"row": "top",
"colrow": "left_top"
}
},
"matrix_right_bottom": {
@ -68,31 +68,39 @@
"y": 5.750154,
"r": 5,
"meta": {
"stagger": 5,
"spread": 25,
"splay": 5,
"origin": [
-9,
-9
],
"shift": [
0,
0
],
"rotate": 0,
"width": 18,
"height": 18,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_right_bottom",
"colrow": "right_bottom",
"col": {
"stagger": 5,
"spread": 25,
"rotate": 5,
"origin": [
-9,
-9
],
"key": {
"stagger": 5,
"spread": 25,
"splay": 5,
"origin": [
-9,
-9
]
},
"rows": {},
"key": {},
"name": "right"
},
"row": "bottom"
"row": "bottom",
"colrow": "right_bottom"
}
},
"matrix_right_top": {
@ -100,31 +108,39 @@
"y": 24.6778532,
"r": 5,
"meta": {
"stagger": 5,
"spread": 25,
"splay": 5,
"origin": [
-9,
-9
],
"shift": [
0,
0
],
"rotate": 0,
"width": 18,
"height": 18,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_right_top",
"colrow": "right_top",
"col": {
"stagger": 5,
"spread": 25,
"rotate": 5,
"origin": [
-9,
-9
],
"key": {
"stagger": 5,
"spread": 25,
"splay": 5,
"origin": [
-9,
-9
]
},
"rows": {},
"key": {},
"name": "right"
},
"row": "top"
"row": "top",
"colrow": "right_top"
}
}
}

View File

@ -0,0 +1,242 @@
0
SECTION
2
HEADER
9
$INSUNITS
70
4
0
ENDSEC
0
SECTION
2
TABLES
0
TABLE
2
LTYPE
0
LTYPE
72
65
70
64
2
CONTINUOUS
3
______
73
0
40
0
0
ENDTAB
0
TABLE
2
LAYER
0
ENDTAB
0
ENDSEC
0
SECTION
2
ENTITIES
0
LINE
8
0
10
-9
20
9
11
9
21
9
0
LINE
8
0
10
9
20
9
11
9
21
-9
0
LINE
8
0
10
9
20
-9
11
-9
21
-9
0
LINE
8
0
10
-9
20
-9
11
-9
21
9
0
LINE
8
0
10
-9
20
28
11
9
21
28
0
LINE
8
0
10
9
20
28
11
9
21
10
0
LINE
8
0
10
9
20
10
11
-9
21
10
0
LINE
8
0
10
-9
20
10
11
-9
21
28
0
LINE
8
0
10
10
20
9
11
28
21
9
0
LINE
8
0
10
28
20
9
11
28
21
-9
0
LINE
8
0
10
28
20
-9
11
10
21
-9
0
LINE
8
0
10
10
20
-9
11
10
21
9
0
LINE
8
0
10
10
20
28
11
28
21
28
0
LINE
8
0
10
28
20
28
11
28
21
10
0
LINE
8
0
10
28
20
10
11
10
21
10
0
LINE
8
0
10
10
20
10
11
10
21
28
0
ENDSEC
0
EOF

View File

@ -4,31 +4,31 @@
"y": 0,
"r": 0,
"meta": {
"stagger": 0,
"spread": 0,
"splay": 0,
"origin": [
0,
0
],
"shift": [
0,
0
],
"rotate": 0,
"width": 18,
"height": 18,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_left_bottom",
"colrow": "left_bottom",
"col": {
"stagger": 0,
"spread": 0,
"rotate": 0,
"origin": [
0,
0
],
"rows": {},
"key": {},
"name": "left"
},
"row": "bottom"
"row": "bottom",
"colrow": "left_bottom"
}
},
"matrix_left_top": {
@ -36,31 +36,31 @@
"y": 19,
"r": 0,
"meta": {
"stagger": 0,
"spread": 0,
"splay": 0,
"origin": [
0,
0
],
"shift": [
0,
0
],
"rotate": 0,
"width": 18,
"height": 18,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_left_top",
"colrow": "left_top",
"col": {
"stagger": 0,
"spread": 0,
"rotate": 0,
"origin": [
0,
0
],
"rows": {},
"key": {},
"name": "left"
},
"row": "top"
"row": "top",
"colrow": "left_top"
}
},
"matrix_right_bottom": {
@ -68,31 +68,31 @@
"y": 0,
"r": 0,
"meta": {
"stagger": 0,
"spread": 19,
"splay": 0,
"origin": [
0,
0
],
"shift": [
0,
0
],
"rotate": 0,
"width": 18,
"height": 18,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_right_bottom",
"colrow": "right_bottom",
"col": {
"stagger": 0,
"spread": 19,
"rotate": 0,
"origin": [
0,
0
],
"rows": {},
"key": {},
"name": "right"
},
"row": "bottom"
"row": "bottom",
"colrow": "right_bottom"
}
},
"matrix_right_top": {
@ -100,31 +100,31 @@
"y": 19,
"r": 0,
"meta": {
"stagger": 0,
"spread": 19,
"splay": 0,
"origin": [
0,
0
],
"shift": [
0,
0
],
"rotate": 0,
"width": 18,
"height": 18,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_right_top",
"colrow": "right_top",
"col": {
"stagger": 0,
"spread": 19,
"rotate": 0,
"origin": [
0,
0
],
"rows": {},
"key": {},
"name": "right"
},
"row": "top"
"row": "top",
"colrow": "right_top"
}
}
}

View File

@ -0,0 +1,98 @@
0
SECTION
2
HEADER
9
$INSUNITS
70
4
0
ENDSEC
0
SECTION
2
TABLES
0
TABLE
2
LTYPE
0
LTYPE
72
65
70
64
2
CONTINUOUS
3
______
73
0
40
0
0
ENDTAB
0
TABLE
2
LAYER
0
ENDTAB
0
ENDSEC
0
SECTION
2
ENTITIES
0
LINE
8
0
10
-9
20
9
11
9
21
9
0
LINE
8
0
10
9
20
9
11
9
21
-9
0
LINE
8
0
10
9
20
-9
11
-9
21
-9
0
LINE
8
0
10
-9
20
-9
11
-9
21
9
0
ENDSEC
0
EOF

View File

@ -4,31 +4,31 @@
"y": 0,
"r": 0,
"meta": {
"stagger": 0,
"spread": 0,
"splay": 0,
"origin": [
0,
0
],
"shift": [
0,
0
],
"rotate": 0,
"width": 18,
"height": 18,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_default_default",
"colrow": "default_default",
"col": {
"stagger": 0,
"spread": 0,
"rotate": 0,
"origin": [
0,
0
],
"rows": {},
"key": {},
"name": "default"
},
"row": "default"
"row": "default",
"colrow": "default_default"
}
}
}

View File

@ -1,16 +1,15 @@
points:
zones:
matrix:
columns:
left:
middle:
rows:
top:
right:
stagger: u
row_overrides:
home:
top:
points.zones.matrix:
columns:
left:
middle:
rows:
bottom:
home:
top:
right:
key.stagger: u
rows:
bottom: $unset
home:
top:
rows:
bottom:
home:

View File

@ -0,0 +1,386 @@
0
SECTION
2
HEADER
9
$INSUNITS
70
4
0
ENDSEC
0
SECTION
2
TABLES
0
TABLE
2
LTYPE
0
LTYPE
72
65
70
64
2
CONTINUOUS
3
______
73
0
40
0
0
ENDTAB
0
TABLE
2
LAYER
0
ENDTAB
0
ENDSEC
0
SECTION
2
ENTITIES
0
LINE
8
0
10
-9
20
9
11
9
21
9
0
LINE
8
0
10
9
20
9
11
9
21
-9
0
LINE
8
0
10
9
20
-9
11
-9
21
-9
0
LINE
8
0
10
-9
20
-9
11
-9
21
9
0
LINE
8
0
10
-9
20
28
11
9
21
28
0
LINE
8
0
10
9
20
28
11
9
21
10
0
LINE
8
0
10
9
20
10
11
-9
21
10
0
LINE
8
0
10
-9
20
10
11
-9
21
28
0
LINE
8
0
10
10
20
9
11
28
21
9
0
LINE
8
0
10
28
20
9
11
28
21
-9
0
LINE
8
0
10
28
20
-9
11
10
21
-9
0
LINE
8
0
10
10
20
-9
11
10
21
9
0
LINE
8
0
10
10
20
28
11
28
21
28
0
LINE
8
0
10
28
20
28
11
28
21
10
0
LINE
8
0
10
28
20
10
11
10
21
10
0
LINE
8
0
10
10
20
10
11
10
21
28
0
LINE
8
0
10
10
20
47
11
28
21
47
0
LINE
8
0
10
28
20
47
11
28
21
29
0
LINE
8
0
10
28
20
29
11
10
21
29
0
LINE
8
0
10
10
20
29
11
10
21
47
0
LINE
8
0
10
29
20
28
11
47
21
28
0
LINE
8
0
10
47
20
28
11
47
21
10
0
LINE
8
0
10
47
20
10
11
29
21
10
0
LINE
8
0
10
29
20
10
11
29
21
28
0
LINE
8
0
10
29
20
47
11
47
21
47
0
LINE
8
0
10
47
20
47
11
47
21
29
0
LINE
8
0
10
47
20
29
11
29
21
29
0
LINE
8
0
10
29
20
29
11
29
21
47
0
ENDSEC
0
EOF

View File

@ -4,31 +4,31 @@
"y": 0,
"r": 0,
"meta": {
"stagger": 0,
"spread": 0,
"splay": 0,
"origin": [
0,
0
],
"shift": [
0,
0
],
"rotate": 0,
"width": 18,
"height": 18,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_left_bottom",
"colrow": "left_bottom",
"col": {
"stagger": 0,
"spread": 0,
"rotate": 0,
"origin": [
0,
0
],
"rows": {},
"key": {},
"name": "left"
},
"row": "bottom"
"row": "bottom",
"colrow": "left_bottom"
}
},
"matrix_left_home": {
@ -36,31 +36,31 @@
"y": 19,
"r": 0,
"meta": {
"stagger": 0,
"spread": 0,
"splay": 0,
"origin": [
0,
0
],
"shift": [
0,
0
],
"rotate": 0,
"width": 18,
"height": 18,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_left_home",
"colrow": "left_home",
"col": {
"stagger": 0,
"spread": 0,
"rotate": 0,
"origin": [
0,
0
],
"rows": {},
"key": {},
"name": "left"
},
"row": "home"
"row": "home",
"colrow": "left_home"
}
},
"matrix_middle_bottom": {
@ -68,33 +68,33 @@
"y": 0,
"r": 0,
"meta": {
"stagger": 0,
"spread": 19,
"splay": 0,
"origin": [
0,
0
],
"shift": [
0,
0
],
"rotate": 0,
"width": 18,
"height": 18,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_middle_bottom",
"colrow": "middle_bottom",
"col": {
"rows": {
"top": {}
},
"stagger": 0,
"spread": 19,
"rotate": 0,
"origin": [
0,
0
],
"key": {},
"name": "middle"
},
"row": "bottom"
"row": "bottom",
"colrow": "middle_bottom"
}
},
"matrix_middle_home": {
@ -102,33 +102,33 @@
"y": 19,
"r": 0,
"meta": {
"stagger": 0,
"spread": 19,
"splay": 0,
"origin": [
0,
0
],
"shift": [
0,
0
],
"rotate": 0,
"width": 18,
"height": 18,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_middle_home",
"colrow": "middle_home",
"col": {
"rows": {
"top": {}
},
"stagger": 0,
"spread": 19,
"rotate": 0,
"origin": [
0,
0
],
"key": {},
"name": "middle"
},
"row": "home"
"row": "home",
"colrow": "middle_home"
}
},
"matrix_middle_top": {
@ -136,33 +136,33 @@
"y": 38,
"r": 0,
"meta": {
"stagger": 0,
"spread": 19,
"splay": 0,
"origin": [
0,
0
],
"shift": [
0,
0
],
"rotate": 0,
"width": 18,
"height": 18,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_middle_top",
"colrow": "middle_top",
"col": {
"rows": {
"top": {}
},
"stagger": 0,
"spread": 19,
"rotate": 0,
"origin": [
0,
0
],
"key": {},
"name": "middle"
},
"row": "top"
"row": "top",
"colrow": "middle_top"
}
},
"matrix_right_home": {
@ -170,38 +170,37 @@
"y": 19,
"r": 0,
"meta": {
"stagger": 19,
"spread": 19,
"splay": 0,
"origin": [
0,
0
],
"shift": [
0,
0
],
"rotate": 0,
"width": 18,
"height": 18,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_right_home",
"colrow": "right_home",
"col": {
"stagger": 19,
"row_overrides": {
"home": {},
"top": {}
"key": {
"stagger": "u"
},
"spread": 19,
"rotate": 0,
"origin": [
0,
0
],
"rows": {
"bottom": "$unset",
"home": {},
"top": {}
},
"key": {},
"name": "right"
},
"row": "home"
"row": "home",
"colrow": "right_home"
}
},
"matrix_right_top": {
@ -209,38 +208,37 @@
"y": 38,
"r": 0,
"meta": {
"stagger": 19,
"spread": 19,
"splay": 0,
"origin": [
0,
0
],
"shift": [
0,
0
],
"rotate": 0,
"width": 18,
"height": 18,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_right_top",
"colrow": "right_top",
"col": {
"stagger": 19,
"row_overrides": {
"home": {},
"top": {}
"key": {
"stagger": "u"
},
"spread": 19,
"rotate": 0,
"origin": [
0,
0
],
"rows": {
"bottom": "$unset",
"home": {},
"top": {}
},
"key": {},
"name": "right"
},
"row": "top"
"row": "top",
"colrow": "right_top"
}
}
}

View File

@ -4,5 +4,11 @@
"cx": 18,
"cy": 17,
"a": 10,
"b": 15
"b": 15,
"$default_stagger": 0,
"$default_spread": 19,
"$default_splay": 0,
"$default_height": 18,
"$default_width": 18,
"$default_padding": 19
}

View File

@ -1,11 +1,12 @@
const u = require('../../src/units')
const public = key => !key.startsWith('$')
describe('Units', function() {
it('defaults', function() {
// check that an empty config has the default units (and nothing more)
const def = u.parse({})
Object.keys(def).length.should.equal(4)
Object.keys(def).filter(public).length.should.equal(4)
def.U.should.equal(19.05)
def.u.should.equal(19)
def.cx.should.equal(18)
@ -20,7 +21,7 @@ describe('Units', function() {
b: 'a + 1'
}
})
Object.keys(res).length.should.equal(6)
Object.keys(res).filter(public).length.should.equal(6)
res.a.should.equal(9)
res.b.should.equal(10)
// also check that order matters, which it should
@ -42,7 +43,7 @@ describe('Units', function() {
a: 'U + 1'
}
})
Object.keys(res).length.should.equal(5)
Object.keys(res).filter(public).length.should.equal(5)
res.a.should.equal(20.05)
})