1
0

Simplify the names in individual point "zones"

This commit is contained in:
Bán Dénes 2021-12-18 20:28:33 +01:00
parent 9ee099b16c
commit 2c18902e9f
6 changed files with 25 additions and 15 deletions

View File

@ -206,6 +206,9 @@ exports.parse = (config, units) => {
// rendering zones
for (let [zone_name, zone] of Object.entries(zones)) {
// zone sanitization
zone = a.sane(zone || {}, `points.zones.${zone_name}`, 'object')()
// extracting keys that are handled here, not at the zone render level
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)
@ -215,7 +218,16 @@ exports.parse = (config, units) => {
delete zone.mirror
// creating new points
const new_points = render_zone(zone_name, zone, anchor, global_key, units)
let new_points = render_zone(zone_name, zone, anchor, global_key, units)
// simplifying the names in individual point "zones"
const new_keys = Object.keys(new_points)
const individual_key = `${zone_name}_default_default`
if (new_keys.length == 1 && new_keys[0] == individual_key) {
new_points[zone_name] = new_points[individual_key]
new_points[zone_name].meta.name = zone_name
delete new_points[individual_key]
}
// adjusting new points
for (const [new_name, new_point] of Object.entries(new_points)) {

View File

@ -14,13 +14,13 @@ outlines:
type: circle
anchor:
ref:
- matrix_default_default
- mirror_matrix_default_default
- matrix
- mirror_matrix
radius: 15
outside_circles:
type: circle
anchor:
ref: matrix_default_default
ref: matrix
shift: [-10, 10]
radius: 5
mirror: true

View File

@ -14,15 +14,15 @@ outlines:
type: polygon
points:
- ref:
- matrix_default_default
- mirror_matrix_default_default
- matrix
- mirror_matrix
shift: [0, 20]
- shift: [20, -40]
- shift: [-40, 0]
outside_polys:
type: polygon
points:
- ref: matrix_default_default
- ref: matrix
shift: [-10, 15]
- shift: [5, -10]
- shift: [-10, 0]

View File

@ -14,14 +14,14 @@ outlines:
type: rectangle
anchor:
ref:
- matrix_default_default
- mirror_matrix_default_default
- matrix
- mirror_matrix
shift: [0, sy/2]
size: [20, 40]
outside_rects:
type: rectangle
anchor:
ref: matrix_default_default
ref: matrix
shift: [-10, 10]
size: 10
mirror: true

View File

@ -1,3 +1 @@
points:
zones:
matrix: {}
points.zones.matrix:

View File

@ -1,5 +1,5 @@
{
"matrix_default_default": {
"matrix": {
"x": 0,
"y": 0,
"r": 0,
@ -21,7 +21,7 @@
"padding": 19,
"skip": false,
"asym": "both",
"name": "matrix_default_default",
"name": "matrix",
"col": {
"rows": {},
"key": {},