MouseMode::Clamp now clamps to [(0,0) (w-1,h-1)]

This commit is contained in:
Daniel Collin 2016-01-29 20:56:26 +01:00
parent b6e5bc4aa9
commit 9458a1b05e
4 changed files with 8 additions and 4 deletions

View file

@ -2,6 +2,10 @@
This project follows semantic versioning.
### v0.3.1 (2016-01-29)
- [fixed] get_mouse_pos(MouseMode::Clamp) now is in the region [(0, 0) - (width - 1, height - 1)] instead of (width, height)
### v0.3.0 (2016-01-29)
- [added] get_mouse_pos

View file

@ -1,6 +1,6 @@
[package]
name = "minifb"
version = "0.3.0"
version = "0.3.1"
license = "MIT/Apache-2.0"
authors = ["Daniel Collin <daniel@collin.com>"]
description = "Cross-platform window setup for bitmap rendering"

View file

@ -12,7 +12,7 @@ Usage
```toml
# Cargo.toml
[dependencies]
minifb = "0.3.0"
minifb = "0.3.1"
```
Example

View file

@ -14,8 +14,8 @@ pub fn get_pos(mode: MouseMode, mx: f32, my: f32, scale: f32, width: f32, height
match mode {
MouseMode::Pass => Some((x, y)),
MouseMode::Clamp => {
Some((clamp(x, 0.0, window_width),
clamp(y, 0.0, window_height)))
Some((clamp(x, 0.0, window_width - 1.0),
clamp(y, 0.0, window_height - 1.0)))
},
MouseMode::Discard => {
if x < 0.0 || y < 0.0 || x >= window_width || y >= window_height {