GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_utility_rectangle_point_detect.c Lines: 7 7 100.0 %
Date: 2024-12-05 08:52:37 Branches: 8 8 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 *
4
 * This program and the accompanying materials are made available under the
5
 * terms of the MIT License which is available at
6
 * https://opensource.org/licenses/MIT.
7
 *
8
 * SPDX-License-Identifier: MIT
9
 **************************************************************************/
10
11
12
/**************************************************************************/
13
/**************************************************************************/
14
/**                                                                       */
15
/** GUIX Component                                                        */
16
/**                                                                       */
17
/**   Utility (Utility)                                                   */
18
/**                                                                       */
19
/**************************************************************************/
20
21
#define GX_SOURCE_CODE
22
23
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_utility.h"
28
29
30
/**************************************************************************/
31
/*                                                                        */
32
/*  FUNCTION                                               RELEASE        */
33
/*                                                                        */
34
/*    _gx_utility_rectangle_point_detect                  PORTABLE C      */
35
/*                                                           6.1          */
36
/*  AUTHOR                                                                */
37
/*                                                                        */
38
/*    Kenneth Maxwell, Microsoft Corporation                              */
39
/*                                                                        */
40
/*  DESCRIPTION                                                           */
41
/*                                                                        */
42
/*    This service detects if the specified point resides in the          */
43
/*    rectangle. If the point does reside in the rectangle, the service   */
44
/*    returns GX_TRUE.                                                    */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    rectangle                             Rectangle                     */
49
/*    point                                 Point                         */
50
/*                                                                        */
51
/*  OUTPUT                                                                */
52
/*                                                                        */
53
/*    [GX_TRUE | GX_FALSE]                                                */
54
/*                                                                        */
55
/*  CALLS                                                                 */
56
/*                                                                        */
57
/*    None                                                                */
58
/*                                                                        */
59
/*  CALLED BY                                                             */
60
/*                                                                        */
61
/*    Application Code                                                    */
62
/*    GUIX Internal Code                                                  */
63
/*                                                                        */
64
/*  RELEASE HISTORY                                                       */
65
/*                                                                        */
66
/*    DATE              NAME                      DESCRIPTION             */
67
/*                                                                        */
68
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
69
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
70
/*                                            resulting in version 6.1    */
71
/*                                                                        */
72
/**************************************************************************/
73
65883054
GX_BOOL  _gx_utility_rectangle_point_detect(GX_RECTANGLE *rectangle, GX_POINT point)
74
{
75
65883054
    if (rectangle -> gx_rectangle_left <= point.gx_point_x &&
76
51230433
        rectangle -> gx_rectangle_right >= point.gx_point_x &&
77
38638488
        rectangle -> gx_rectangle_top <= point.gx_point_y &&
78
36633056
        rectangle -> gx_rectangle_bottom >= point.gx_point_y)
79
    {
80
81
        /* Yes, the point is within the rectangle.  */
82
34684556
        return(GX_TRUE);
83
    }
84
    else
85
    {
86
87
        /* No, the point is not within the rectangle.  */
88
31198498
        return(GX_FALSE);
89
    }
90
}
91