mirror of
https://github.com/italicsjenga/rust_minifb.git
synced 2025-02-04 06:26:34 +11:00
MouseMode::Clamp now clamps to [(0,0) (w-1,h-1)]
This commit is contained in:
parent
b6e5bc4aa9
commit
9458a1b05e
4 changed files with 8 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -12,7 +12,7 @@ Usage
|
|||
```toml
|
||||
# Cargo.toml
|
||||
[dependencies]
|
||||
minifb = "0.3.0"
|
||||
minifb = "0.3.1"
|
||||
```
|
||||
|
||||
Example
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue