You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
315 lines
24 KiB
315 lines
24 KiB
3 years ago
|
var __create = Object.create;
|
||
|
var __defProp = Object.defineProperty;
|
||
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||
|
var __getProtoOf = Object.getPrototypeOf;
|
||
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||
|
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
||
|
var __export = (target, all) => {
|
||
|
__markAsModule(target);
|
||
|
for (var name in all)
|
||
|
__defProp(target, name, { get: all[name], enumerable: true });
|
||
|
};
|
||
|
var __reExport = (target, module2, desc) => {
|
||
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
||
|
for (let key of __getOwnPropNames(module2))
|
||
|
if (!__hasOwnProp.call(target, key) && key !== "default")
|
||
|
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
||
|
}
|
||
|
return target;
|
||
|
};
|
||
|
var __toModule = (module2) => {
|
||
|
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
||
|
};
|
||
|
var __async = (__this, __arguments, generator) => {
|
||
|
return new Promise((resolve, reject) => {
|
||
|
var fulfilled = (value) => {
|
||
|
try {
|
||
|
step(generator.next(value));
|
||
|
} catch (e) {
|
||
|
reject(e);
|
||
|
}
|
||
|
};
|
||
|
var rejected = (value) => {
|
||
|
try {
|
||
|
step(generator.throw(value));
|
||
|
} catch (e) {
|
||
|
reject(e);
|
||
|
}
|
||
|
};
|
||
|
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
||
|
step((generator = generator.apply(__this, __arguments)).next());
|
||
|
});
|
||
|
};
|
||
|
|
||
|
// src/main.ts
|
||
|
__export(exports, {
|
||
|
default: () => LineupBuilderPlugin
|
||
|
});
|
||
|
|
||
|
// src/config.ts
|
||
|
var KEEPER_COLOUR = "#808080";
|
||
|
var DEFENDER_COLOUR = "#2009ff";
|
||
|
var MIDFIELDER_COLOUR = "#ff0";
|
||
|
var FORWARD_COLOUR = "#f00";
|
||
|
|
||
|
// src/position.ts
|
||
|
var GK = {
|
||
|
x: 772,
|
||
|
y: 1670,
|
||
|
circleColour: KEEPER_COLOUR
|
||
|
};
|
||
|
var LB = {
|
||
|
x: 272,
|
||
|
y: 1347,
|
||
|
circleColour: DEFENDER_COLOUR
|
||
|
};
|
||
|
var CBL = {
|
||
|
x: 571,
|
||
|
y: 1447,
|
||
|
circleColour: DEFENDER_COLOUR
|
||
|
};
|
||
|
var CBR = {
|
||
|
x: 970,
|
||
|
y: 1447,
|
||
|
circleColour: DEFENDER_COLOUR
|
||
|
};
|
||
|
var RB = {
|
||
|
x: 1272,
|
||
|
y: 1347,
|
||
|
circleColour: DEFENDER_COLOUR
|
||
|
};
|
||
|
var LWB = {
|
||
|
x: 272,
|
||
|
y: 1247,
|
||
|
circleColour: DEFENDER_COLOUR
|
||
|
};
|
||
|
var LCB = {
|
||
|
x: 471,
|
||
|
y: 1447,
|
||
|
circleColour: DEFENDER_COLOUR
|
||
|
};
|
||
|
var CCB = {
|
||
|
x: 772,
|
||
|
y: 1420,
|
||
|
circleColour: DEFENDER_COLOUR
|
||
|
};
|
||
|
var RCB = {
|
||
|
x: 1070,
|
||
|
y: 1447,
|
||
|
circleColour: DEFENDER_COLOUR
|
||
|
};
|
||
|
var RWB = {
|
||
|
x: 1272,
|
||
|
y: 1247,
|
||
|
circleColour: DEFENDER_COLOUR
|
||
|
};
|
||
|
var CDM = {
|
||
|
x: 772,
|
||
|
y: 1083,
|
||
|
circleColour: MIDFIELDER_COLOUR
|
||
|
};
|
||
|
var LDM = {
|
||
|
x: 551.8,
|
||
|
y: 1083,
|
||
|
circleColour: MIDFIELDER_COLOUR
|
||
|
};
|
||
|
var RDM = {
|
||
|
x: 988.8,
|
||
|
y: 1083,
|
||
|
circleColour: MIDFIELDER_COLOUR
|
||
|
};
|
||
|
var CML = {
|
||
|
x: 571,
|
||
|
y: 976,
|
||
|
circleColour: MIDFIELDER_COLOUR
|
||
|
};
|
||
|
var CMR = {
|
||
|
x: 970,
|
||
|
y: 976,
|
||
|
circleColour: MIDFIELDER_COLOUR
|
||
|
};
|
||
|
var LCM = {
|
||
|
x: 417,
|
||
|
y: 883,
|
||
|
circleColour: MIDFIELDER_COLOUR
|
||
|
};
|
||
|
var RCM = {
|
||
|
x: 1152,
|
||
|
y: 883,
|
||
|
circleColour: MIDFIELDER_COLOUR
|
||
|
};
|
||
|
var CAM = {
|
||
|
x: 772,
|
||
|
y: 580.9,
|
||
|
circleColour: MIDFIELDER_COLOUR
|
||
|
};
|
||
|
var LAM = {
|
||
|
x: 319.1,
|
||
|
y: 580.9,
|
||
|
circleColour: MIDFIELDER_COLOUR
|
||
|
};
|
||
|
var RAM = {
|
||
|
x: 1211.8,
|
||
|
y: 580.9,
|
||
|
circleColour: MIDFIELDER_COLOUR
|
||
|
};
|
||
|
var LM = {
|
||
|
x: 328,
|
||
|
y: 775,
|
||
|
circleColour: MIDFIELDER_COLOUR
|
||
|
};
|
||
|
var RM = {
|
||
|
x: 1216,
|
||
|
y: 775,
|
||
|
circleColour: MIDFIELDER_COLOUR
|
||
|
};
|
||
|
var RW = {
|
||
|
x: 1258,
|
||
|
y: 363,
|
||
|
circleColour: FORWARD_COLOUR
|
||
|
};
|
||
|
var LW = {
|
||
|
x: 282,
|
||
|
y: 363,
|
||
|
circleColour: FORWARD_COLOUR
|
||
|
};
|
||
|
var LS = {
|
||
|
x: 588,
|
||
|
y: 260,
|
||
|
circleColour: FORWARD_COLOUR
|
||
|
};
|
||
|
var RS = {
|
||
|
x: 962,
|
||
|
y: 260,
|
||
|
circleColour: FORWARD_COLOUR
|
||
|
};
|
||
|
var ST = {
|
||
|
x: 772,
|
||
|
y: 193,
|
||
|
circleColour: FORWARD_COLOUR
|
||
|
};
|
||
|
|
||
|
// src/formation.ts
|
||
|
var formations = [
|
||
|
{
|
||
|
name: "442",
|
||
|
positions: [GK, LB, CBL, CBR, RB, LM, CML, CMR, RM, LS, RS]
|
||
|
},
|
||
|
{
|
||
|
name: "433",
|
||
|
positions: [GK, LB, CBL, CBR, RB, LCM, CDM, RCM, LW, ST, RW]
|
||
|
},
|
||
|
{
|
||
|
name: "4231",
|
||
|
positions: [GK, LB, CBL, CBR, RB, LDM, RDM, LAM, CAM, RAM, ST]
|
||
|
},
|
||
|
{
|
||
|
name: "442-diamond",
|
||
|
positions: [GK, LB, CBL, CBR, RB, CDM, LM, RM, CAM, LS, RS]
|
||
|
},
|
||
|
{
|
||
|
name: "541",
|
||
|
positions: [GK, LWB, LCB, CCB, RCB, RWB, LM, CML, CMR, RM, ST]
|
||
|
},
|
||
|
{
|
||
|
name: "523",
|
||
|
positions: [GK, LWB, LCB, CCB, RCB, RWB, CML, CMR, LW, ST, RW]
|
||
|
},
|
||
|
{
|
||
|
name: "532",
|
||
|
positions: [GK, LWB, LCB, CCB, RCB, RWB, LCM, CDM, RCM, LS, RS]
|
||
|
},
|
||
|
{
|
||
|
name: "343",
|
||
|
positions: [GK, LCB, CCB, RCB, LM, CML, CMR, RM, LW, ST, RW]
|
||
|
},
|
||
|
{
|
||
|
name: "352",
|
||
|
positions: [GK, LCB, CCB, RCB, LM, LDM, RDM, RM, CAM, LS, RS]
|
||
|
}
|
||
|
];
|
||
|
|
||
|
// src/main.ts
|
||
|
var import_obsidian = __toModule(require("obsidian"));
|
||
|
|
||
|
// src/svg-builder.ts
|
||
|
var LABEL_OFFSET_X = -69;
|
||
|
var LABEL_OFFSET_Y = 140;
|
||
|
function buildLabels(positions, players) {
|
||
|
let labels = [];
|
||
|
for (var i = 0; i < positions.length; i++) {
|
||
|
labels[i] = buildLabel(positions[i], players[i]);
|
||
|
}
|
||
|
return labels;
|
||
|
}
|
||
|
function buildCircles(positions) {
|
||
|
return positions.map((position) => buildCircle(position));
|
||
|
}
|
||
|
function buildLabel(position, playerName) {
|
||
|
return `<tspan x="${position.x + LABEL_OFFSET_X}" y="${position.y + LABEL_OFFSET_Y}">${playerName}</tspan>`;
|
||
|
}
|
||
|
function buildCircle(position) {
|
||
|
return `<use xlink:href="#pos" x="${position.x}" y="${position.y}" fill="${position.circleColour}"/>`;
|
||
|
}
|
||
|
function buildSvg(positions, players) {
|
||
|
return `
|
||
|
<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 1384 1920" preserveAspectRatio="xMinYMin" version="1.1">
|
||
|
<path d="M44.5,34.5h1312v1856h-1312z" fill="#393"/>
|
||
|
<path d="M69,59h1264.5v1808.5h-1264.5zM69,964h820.6a197.1,197.1 0 0 1-394.2,0a197.1,197.1 0 0 1 394.2,0h444M515,59v173h373.6v-173M331,59v347h740v-347M515,1868v-173h373.6v173M331,1868v-347h740v347" fill="none" stroke="#fff" stroke-width="4"/>
|
||
|
<defs>
|
||
|
<path d="m0,0a72,72 0 0 1-144,0 72,72 0 1 1 144,0z" id="pos"/>
|
||
|
</defs>
|
||
|
|
||
|
<g stroke="#000" stroke-width="6">
|
||
|
${buildCircles(positions).join("\n")}
|
||
|
</g>
|
||
|
|
||
|
<text style="font-size:56px;text-align:center;line-height:125%;text-anchor:middle;fill:#000000;font-family:Bitstream Vera Sans" x="709.4" y="1871.6" linespacing="125%">
|
||
|
${buildLabels(positions, players).join("\n")}
|
||
|
</text>
|
||
|
</svg>`;
|
||
|
}
|
||
|
|
||
|
// src/main.ts
|
||
|
var LineupBuilderPlugin = class extends import_obsidian.Plugin {
|
||
|
onInit() {
|
||
|
}
|
||
|
onload() {
|
||
|
return __async(this, null, function* () {
|
||
|
this.registerMarkdownCodeBlockProcessor("lineup", this.draw_lineup());
|
||
|
});
|
||
|
}
|
||
|
draw_lineup() {
|
||
|
return (source, el, ctx) => {
|
||
|
const { formation, players } = LineupBuilderPlugin.parseCode(source);
|
||
|
const xmlns = "http://www.w3.org/2000/svg";
|
||
|
var boxWidth = 346;
|
||
|
var boxHeight = 480;
|
||
|
var block = document.createElementNS(xmlns, "svg");
|
||
|
block.setAttributeNS(null, "viewBox", "0 0 " + boxWidth + " " + boxHeight);
|
||
|
block.setAttributeNS(null, "width", String(boxWidth));
|
||
|
block.setAttributeNS(null, "height", String(boxHeight));
|
||
|
block.innerHTML = buildSvg(formation.positions, players);
|
||
|
el.appendChild(block);
|
||
|
};
|
||
|
}
|
||
|
static parseCode(input) {
|
||
|
const lines = input.split(/\r?\n/);
|
||
|
let formation = lines[0];
|
||
|
if (formation.startsWith("formation: ")) {
|
||
|
formation = formation.replace("formation: ", "");
|
||
|
}
|
||
|
let players = [];
|
||
|
let playersLine = lines[1];
|
||
|
if (playersLine.startsWith("players: ")) {
|
||
|
players = playersLine.replace("players: ", "").split(",");
|
||
|
}
|
||
|
return {
|
||
|
formation: formations.find((x) => x.name === formation),
|
||
|
players
|
||
|
};
|
||
|
}
|
||
|
};
|
||
|
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsic3JjL21haW4udHMiLCAic3JjL2NvbmZpZy50cyIsICJzcmMvcG9zaXRpb24udHMiLCAic3JjL2Zvcm1hdGlvbi50cyIsICJzcmMvc3ZnLWJ1aWxkZXIudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImltcG9ydCB7IGZvcm1hdGlvbnMgfSBmcm9tICdzcmMvZm9ybWF0aW9uJztcclxuaW1wb3J0IHsgTWFya2Rvd25Qb3N0UHJvY2Vzc29yQ29udGV4dCwgUGx1Z2luIH0gZnJvbSAnb2JzaWRpYW4nO1xyXG5pbXBvcnQgeyBQYXJzZWRDb2RlIH0gZnJvbSAnLi90cy9pbnRlcmZhY2VzJztcclxuaW1wb3J0IHsgYnVpbGRTdmcgfSBmcm9tIC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