Files
vue-driven-cloud-storage/backend/node_modules/svg-captcha/lib/ch-to-path.js
237899745 4350113979 fix: 修复配额说明重复和undefined问题
- 在editStorageForm中初始化oss_storage_quota_value和oss_quota_unit
- 删除重复的旧配额说明块,保留新的当前配额设置显示

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 19:39:53 +08:00

47 lines
1006 B
JavaScript

'use strict';
const assert = require('assert');
function rndPathCmd(cmd) {
const r = (Math.random() * 0.2) - 0.1;
switch (cmd.type) {
case 'M': case 'L':
cmd.x += r;
cmd.y += r;
break;
case 'Q': case 'C':
cmd.x += r;
cmd.y += r;
cmd.x1 += r;
cmd.y1 += r;
break;
default:
// Close path cmd
break;
}
return cmd;
}
module.exports = function (text, opts) {
const ch = text[0];
assert(ch, 'expect a string');
const fontSize = opts.fontSize;
const fontScale = fontSize / opts.font.unitsPerEm;
const glyph = opts.font.charToGlyph(ch);
const width = glyph.advanceWidth ? glyph.advanceWidth * fontScale : 0;
const left = opts.x - (width / 2);
const height = (opts.ascender + opts.descender) * fontScale;
const top = opts.y + (height / 2);
const path = glyph.getPath(left, top, fontSize);
// Randomize path commands
path.commands.forEach(rndPathCmd);
const pathData = path.toPathData();
return pathData;
};