|
| 1 | +# Pyrogram - Telegram MTProto API Client Library for Python |
| 2 | +# Copyright (C) 2017-present Dan <https://github.com/delivrance> |
| 3 | +# |
| 4 | +# This file is part of Pyrogram. |
| 5 | +# |
| 6 | +# Pyrogram is free software: you can redistribute it and/or modify |
| 7 | +# it under the terms of the GNU Lesser General Public License as published |
| 8 | +# by the Free Software Foundation, either version 3 of the License, or |
| 9 | +# (at your option) any later version. |
| 10 | +# |
| 11 | +# Pyrogram is distributed in the hope that it will be useful, |
| 12 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | +# GNU Lesser General Public License for more details. |
| 15 | +# |
| 16 | +# You should have received a copy of the GNU Lesser General Public License |
| 17 | +# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. |
| 18 | + |
| 19 | + |
| 20 | +from pyrogram import enums, raw |
| 21 | + |
| 22 | +from ..object import Object |
| 23 | + |
| 24 | + |
| 25 | +class MaskPosition(Object): |
| 26 | + """This object describes the position on faces where a mask should be placed by default. |
| 27 | +
|
| 28 | + Parameters: |
| 29 | + point (:obj:`~pyrogram.enums.MaskPointType`): |
| 30 | + The part of the face relative to which the mask should be placed. |
| 31 | +
|
| 32 | + x_shift (``float``): |
| 33 | + Shift by X-axis measured in widths of the mask scaled to the face size, from left to right. |
| 34 | + For example, choosing -1.0 will place mask just to the left of the default mask position. |
| 35 | +
|
| 36 | + y_shift (``float``): |
| 37 | + Shift by Y-axis measured in heights of the mask scaled to the face size, from top to bottom. |
| 38 | + For example, 1.0 will place the mask just below the default mask position. |
| 39 | +
|
| 40 | + scale (``float``): |
| 41 | + Mask scaling coefficient. For example, 2.0 means double size. |
| 42 | + """ |
| 43 | + def __init__( |
| 44 | + self, |
| 45 | + *, |
| 46 | + point: "enums.MaskPointType", |
| 47 | + x_shift: float, |
| 48 | + y_shift: float, |
| 49 | + scale: float |
| 50 | + ): |
| 51 | + super().__init__() |
| 52 | + |
| 53 | + self.point = point |
| 54 | + self.x_shift = x_shift |
| 55 | + self.y_shift = y_shift |
| 56 | + self.scale = scale |
| 57 | + |
| 58 | + @staticmethod |
| 59 | + def _parse( |
| 60 | + coords: "raw.types.MaskCoords" |
| 61 | + ) -> "MaskPosition": |
| 62 | + if not coords: |
| 63 | + return None |
| 64 | + |
| 65 | + return MaskPosition( |
| 66 | + point=enums.MaskPointType(coords.n), |
| 67 | + x_shift=coords.x, |
| 68 | + y_shift=coords.y, |
| 69 | + scale=coords.zoom |
| 70 | + ) |
0 commit comments