Skip to content

Commit c11d296

Browse files
committed
Sort screenshot properties by name
1 parent f1c71bb commit c11d296

File tree

1 file changed

+36
-40
lines changed

1 file changed

+36
-40
lines changed

mss/screenshot.py

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -75,29 +75,23 @@ def from_size(cls, data, width, height):
7575
return cls(data, monitor)
7676

7777
@property
78-
def top(self):
78+
def bgra(self):
79+
# type: () -> bytes
80+
""" Compute BGRA values from the BGRA raw pixels. """
81+
return bytes(self.raw)
82+
83+
@property
84+
def height(self):
7985
# type: () -> int
80-
""" Convenient accessor to the top position. """
81-
return self.pos.top
86+
""" Convenient accessor to the height size. """
87+
return self.size.height
8288

8389
@property
8490
def left(self):
8591
# type: () -> int
8692
""" Convenient accessor to the left position. """
8793
return self.pos.left
8894

89-
@property
90-
def width(self):
91-
# type: () -> int
92-
""" Convenient accessor to the width size. """
93-
return self.size.width
94-
95-
@property
96-
def height(self):
97-
# type: () -> int
98-
""" Convenient accessor to the height size. """
99-
return self.size.height
100-
10195
@property
10296
def pixels(self):
10397
# type: () -> List[Tuple[int, int, int]]
@@ -111,31 +105,6 @@ def pixels(self):
111105

112106
return self.__pixels
113107

114-
def pixel(self, coord_x, coord_y):
115-
# type: (int, int) -> Tuple[int, int, int]
116-
"""
117-
Returns the pixel value at a given position.
118-
119-
:param int coord_x: The x coordinate.
120-
:param int coord_y: The y coordinate.
121-
:return tuple: The pixel value as (R, G, B).
122-
"""
123-
124-
try:
125-
return self.pixels[coord_y][coord_x]
126-
except IndexError:
127-
raise ScreenShotError('Pixel location out of range.', locals())
128-
129-
@property
130-
def bgra(self):
131-
# type: () -> bytes
132-
"""
133-
Compute BGRA values from the BGRA raw pixels.
134-
135-
:return bytes: BGRA pixels.
136-
"""
137-
return bytes(self.raw)
138-
139108
@property
140109
def rgb(self):
141110
# type: () -> bytes
@@ -152,3 +121,30 @@ def rgb(self):
152121
self.__rgb = bytes(rgb)
153122

154123
return self.__rgb
124+
125+
@property
126+
def top(self):
127+
# type: () -> int
128+
""" Convenient accessor to the top position. """
129+
return self.pos.top
130+
131+
@property
132+
def width(self):
133+
# type: () -> int
134+
""" Convenient accessor to the width size. """
135+
return self.size.width
136+
137+
def pixel(self, coord_x, coord_y):
138+
# type: (int, int) -> Tuple[int, int, int]
139+
"""
140+
Returns the pixel value at a given position.
141+
142+
:param int coord_x: The x coordinate.
143+
:param int coord_y: The y coordinate.
144+
:return tuple: The pixel value as (R, G, B).
145+
"""
146+
147+
try:
148+
return self.pixels[coord_y][coord_x]
149+
except IndexError:
150+
raise ScreenShotError('Pixel location out of range.', locals())

0 commit comments

Comments
 (0)