UNPKG

mine-h5-ui

Version:

一款轻量级、模块化基于 Vue3.x 的 H5 前端 UI 组件库 👍

108 lines (107 loc) 3.44 kB
/*! * mine-h5-ui v2.15.0 * Copyright (c) 2025 biaov * @license MIT */ const u = (x, o) => { const t = o.x * 2 - x.x, n = o.y * 2 - x.y; return { x: t, y: n }; }, w = (x, o) => { const t = (x.x + o.x) / 2, n = (x.y + o.y) / 2; return { x: t, y: n }; }, d = (x, o = "angle") => { const t = Math.PI / 180; return o === "angle" ? x * t : x / t; }, a = (x, o, t) => { const n = d(t), e = Math.sin(n), s = Math.cos(n), y = x.x - o.x, h = x.y - o.y, r = y * s - h * e + o.x, M = y * e + h * s + o.y; return { x: r, y: M }; }, c = ({ symmPoint: x, curPoint: o, rect: t }) => { const n = w(o, x), e = a(o, n, -t.r), s = u(e, n), y = s.x - e.x, h = s.y - e.y; return y > 0 && h > 0 && (t.w = Math.round(y), t.h = Math.round(h), t.x = Math.round(e.x), t.y = Math.round(e.y)), t; }, i = ({ startPoint: x, symmPoint: o, curPoint: t, rect: n }) => { const e = a(t, x, -n.r), s = a( { x: x.x, y: e.y }, x, n.r ), y = Math.sqrt((s.x - o.x) ** 2 + (s.y - o.y) ** 2); if (y > 0) { const h = { x: (s.x + o.x) / 2, y: (s.y + o.y) / 2 }; n.h = Math.round(y), n.x = Math.round(h.x - n.w / 2), n.y = Math.round(h.y - y / 2); } return n; }, C = ({ symmPoint: x, curPoint: o, rect: t }) => { const n = w(o, x), e = a(o, n, -t.r), s = u(e, n), y = e.x - s.x, h = s.y - e.y; return y > 0 && h > 0 && (t.w = Math.round(y), t.h = Math.round(h), t.x = Math.round(s.x), t.y = Math.round(e.y)), t; }, f = ({ startPoint: x, symmPoint: o, curPoint: t, rect: n }) => { const e = a(t, x, -n.r), s = a( { x: e.x, y: x.y }, x, n.r ), y = Math.sqrt((s.x - o.x) ** 2 + (s.y - o.y) ** 2); if (y > 0) { const h = { x: (s.x + o.x) / 2, y: (s.y + o.y) / 2 }; n.w = Math.round(y), n.x = Math.round(h.x - y / 2), n.y = Math.round(h.y - n.h / 2); } return n; }, z = ({ symmPoint: x, curPoint: o, rect: t }) => { const n = w(o, x), e = a(o, n, -t.r), s = u(e, n), y = e.x - s.x, h = e.y - s.y; return y > 0 && h > 0 && (t.w = Math.round(y), t.h = Math.round(h), t.x = Math.round(s.x), t.y = Math.round(s.y)), t; }, R = ({ startPoint: x, symmPoint: o, curPoint: t, rect: n }) => { const e = a(t, x, -n.r), s = a( { x: x.x, y: e.y }, x, n.r ), y = Math.sqrt((s.x - o.x) ** 2 + (s.y - o.y) ** 2); if (y > 0) { const h = { x: (s.x + o.x) / 2, y: (s.y + o.y) / 2 }; n.h = Math.round(y), n.x = Math.round(h.x - n.w / 2), n.y = Math.round(h.y - y / 2); } return n; }, l = ({ symmPoint: x, curPoint: o, rect: t }) => { const n = w(o, x), e = a(o, n, -t.r), s = u(e, n), y = s.x - e.x, h = e.y - s.y; return y > 0 && h > 0 && (t.w = Math.round(y), t.h = Math.round(h), t.x = Math.round(e.x), t.y = Math.round(s.y)), t; }, W = ({ startPoint: x, symmPoint: o, curPoint: t, rect: n }) => { const e = a(t, x, -n.r), s = a({ x: e.x, y: x.y }, x, n.r), y = Math.sqrt((s.x - o.x) ** 2 + (s.y - o.y) ** 2); if (y > 0) { const h = { x: (s.x + o.x) / 2, y: (s.y + o.y) / 2 }; n.w = Math.round(y), n.y = Math.round(h.y - n.h / 2), n.x = Math.round(h.x - y / 2); } return n; }, g = { nw: c, n: i, ne: C, e: f, se: z, s: R, sw: l, w: W }, H = (x, o) => g[x](structuredClone(o)); export { d as angleMutualRadian, H as default, w as getCenterPoint, a as getRotatePoint, u as getSymmPoint };