dragonwell
Programmer
How can I change the width and height of a System.Drawing.Rectangle object, by a small percentage? If my Rectangle is 100 wide by 50 high, say I want to scale it by 1.02 or .98776 percent? By multiplying the perncentage times the original size, I end up with a Single, and it seems the Rectangle's dimensions can only be Integers.
so
I'm sure this is just simple math.... but not simple enough for me.![[sad] [sad] [sad]](/data/assets/smilies/sad.gif)
![[pipe] [pipe] [pipe]](/data/assets/smilies/pipe.gif)
so
Code:
Single percentOfChange = .98776;
//since Width is an integer, this won't work
myRectangle.Width = myRectangle.Width * percentOfChange;
//...and this forces the percentage to 0
myRectangle.Width = (int)(myRectangle.Width * percentOfChange);
I'm sure this is just simple math.... but not simple enough for me.
![[sad] [sad] [sad]](/data/assets/smilies/sad.gif)
![[pipe] [pipe] [pipe]](/data/assets/smilies/pipe.gif)