I'm trying to arrange the squares as shown in the picture . Each square is smaller than the previous one by a constant value. When positioning a square, I know:
The formula must necessarily contain multiplication by the index relative to the centre because the squares can change their position by multiplication on it.
I'm writing some code for it, but it's not ideal. Constant (0.5) is an eyeballed value.
Float GetCardPosition(Int Index) {
var Distance = CenterIndex - Index; // index relative to the center
var Size = GetCardSize(index);
var CardCenter = Size / 2;
var Center = MaxWidth / 2;
var CenterIndent = Indent / 2;
var CardPos = Center - CardCenter;
var Pos = (CardCenter + CenterIndent * Math.abs(Distance) * 0.5) * Distance;
return CardPos - Pos;
}
I think a simple observation will help you. The center of the squares starting with square number zero is 0, 7, 12, 15, 16 (and negative in the opposite direction). This is 16 - 16, 16 - 9, 16 - 4, 16 - 1, 16 - 0. So the simple formula for the n-th square center is f(n) = 16 - (4 - n)^2.