tags:

views:

50

answers:

2

Hi,

I have a rectangle say (150, 200, 25,25) and x- axis up to 800 and y-axis upto 650. Now like to increase the value of x and y axis by 100. The rectangle value also increase according to x and y axis.

say my rectangle are in the shaded place. now i increase the x and y axis. the shaded position also increases. the rectangle value also need to increase so it placed in that shaded place as before.

How can i achieve this...

Thanks in advance....

A: 

Use a scale factor for each axis>

ScaleFactorX = NewValueAxisX / OldValueAxisX = 900/800 (in your example

NewRectValuesX = OldRectValuesX * ScaleFactorX

the same for Y axis

If your rect was at the top (at 800), now it will be at

NewRectValue = 800 * Scale = 800 * 900/800 = 800 (still at the top)

belisarius
Thanks for your answer. but my last line makes my quires wrong. so i deleted the lsat line.c sorry for that..say my rectangle are in the shaded place. now i increase the x and y axis. the shaded position also increases. the rectangle value also need to increase so it placed in that shaded place as before.
Nivas
A: 

ratio = Convert.ToDouble(new x- axis) / Convert.ToDouble(old x -axis);

rect1.X = Convert.ToInt16((rectangles[c].X) * ratio); rect1.Y = Convert.ToInt16((rectangles[c].Y * ratio)); rect1.Width = Convert.ToInt16(rectangles[c].Width * ratio); rect1.Height = Convert.ToInt16(rectangles[c].Height * ratio);

Nivas