Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Perlkonig committed Apr 8, 2024
2 parents 7eda4ab + 577b7ac commit 1c5ddc4
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/renderers/_base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4262,7 +4262,17 @@ export abstract class RendererBase {
baseOpacity = this.json.board.strokeOpacity;
}

for (const marker of this.json.board.markers) {
const allMarkers = this.json.board.markers.filter(m => m.type !== "fences");
const fences = (this.json.board.markers.filter(m => m.type === "fences") as unknown[]) as {type: "fences", sides: {[k: string]: any}[]}[];
if (fences.length > 0) {
for (const decl of fences) {
for (const side of decl.sides) {
allMarkers.push({type: "fence", ...side});
}
}
}

for (const marker of allMarkers) {
if (! ((preGridLines && marker.belowGrid === true) || (!preGridLines && (marker.belowGrid === undefined || marker.belowGrid === false)) || (preGridLines && marker.type === "halo"))) {
continue;
}
Expand Down Expand Up @@ -5587,9 +5597,9 @@ export abstract class RendererBase {
const txtWidth = tmptxt.bbox().w;
tmptxt.remove();
// set the actual width of the nested svg
const realWidth = Math.max(areaWidth, txtWidth*1.05)
const {x: vbx, y:vby, w: vbw, h: vbh} = nested.viewbox();
const realWidth = Math.max(vbw, txtWidth);
nested.width(realWidth);
const {x: vbx, y:vby, h: vbh} = nested.viewbox();
nested.viewbox(vbx, vby, realWidth, vbh);
const txt = nested.text(area.label).addClass(`aprender-area-label`);
txt.font({size: textHeight, anchor: "start", fill: "#000"})
Expand Down
49 changes: 49 additions & 0 deletions src/schemas/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,55 @@ export interface APRenderRep {
*/
dashed?: number[];
}
| {
/**
* Only works for the `squares*` and rect-of-hex board styles. Draws a thick line between two adjacent cells. It doesn't check adjacency, but the results will not be what you expect otherwise.
*/
type: "fences";
/**
* @minItems 1
*/
sides: [
{
cell: {
row: number;
col: number;
};
side: "N" | "NE" | "E" | "SE" | "S" | "SW" | "W" | "NW";
/**
* The colour of the fence. Can be either a number (which will be interpreted as a built-in player colour) or a hexadecimal colour string.
*/
colour?: PositiveInteger | Colourstrings;
/**
* Expressed as a multiple of the base stroke width
*/
width?: number;
/**
* A valid `dasharray` appropriate for the game's display.
*/
dashed?: number[];
},
...{
cell: {
row: number;
col: number;
};
side: "N" | "NE" | "E" | "SE" | "S" | "SW" | "W" | "NW";
/**
* The colour of the fence. Can be either a number (which will be interpreted as a built-in player colour) or a hexadecimal colour string.
*/
colour?: PositiveInteger | Colourstrings;
/**
* Expressed as a multiple of the base stroke width
*/
width?: number;
/**
* A valid `dasharray` appropriate for the game's display.
*/
dashed?: number[];
}[]
];
}
| {
/**
* A way of incorporating a glyph from the legend into the board itself. Currently only works in the `default` and `stacking-offset` renderer.
Expand Down
59 changes: 59 additions & 0 deletions src/schemas/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,65 @@
"required": ["type", "cell", "side"],
"additionalProperties": false
},
{
"properties": {
"type": {
"description": "Only works for the `squares*` and rect-of-hex board styles. Draws a thick line between two adjacent cells. It doesn't check adjacency, but the results will not be what you expect otherwise.",
"enum": ["fences"]
},
"sides": {
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"properties": {
"cell": {
"type": "object",
"properties": {
"row": {
"type": "integer",
"minimum": 0
},
"col": {
"type": "integer",
"minimum": 0
}
},
"required": ["row", "col"],
"additionalProperties": false
},
"side": {
"enum": ["N", "NE", "E", "SE", "S", "SW", "W", "NW"]
},
"colour": {
"description": "The colour of the fence. Can be either a number (which will be interpreted as a built-in player colour) or a hexadecimal colour string.",
"anyOf": [
{"$ref": "#/definitions/positiveInteger"},
{"$ref": "#/definitions/colourstrings"}
],
"default": "#000"
},
"width": {
"description": "Expressed as a multiple of the base stroke width",
"type": "number",
"default": 6
},
"dashed": {
"description": "A valid `dasharray` appropriate for the game's display.",
"type": "array",
"items": {
"type": "number"
}
}
},
"required": ["cell", "side"],
"additionalProperties": false
}
}
},
"required": ["type", "sides"],
"additionalProperties": false
},
{
"properties": {
"type": {
Expand Down

0 comments on commit 1c5ddc4

Please sign in to comment.