:right-sidebar: True Point =================================================================== .. currentmodule:: gi.repository.Graphene .. versionadded:: 1.0 .. class:: Point(*args, **kwargs) :no-contents-entry: A point with two coordinates. Constructors ------------ .. rst-class:: interim-class .. class:: Point :no-index: .. classmethod:: alloc() -> ~gi.repository.Graphene.Point Allocates a new :obj:`~gi.repository.Graphene.Point` structure. The coordinates of the returned point are (0, 0). It's possible to chain this function with :func:`~gi.repository.Graphene.Point.init` or :func:`~gi.repository.Graphene.Point.init_from_point`, e.g.: .. code-block:: C :dedent: graphene_point_t * point_new (float x, float y) { return graphene_point_init (graphene_point_alloc (), x, y); } graphene_point_t * point_copy (const graphene_point_t *p) { return graphene_point_init_from_point (graphene_point_alloc (), p); } .. versionadded:: 1.0 Methods ------- .. rst-class:: interim-class .. class:: Point :no-index: .. method:: distance(b: ~gi.repository.Graphene.Point) -> ~typing.Tuple[float, float, float] Computes the distance between ``a`` and ``b``\. .. versionadded:: 1.0 :param b: a :obj:`~gi.repository.Graphene.Point` .. method:: equal(b: ~gi.repository.Graphene.Point) -> bool Checks if the two points ``a`` and ``b`` point to the same coordinates. This function accounts for floating point fluctuations; if you want to control the fuzziness of the match, you can use :func:`~gi.repository.Graphene.Point.near` instead. .. versionadded:: 1.0 :param b: a :obj:`~gi.repository.Graphene.Point` .. method:: free() -> None Frees the resources allocated by :func:`~gi.repository.Graphene.Point.alloc`. .. versionadded:: 1.0 .. method:: init(x: float, y: float) -> ~gi.repository.Graphene.Point Initializes ``p`` to the given ``x`` and ``y`` coordinates. It's safe to call this function multiple times. .. versionadded:: 1.0 :param x: the X coordinate :param y: the Y coordinate .. method:: init_from_point(src: ~gi.repository.Graphene.Point) -> ~gi.repository.Graphene.Point Initializes ``p`` with the same coordinates of ``src``\. .. versionadded:: 1.0 :param src: the :obj:`~gi.repository.Graphene.Point` to use .. method:: init_from_vec2(src: ~gi.repository.Graphene.Vec2) -> ~gi.repository.Graphene.Point Initializes ``p`` with the coordinates inside the given :obj:`~gi.repository.Graphene.Vec2`\. .. versionadded:: 1.4 :param src: a :obj:`~gi.repository.Graphene.Vec2` .. method:: interpolate(b: ~gi.repository.Graphene.Point, factor: float) -> ~gi.repository.Graphene.Point Linearly interpolates the coordinates of ``a`` and ``b`` using the given ``factor``\. .. versionadded:: 1.0 :param b: a :obj:`~gi.repository.Graphene.Point` :param factor: the linear interpolation factor .. method:: near(b: ~gi.repository.Graphene.Point, epsilon: float) -> bool Checks whether the two points ``a`` and ``b`` are within the threshold of ``epsilon``\. .. versionadded:: 1.0 :param b: a :obj:`~gi.repository.Graphene.Point` :param epsilon: threshold between the two points .. method:: to_vec2() -> ~gi.repository.Graphene.Vec2 Stores the coordinates of the given :obj:`~gi.repository.Graphene.Point` into a :obj:`~gi.repository.Graphene.Vec2`\. .. versionadded:: 1.4 .. classmethod:: zero() -> ~gi.repository.Graphene.Point Returns a point fixed at (0, 0). .. versionadded:: 1.0 Fields ------ .. rst-class:: interim-class .. class:: Point :no-index: .. attribute:: x The X coordinate of the point .. attribute:: y The Y coordinate of the point