rect<T> and getWidth

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
AticAtac
Posts: 29
Joined: Mon Mar 22, 2004 2:46 pm
Location: Germany

rect<T> and getWidth

Post by AticAtac »

T getWidth() const
{
return LowerRightCorner.X - UpperLeftCorner.X;
}


shouldn't it be :

return LowerRightCorner.X - UpperLeftCorner.X + 1;

?

This is my understanding of "rect" and "width".
Conquistador
Posts: 340
Joined: Wed Sep 28, 2005 4:38 pm
Location: Canada, Eh!

Post by Conquistador »

Why should it be like that? It looks right to me..
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

Yes, it should be +1.
Image
AticAtac
Posts: 29
Joined: Mon Mar 22, 2004 2:46 pm
Location: Germany

Post by AticAtac »

The problem is that many functions like draw2DImage(...) relies on this "bug". So clearing this means to update many other codes. But i think it should be done.
hybrid

Post by hybrid »

Conquistador wrote:Why should it be like that? It looks right to me..
If you have a line of pixels going (on the x-axis) from 1 to 5 it would look like this

Code: Select all

1 2 3 4 5
* * * * *
You would assume the width to be 5 as we have 5 pixels, but the method will return 4 (=5-1).
Post Reply