Files
Harvey_Team_Page/design/brand-marks-2026-10-14/measure-official-marks.cjs
T
FastD e352335822 Filter bar with hover layer, icon-only project links, design reports
Filters: the panel is a bar (status segment, always visible) plus a body that lives as a layer
under it - collapsed by default, expands on hover/focus/tap and never moves the case grid; the
reset control appears only when a facet is limited; width capped at 720px (measured 45px slack
against 477px before). Facet research report is included.

Links: project links in the mini card and in the project window are icon-only buttons with a
uniform slot (16px card / 18px window) and the accessible name in aria-label; studio contacts
(mail, VK, RuStore) live outside the cards.

Team and page: real photos from the public TITANS team page go to the member window while the
card keeps the mascot; the portfolio gains the First Step Radio card and genre values, the
process block became an individual-approach section, plus a cookie bar and a removable ticker.

Design folders under design/ keep reports, measurements, scripts and the .pen; probe and
before/after screenshot dumps, editor backups and caches are removed. Background-variant and
palette previews stay until the client picks one.
2026-10-15 05:50:52 +03:00

193 lines
10 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* Геометрия официальных знаков VK и RuStore: чернила, масса, охранное поле (kanban t_ecca48e2).
*
* Всё — замер, а не догадка:
* 1) читает ОФИЦИАЛЬНЫЕ файлы из design/brand-marks-2026-10-14/assets/ (геометрия не правится);
* 2) растеризует знак в Chromium через canvas (рендер 256 px, увеличение 16x) и считает
* чернильный bbox в единицах исходного viewBox, alpha-площадь силуэта и площади по цвету;
* 3) выводит общую константу L (сторона знака в слоте 24x24 ед.) для обоих брендов:
* официальное основание обоих — квадрат 1:1, поэтому масштаб у них ОДИН;
* 4) считает готовые transform-группы (tx, ty, s) для каждого варианта L;
* 5) сравнивает массу с массой штриховых знаков (глобус/камера) прошлой волны
* (design/glyph-slot-2026-10-14/glyph-mass.json) и проверяет правило охранного поля
* RuStore (брендбук с. 5): «свободное пространство = половине высоты знака или больше».
*
* Запуск: node design/brand-marks-2026-10-14/measure-official-marks.cjs
* Выход: stdout + official-marks.json рядом со скриптом.
*/
const fs = require('fs');
const path = require('path');
const { launch } = require('./pw.cjs');
const HERE = __dirname;
const ROOT = path.resolve(HERE, '..', '..');
const A = (p) => path.join(HERE, 'assets', p);
/* ---------- 1. Геометрия из официальных файлов (как есть) ---------- */
function parseSvg(file) {
const s = fs.readFileSync(file, 'utf8');
const root = s.match(/<svg[^>]*>/)[0];
const vb = (root.match(/viewBox="([^"]+)"/) || [])[1].split(/\s+/).map(Number);
const paths = (s.match(/<path[^>]*>/g) || []).map((p) => ({
d: (p.match(/ d="([^"]+)"/) || [])[1],
fill: (p.match(/ fill="([^"]+)"/) || [])[1],
evenodd: /fill-rule="evenodd"/.test(p)
}));
return { viewBox: vb, paths, file };
}
const VK = parseSvg(A('vk/VK Logo.svg'));
const RS = parseSvg(A('rustore/RuStore_Icon (2).svg'));
/* Знак = оба официальных пути, родные цвета, родной viewBox. Размер рендера задаётся отдельно,
чтобы canvas не раздувался (RuStore: 512 ед. против VK: 101 ед.). */
const markSvg = (g, render) => '<svg xmlns="http://www.w3.org/2000/svg" style="display:block;width:' + render +
'px;height:' + render + 'px" viewBox="' + g.viewBox.join(' ') + '">' +
g.paths.map((p) => '<path d="' + p.d + '" fill="' + p.fill + '"' + (p.evenodd ? ' fill-rule="evenodd"' : '') + '/>').join('') +
'</svg>';
const partSvg = (g, i, render) => '<svg xmlns="http://www.w3.org/2000/svg" style="display:block;width:' + render +
'px;height:' + render + 'px" viewBox="' + g.viewBox.join(' ') + '"><path d="' + g.paths[i].d + '" fill="#000"' +
(g.paths[i].evenodd ? ' fill-rule="evenodd"' : '') + '/></svg>';
const PROBE = `async function (o) {
const { svg, render, scale } = o;
const px = Math.round(render * scale);
const url = 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(svg)));
const img = new Image();
await new Promise(function (res, rej) { img.onload = res; img.onerror = rej; img.src = url; });
const c = document.createElement('canvas');
c.width = px; c.height = px;
const ctx = c.getContext('2d');
ctx.drawImage(img, 0, 0, px, px);
const d = ctx.getImageData(0, 0, px, px).data;
let sum = 0, minX = 1e9, minY = 1e9, maxX = -1, maxY = -1, white = 0, blue = 0;
for (let y = 0; y < px; y++) for (let x = 0; x < px; x++) {
const i = (y * px + x) * 4, a = d[i + 3];
if (a === 0) continue;
sum += a / 255;
if (x < minX) minX = x; if (x > maxX) maxX = x;
if (y < minY) minY = y; if (y > maxY) maxY = y;
const r = d[i], g2 = d[i + 1], b = d[i + 2];
if (r > 220 && g2 > 220 && b > 220) white++;
else if (b > 150 && r < 120) blue++;
}
return {
area: sum / (scale * scale),
bx: minX / scale, by: minY / scale,
bw: (maxX - minX + 1) / scale, bh: (maxY - minY + 1) / scale,
white: white / (scale * scale), blue: blue / (scale * scale)
};
}`;
(async () => {
const browser = await launch();
const p = await browser.newPage({ viewport: { width: 400, height: 400 } });
await p.setContent('<!doctype html><meta charset="utf-8"><body style="margin:0;background:#fff"></body>');
const SCALE = 16, RENDER = 256;
const raster = (svg, render, scale) => p.evaluate('(' + PROBE + ')(' + JSON.stringify({ svg, render, scale }) + ')');
const out = { measured_from: 'official SVG files, raster in Chromium (render 256 px, scale 16x)', brands: {} };
for (const [key, g] of [['vk', VK], ['rustore', RS]]) {
const vbW = g.viewBox[2] - g.viewBox[0];
const per = vbW / RENDER; // ед. viewBox на 1 px рендера
const full = await raster(markSvg(g, RENDER), RENDER, SCALE);
const base = await raster(partSvg(g, 0, RENDER), RENDER, SCALE);
const inner = await raster(partSvg(g, 1, RENDER), RENDER, SCALE);
const ink = {
x: +(g.viewBox[0] + full.bx * per).toFixed(3), y: +(g.viewBox[1] + full.by * per).toFixed(3),
w: +(full.bw * per).toFixed(3), h: +(full.bh * per).toFixed(3)
};
out.brands[key] = {
file: path.relative(ROOT, g.file).replace(/\\/g, '/'),
viewBox: g.viewBox,
colors: g.paths.map((x) => x.fill),
ink,
inkAspect: +(ink.w / ink.h).toFixed(4),
silhouetteUnits2: +(full.area * per * per).toFixed(2),
squareUnits2: +(base.area * per * per).toFixed(2),
innerUnits2: +(inner.area * per * per).toFixed(2),
innerShareOfSquare: +(inner.area / base.area).toFixed(4),
whiteShareOfSilhouette: +(full.white / full.area).toFixed(4),
squareFillOfBox: +((base.area * per * per) / Math.pow(vbW, 2)).toFixed(4)
};
}
/* ---------- 2. Опорные массы штриховых знаков прошлой волны ---------- */
const prev = JSON.parse(fs.readFileSync(path.join(ROOT, 'design', 'glyph-slot-2026-10-14', 'glyph-mass.json'), 'utf8'));
const lineMass = { site: prev.solved.site.mass24, video: prev.solved.video.mass24 };
out.line_glyphs = {
mass_at_slot24px: lineMass, L_units: { site: prev.solved.site.L, video: prev.solved.video.L },
targetMass: Math.min(lineMass.site, lineMass.video)
};
/* ---------- 3. Слот (контракт §10.28) ---------- */
const SLOT = { card: 20, win: 24 }; // слот знака, px
const BTN = { card: 36, win: 48 }; // кнопка-ссылка, px
out.slot = SLOT; out.button = BTN;
const tf = (b, L) => {
const s = L / Math.max(b.ink.w, b.ink.h);
return {
L: +L.toFixed(2), s: +s.toFixed(5),
tx: +(12 - (b.ink.x + b.ink.w / 2) * s).toFixed(5),
ty: +(12 - (b.ink.y + b.ink.h / 2) * s).toFixed(5)
};
};
const rows = [];
for (let L = 24; L >= 12; L -= 0.5) {
const r = { L: +L.toFixed(2) };
for (const [key, b] of Object.entries(out.brands)) {
const t = tf(b, L);
const sq = L / 24; // сторона квадрата как доля слота
r[key] = {
s: t.s, tx: t.tx, ty: t.ty,
mass: +(b.silhouetteUnits2 * t.s * t.s).toFixed(2),
massVsLine: +((b.silhouetteUnits2 * t.s * t.s) / out.line_glyphs.targetMass).toFixed(3),
squareCardPx: +(sq * SLOT.card).toFixed(2), squareWinPx: +(sq * SLOT.win).toFixed(2),
logoHeightCardPx: +((b.ink.h / Math.max(b.ink.w, b.ink.h)) * sq * SLOT.card).toFixed(2),
innerSymbolCardPx: +(Math.sqrt(b.innerUnits2) * t.s / 24 * SLOT.card).toFixed(2),
/* RuStore, брендбук с. 5: свободное пространство ≥ половины высоты знака */
clearSpaceCardOk: ((BTN.card - sq * SLOT.card) / 2) >= (sq * SLOT.card) / 2,
clearSpaceWinOk: ((BTN.win - sq * SLOT.win) / 2) >= (sq * SLOT.win) / 2
};
}
r.brandSpread = +(Math.max(r.vk.mass, r.rustore.mass) / Math.min(r.vk.mass, r.rustore.mass)).toFixed(4);
rows.push(r);
}
out.solveTable = rows;
out.massMatchedL = rows.reduce((a, b) =>
Math.abs(b.vk.massVsLine - 1) + Math.abs(b.rustore.massVsLine - 1) <
Math.abs(a.vk.massVsLine - 1) + Math.abs(a.rustore.massVsLine - 1) ? b : a).L;
out.candidates = Object.fromEntries([24, 22, 21, 20, 19, 18, 17, 16, 15, 14]
.map((L) => ['L' + L, rows.find((r) => r.L === L)]).filter((x) => x[1]));
fs.writeFileSync(path.join(HERE, 'official-marks.json'), JSON.stringify(out, null, 2) + '\n');
console.log('=== ЗНАКИ (официальные файлы, геометрия как есть) ===');
console.table(Object.entries(out.brands).map(([k, b]) => ({
бренд: k, viewBox: b.viewBox.join(' '), файл: b.file.split('/').pop(),
'чернила ед.': b.ink.w + '×' + b.ink.h, 'аспект': b.inkAspect,
'силуэт ед²': b.silhouetteUnits2, 'заполн. бокса': b.squareFillOfBox,
'внутр./основание': b.innerShareOfSquare, 'белого в силуэте': b.whiteShareOfSilhouette
})));
console.log('=== ОПОРА: штриховые знаки прошлой волны ===', JSON.stringify(out.line_glyphs));
console.log('=== ВАРИАНТЫ ОБЩЕЙ КОНСТАНТЫ L (сторона знака в слоте 24×24 ед.) ===');
console.table([24, 22, 21, 20, 19, 18, 17, 16, 15, 14].map((L) => {
const r = rows.find((x) => x.L === L) || { vk: {}, rustore: {} };
return {
L,
'VK масса/штрих': r.vk.massVsLine, 'RS масса/штрих': r.rustore.massVsLine,
'разброс брендов': r.brandSpread,
'квадрат карт., px': r.vk.squareCardPx, 'квадрат окно, px': r.vk.squareWinPx,
'внутр. символ карт., px': r.rustore.innerSymbolCardPx,
'охран.поле 36 ок': r.vk.clearSpaceCardOk, 'охран.поле 48 ок': r.vk.clearSpaceWinOk
};
}));
console.log('=== ближе всего к массе штриховых знаков: L =', out.massMatchedL, '===');
console.log(JSON.stringify(out.candidates['L' + out.massMatchedL], null, 1));
await browser.close();
})();