refactor: better sizing
This commit is contained in:
parent
2b1dbd41e1
commit
2e03ef3591
|
|
@ -16,7 +16,7 @@ export function getInscribedTrianglePoints(
|
||||||
height: number
|
height: number
|
||||||
): [number, number][] {
|
): [number, number][] {
|
||||||
// 以短边为基准计算内接正三角形的边长
|
// 以短边为基准计算内接正三角形的边长
|
||||||
const minDim = Math.min(width, height);
|
const minDim = Math.min(width, height / Math.sqrt(3) * 2);
|
||||||
// 正三角形的高 = 边长 * sqrt(3) / 2
|
// 正三角形的高 = 边长 * sqrt(3) / 2
|
||||||
const triangleHeight = minDim * Math.sqrt(3) / 2;
|
const triangleHeight = minDim * Math.sqrt(3) / 2;
|
||||||
const sideLength = minDim;
|
const sideLength = minDim;
|
||||||
|
|
@ -45,8 +45,7 @@ export function getInscribedHexagonPoints(
|
||||||
width: number,
|
width: number,
|
||||||
height: number
|
height: number
|
||||||
): [number, number][] {
|
): [number, number][] {
|
||||||
// 以短边为基准计算内接正六边形的半径
|
const minDim = Math.min(width, height / Math.sqrt(3) * 2);
|
||||||
const minDim = Math.min(width, height);
|
|
||||||
const radius = minDim / 2;
|
const radius = minDim / 2;
|
||||||
|
|
||||||
// 中心点
|
// 中心点
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue