Files
NapCatQQ/.pnpm-store/v3/files/bf/3e95e91d8fdd0ac48f35c842c220dd24439ba4339d2062ada9dccf3e5445525599ac319f68e19cca377f03b1a20cc923e2b1e235a488a0830a57788afe93ae
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

37 lines
1011 B
Plaintext

/**
* @file 椭圆转换成轮廓
* @author mengke01(kekee000@gmail.com)
*/
import {computePath} from '../../graphics/computeBoundingBox';
import pathAdjust from '../../graphics/pathAdjust';
import circlePath from '../../graphics/path/circle';
import {clone} from '../../common/lang';
/**
* 椭圆转换成轮廓
*
* @param {number} cx 椭圆中心点x
* @param {number} cy 椭圆中心点y
* @param {number} rx 椭圆x轴半径
* @param {number} ry 椭圆y周半径
* @return {Array} 轮廓数组
*/
export default function oval2contour(cx, cy, rx, ry) {
if (undefined === ry) {
ry = rx;
}
const bound = computePath(circlePath);
const scaleX = (+rx) * 2 / bound.width;
const scaleY = (+ry) * 2 / bound.height;
const centerX = bound.width * scaleX / 2;
const centerY = bound.height * scaleY / 2;
const contour = clone(circlePath);
pathAdjust(contour, scaleX, scaleY);
pathAdjust(contour, 1, 1, +cx - centerX, +cy - centerY);
return contour;
}