-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Currently, the whole math library is kind of .. confusing.
There should only be 1 representation: exclusive. All rects should inclusively ranged.
The only place where exclusivity matters is on the terminal surface. this can just add Vec2::splat(1) to make it inclusive at the very end of the 'pipeline'.
But, perhaps we should make everything exclusive and the surface subtracts Vec2::splat(1).
For example, currently everything uses the exclusive ranges:
for y in 0..rect.height() {
for x in 0..rect.width() {
let pos = pos2(x, y);
}
}But things like Rect::clamp() uses an inclusive range:
pub fn clamp(&self, pos: Pos2) -> Pos2 {
pos.clamp(self.min, self.max)
}This is a bit annoying, for example:
fn event(&mut self, event: ViewEvent, ctx: EventCtx) -> Handled {
if let ViewEvent::MouseDrag {
current,
inside: true,
..
} = event
{
self.cursor = ctx.rect().clamp(current);
return Handled::Sink;
}
Handled::Bubble
}That clamps the cursor to 1,1 past the viewable area of the rectangle.
I think all rectangle math should be exclusive so it aligns with how we can iterate through the coordinates of a rect.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels