1/* graphene-point.h: Point and Size
2 *
3 * SPDX-License-Identifier: MIT
4 *
5 * Copyright 2014 Emmanuele Bassi
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 * THE SOFTWARE.
24 */
25
26#pragma once
27
28#if !defined(GRAPHENE_H_INSIDE) && !defined(GRAPHENE_COMPILATION)
29#error "Only graphene.h can be included directly."
30#endif
31
32#include "graphene-types.h"
33
34GRAPHENE_BEGIN_DECLS
35
36/**
37 * GRAPHENE_POINT_INIT:
38 * @_x: the X coordinate
39 * @_y: the Y coordinate
40 *
41 * Initializes a #graphene_point_t with the given coordinates
42 * when declaring it, e.g:
43 *
44 * |[<!-- language="C" -->
45 * graphene_point_t p = GRAPHENE_POINT_INIT (10.f, 10.f);
46 * ]|
47 *
48 * Since: 1.0
49 */
50#define GRAPHENE_POINT_INIT(_x,_y) (graphene_point_t) { .x = (_x), .y = (_y) }
51
52/**
53 * GRAPHENE_POINT_INIT_ZERO:
54 *
55 * Initializes a #graphene_point_t to (0, 0) when declaring it.
56 *
57 * Since: 1.0
58 */
59#define GRAPHENE_POINT_INIT_ZERO GRAPHENE_POINT_INIT (0.f, 0.f)
60
61/**
62 * graphene_point_t:
63 * @x: the X coordinate of the point
64 * @y: the Y coordinate of the point
65 *
66 * A point with two coordinates.
67 *
68 * Since: 1.0
69 */
70struct _graphene_point_t
71{
72 float x;
73 float y;
74};
75
76GRAPHENE_AVAILABLE_IN_1_0
77graphene_point_t * graphene_point_alloc (void);
78GRAPHENE_AVAILABLE_IN_1_0
79void graphene_point_free (graphene_point_t *p);
80
81GRAPHENE_AVAILABLE_IN_1_0
82graphene_point_t * graphene_point_init (graphene_point_t *p,
83 float x,
84 float y);
85GRAPHENE_AVAILABLE_IN_1_0
86graphene_point_t * graphene_point_init_from_point (graphene_point_t *p,
87 const graphene_point_t *src);
88GRAPHENE_AVAILABLE_IN_1_4
89graphene_point_t * graphene_point_init_from_vec2 (graphene_point_t *p,
90 const graphene_vec2_t *src);
91GRAPHENE_AVAILABLE_IN_1_0
92bool graphene_point_equal (const graphene_point_t *a,
93 const graphene_point_t *b);
94
95GRAPHENE_AVAILABLE_IN_1_0
96float graphene_point_distance (const graphene_point_t *a,
97 const graphene_point_t *b,
98 float *d_x,
99 float *d_y);
100
101GRAPHENE_AVAILABLE_IN_1_0
102bool graphene_point_near (const graphene_point_t *a,
103 const graphene_point_t *b,
104 float epsilon);
105
106GRAPHENE_AVAILABLE_IN_1_0
107void graphene_point_interpolate (const graphene_point_t *a,
108 const graphene_point_t *b,
109 double factor,
110 graphene_point_t *res);
111
112GRAPHENE_AVAILABLE_IN_1_4
113void graphene_point_to_vec2 (const graphene_point_t *p,
114 graphene_vec2_t *v);
115
116GRAPHENE_AVAILABLE_IN_1_0
117const graphene_point_t * graphene_point_zero (void);
118
119GRAPHENE_END_DECLS
120

source code of gtk/subprojects/graphene/include/graphene-point.h