Skip to content

Commit

Permalink
MouseMode::Clamp now clamps to [(0,0) (w-1,h-1)]
Browse files Browse the repository at this point in the history
  • Loading branch information
emoon committed Jan 29, 2016
1 parent b6e5bc4 commit 9458a1b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "minifb"
version = "0.3.0"
version = "0.3.1"
license = "MIT/Apache-2.0"
authors = ["Daniel Collin <[email protected]>"]
description = "Cross-platform window setup for bitmap rendering"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Usage
```toml
# Cargo.toml
[dependencies]
minifb = "0.3.0"
minifb = "0.3.1"
```

Example
Expand Down
4 changes: 2 additions & 2 deletions src/mouse_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9458a1b

Please sign in to comment.