diff --git a/src/points.js b/src/points.js index 8377d40..396413c 100644 --- a/src/points.js +++ b/src/points.js @@ -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)) { diff --git a/test/outlines/circles.yaml b/test/outlines/circles.yaml index fe8d572..3daca88 100644 --- a/test/outlines/circles.yaml +++ b/test/outlines/circles.yaml @@ -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 \ No newline at end of file diff --git a/test/outlines/polygons.yaml b/test/outlines/polygons.yaml index d22f109..3489d56 100644 --- a/test/outlines/polygons.yaml +++ b/test/outlines/polygons.yaml @@ -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] diff --git a/test/outlines/rectangles.yaml b/test/outlines/rectangles.yaml index 43bf02a..cec172d 100644 --- a/test/outlines/rectangles.yaml +++ b/test/outlines/rectangles.yaml @@ -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 \ No newline at end of file diff --git a/test/points/default.yaml b/test/points/default.yaml index 0e806d6..f767592 100644 --- a/test/points/default.yaml +++ b/test/points/default.yaml @@ -1,3 +1 @@ -points: - zones: - matrix: {} \ No newline at end of file +points.zones.matrix: \ No newline at end of file diff --git a/test/points/default___points.json b/test/points/default___points.json index e19638c..33e284f 100644 --- a/test/points/default___points.json +++ b/test/points/default___points.json @@ -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": {},