Question

I have 3 rectangles being rendered here. Let's say i wanted to move them all above the line yet keep their order, how would i go about that? I tried subtracting the Y and height rather than adding the Y it but as expected, the lower rectangle goes at the top, middle stays in the middle and top goes to the bottom

before:

z http://screensnapr.com/e/Lljb6S.png

after: z http://screensnapr.com/e/EgWID2.png

So is there any simple solution to render them just above rather than having to change all values ?

Was it helpful?

Solution

You just want your boxes to stay over the X-axis, then you need to elevate all of them by the sum of all heights, plus the distance between blue box and the axis [being this blueBox.y].

So with a bit of pseudocode:

double totalHeight = box1.height + box2.height + box3.height + Math.abs(box1.y);

for(box in boxes){

    box.y -= totalHeight;

}    

The key is that you can't state the position of the single box without referring to the others - you need that sum.

OTHER TIPS

As far as i understood from your problem you want to lift those rectangles up.

Lets say you want to up them by Z pixel.

Then the co-ordinate of the first rectangle will be :

Y= Y- Z

I hope i understand your problem :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top