[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Sc-devel] relative coordinates in SCCompositeView ?



I see... the problem shows up when you have 3 layers of nesting. It works fine for 2, but breaks for 3.

w = SCWindow.new("test", Rect(50, 50, 500, 500)).front;
f = SCCompositeView(w, Rect(50, 50, 150, 200)).background_(Color.red(alpha: 0.3))
.relativeOrigin_(true);
g = SCCompositeView(f, Rect(10, 10, 100, 100)).background_(Color.blue(alpha: 0.3))
.relativeOrigin_(true);
h = SCCompositeView(g, Rect(30, 15, 60, 40)).background_(Color.yellow(alpha: 0.3))
.relativeOrigin_(true);
SCStaticText(h, Rect(10, 10, 40, 20)).background_(Color.white).string_("hello");
w.refresh;


Since it would be bad to fix it for 3 layers but leave it broken for 4, here's a stress test.

(
var ratio = rrand(1.25, 1.6), x = 0, lastx = 0, lastView;

if(0.5.coin) { ratio = ratio.reciprocal };

w = SCWindow("Albers ad infinitum", Rect(10, 10, 600, 600));
lastView = w;
while { x < 299 } {
lastView = SCCompositeView(lastView,
Rect(x - lastx, (x - lastx) * ratio, 600 - (2*x), 600 - (2*x)))
.background_(Color.rand.alpha_(rrand(0.3, 0.7)))
.relativeOrigin_(true);
lastx = x;
x = x + rrand(12, 36);
};
w.front;
)

For comparison, the same without relative origins. Both should look the same. (Quite pretty... Josef was no fool.)

(
var ratio = rrand(1.25, 1.6), x = 0, lastx = 0, lastView;

if(0.5.coin) { ratio = ratio.reciprocal };

w = SCWindow("Albers ad infinitum", Rect(10, 10, 600, 600));
lastView = w;
while { x < 299 } {
lastView = SCCompositeView(lastView,
Rect(x, x * ratio, 600 - (2*x), 600 - (2*x)))
.background_(Color.rand.alpha_(rrand(0.3, 0.7)))
.relativeOrigin_(false);
lastx = x;
x = x + rrand(12, 36);
};
w.front;
)



hjh

: H. James Harkins

: jamshark70@xxxxxxxxxxxxxxxxx

: http://www.dewdrop-world.net

.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:


"Come said the Muse,

Sing me a song no poet has yet chanted,

Sing me the universal."  -- Whitman