mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-27 04:08:53 +01:00
ebiten: change the unit of (*Monitor).Bounds
Monitors can have different device scale factors, and in this case, it doesn't make sense to use device-independent pixels as unit for monitor positions and sizes. Updates #2778
This commit is contained in:
parent
d736a8cff7
commit
b3058b68a0
@ -40,13 +40,7 @@ type Monitor struct {
|
|||||||
|
|
||||||
// Bounds returns the monitor's bounds.
|
// Bounds returns the monitor's bounds.
|
||||||
func (m *Monitor) Bounds() image.Rectangle {
|
func (m *Monitor) Bounds() image.Rectangle {
|
||||||
ui := Get()
|
return image.Rect(m.x, m.y, m.x+m.width, m.y+m.height)
|
||||||
return image.Rect(
|
|
||||||
int(ui.dipFromGLFWMonitorPixel(float64(m.x), m.m)),
|
|
||||||
int(ui.dipFromGLFWMonitorPixel(float64(m.y), m.m)),
|
|
||||||
int(ui.dipFromGLFWMonitorPixel(float64(m.x+m.width), m.m)),
|
|
||||||
int(ui.dipFromGLFWMonitorPixel(float64(m.x+m.height), m.m)),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name returns the monitor's name.
|
// Name returns the monitor's name.
|
||||||
|
@ -23,7 +23,8 @@ import (
|
|||||||
// MonitorType represents a monitor available to the system.
|
// MonitorType represents a monitor available to the system.
|
||||||
type MonitorType ui.Monitor
|
type MonitorType ui.Monitor
|
||||||
|
|
||||||
// Bounds returns the position and size of the monitor in device-independent pixels.
|
// Bounds returns the position and size of the monitor in pixels.
|
||||||
|
// Be careful that the unit is not device-independent pixels.
|
||||||
func (m *MonitorType) Bounds() image.Rectangle {
|
func (m *MonitorType) Bounds() image.Rectangle {
|
||||||
return (*ui.Monitor)(m).Bounds()
|
return (*ui.Monitor)(m).Bounds()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user