M4DT5MAD3TATSVAT3MFNABHONWXOW443XD5W6DGEVVYHVITXVBDAC
KHAKSWQANUZL7B3EYF6GWTDGSUR2WVZGU5BPPI6OKYIPCD3QMWAQC
NQA6YRMRCF7LIHPYWLC355FPCH7CYA3QKSKQHSNJHA2XHOCWZXCAC
627ZCA4JTONT2DQPA2FU44FRSCXZGA6P3YAGTPL76K3UJVYGMFWAC
THNMNMVRZQVPZTEXHIK6WGYN3QDEFPKFOVOCB5HTWCYC5BOBYQ5AC
AAKN4XJLZ2GARZMUFYX3CJZKYHTRRZDYNTFRLMY7VPAY7K6W4N3QC
QU7JVYXAGGNN4754FJAT7HFTSFHLLIWWNIVYBMCBQJVSLTB5RNIQC
height: Math.abs(p1.y - p2.y)
height: Math.abs(p1.y - p2.y),
});
}
public static FromCenter(props: {
center: IVector2;
dimensions: IVector2;
}): Rect {
return new Rect({
x: props.center.x - props.dimensions.x / 2,
y: props.center.y - props.dimensions.y / 2,
width: props.dimensions.x,
height: props.dimensions.y,
x: this.centerX - (props.width || this.width) /2,
y: this.centerY - (props.height || this.height) /2,
width: (props.width || this.width),
height: (props.height || this.height)
})
x: this.centerX - (props.width || this.width) / 2,
y: this.centerY - (props.height || this.height) / 2,
width: props.width || this.width,
height: props.height || this.height,
});
const { center, height, width } = this.drawRectangle();
const renderRects = new RenderRects(this.app.stage, new Rect({x:0, y:0, width: this.config.canvasWidth, height: this.config.canvasHeight})
)
renderRects.drawFirst();
// const { center, height, width } = this.drawRectangle();
const {
centers: newCenters,
height: newHeight,
width: newWidth,
} = this.renderRecursion(center, height, width);
this.drawRectangle(newCenters[0], newHeight, newWidth);
this.drawRectangle(newCenters[1], newHeight, newWidth);
// const {
// centers: newCenters,
// height: newHeight,
// width: newWidth,
// } = this.renderRecursion(center, height, width);
// this.drawRectangle(newCenters[0], newHeight, newWidth);
// this.drawRectangle(newCenters[1], newHeight, newWidth);
let {
centers: newNewCenters,
height: newNewHeight,
width: newNewWidth,
} = this.renderRecursion(newCenters[0], newHeight, newWidth);
this.drawRectangle(newNewCenters[0], newNewHeight, newNewWidth);
this.drawRectangle(newNewCenters[1], newNewHeight, newNewWidth);
let { centers: newNewCenters2 } = this.renderRecursion(
newCenters[1],
newHeight,
newWidth
);
this.drawRectangle(newNewCenters2[0], newNewHeight, newNewWidth);
this.drawRectangle(newNewCenters2[1], newNewHeight, newNewWidth);
// let {
// centers: newNewCenters,
// height: newNewHeight,
// width: newNewWidth,
// } = this.renderRecursion(newCenters[0], newHeight, newWidth);
// this.drawRectangle(newNewCenters[0], newNewHeight, newNewWidth);
// this.drawRectangle(newNewCenters[1], newNewHeight, newNewWidth);
// let { centers: newNewCenters2 } = this.renderRecursion(
// newCenters[1],
// newHeight,
// newWidth
// );
// this.drawRectangle(newNewCenters2[0], newNewHeight, newNewWidth);
// this.drawRectangle(newNewCenters2[1], newNewHeight, newNewWidth);
this.drawRect(newRect);
const layer2 = this.nestRectPair(
newRect,
this.config.downscaleRatio12,
this.config.aspectRatio2 || this.config.aspectRatio1,
this.config.centerToEdgeBorderRatio2
);
this.drawRect(layer2.first);
this.drawRect(layer2.second);
const layer3 = new Pair(
this.nestRectPair(
layer2.first,
this.config.downscaleRatio23 || this.config.downscaleRatio12,
this.config.aspectRatio3 || this.config.aspectRatio2 || this.config.aspectRatio1,
this.config.centerToEdgeBorderRatio3 || this.config.centerToEdgeBorderRatio2
),
this.nestRectPair(
layer2.second,
this.config.downscaleRatio23 || this.config.downscaleRatio12,
this.config.aspectRatio3 || this.config.aspectRatio2 || this.config.aspectRatio1,
this.config.centerToEdgeBorderRatio3 || this.config.centerToEdgeBorderRatio2
),
)
this.drawRect(layer3.first.first);
this.drawRect(layer3.second.first);
this.drawRect(layer3.first.second);
this.drawRect(layer3.second.second);
private drawRect(rect: Rect) {
private nestRectPair(
original: Rect,
downscaleRatio: number,
newAspectRatio: number,
centerToEdgeBorderRatio: number
): Pair<Rect, Rect> {
const longSide = Math.min(original.height, original.width) * downscaleRatio;
const shortSide = longSide / newAspectRatio;
const remaining = Math.max(original.height, original.width) - 2 * shortSide;
const middleGap =
(remaining / (2 + centerToEdgeBorderRatio)) * centerToEdgeBorderRatio;
const offset = middleGap / 2 + shortSide / 2;
if (original.height < original.width) {
const newHeight = longSide;
const newWidth = shortSide;
const leftCenter = new Vector2(
original.centerX - offset,
original.centerY
);
const rightCenter = new Vector2(
original.centerX + offset,
original.centerY
);
return new Pair<Rect, Rect>(
Rect.FromCenter({
center: leftCenter,
dimensions: new Vector2(newWidth, newHeight),
}),
Rect.FromCenter({
center: rightCenter,
dimensions: new Vector2(newWidth, newHeight),
})
);
} else {
const newHeight = shortSide;
const newWidth = longSide;
const topCenter = new Vector2(
original.centerX,
original.centerY - offset
);
const bottomCenter = new Vector2(
original.centerX,
original.centerY + offset
);
return new Pair<Rect, Rect>(
Rect.FromCenter({
center: topCenter,
dimensions: new Vector2(newWidth, newHeight),
}),
Rect.FromCenter({
center: bottomCenter,
dimensions: new Vector2(newWidth, newHeight),
})
);
}
}
private drawRect(rect: Rect, hasBorder: boolean = true) {
this.drawCircleAt(rect.topLeft)
this.drawCircleAt(rect.topRight)
this.drawCircleAt(rect.bottomLeft)
this.drawCircleAt(rect.bottomRight)
this.drawCircleAt(rect.topLeft);
this.drawCircleAt(rect.topRight);
this.drawCircleAt(rect.bottomLeft);
this.drawCircleAt(rect.bottomRight);
this.drawCircleAt(new Vector2(rect.left, rect.centerY))
this.drawCircleAt(new Vector2(rect.right, rect.centerY))
this.drawCircleAt(new Vector2(rect.centerX, rect.top))
this.drawCircleAt(new Vector2(rect.centerX, rect.bottom))
this.drawCircleAt(new Vector2(rect.left, rect.centerY));
this.drawCircleAt(new Vector2(rect.right, rect.centerY));
this.drawCircleAt(new Vector2(rect.centerX, rect.top));
this.drawCircleAt(new Vector2(rect.centerX, rect.bottom));